This is related to the discussion on the integrations/terraform-provider-github#1262
In June GitHub made the environments and environment protection rules generally available, however, the wait_timer and reviewers remains limited to enterprise.
Many developers would like to make use of this great new feature, but the bug in the Terraform provider currently proves to be a blocker.
The provider uses the go-github Go library under the hood and makes the following call:
_, _, err := client.Repositories.CreateUpdateEnvironment(ctx, owner, repoName, escapedEnvName, &updateData)
where the &updateData is a github.CreateUpdateEnvironment struct.
Looking at the code it seems that instead of sending nil value for wait_timer it defaults to 0.
// CreateUpdateEnvironment represents the fields required for the create/update operation
// following the Create/Update release example.
// See https://github.com/google/go-github/issues/992 for more information.
// Removed omitempty here as the API expects null values for reviewers and deployment_branch_policy to clear them.
type CreateUpdateEnvironment struct {
WaitTimer *int `json:"wait_timer"`
Reviewers []*EnvReviewers `json:"reviewers"`
DeploymentBranchPolicy *BranchPolicy `json:"deployment_branch_policy"`
}
This is causing the issue for us, as the API doesn't expect this parameter and returns 422.
I understand why the omitempty was removed, so I'm looking at what alternative solutions are possible to ensure environments fully work regardless of the payment plan.
This is related to the discussion on the integrations/terraform-provider-github#1262
In June GitHub made the environments and environment protection rules generally available, however, the
wait_timerandreviewersremains limited to enterprise.Many developers would like to make use of this great new feature, but the bug in the Terraform provider currently proves to be a blocker.
The provider uses the
go-githubGo library under the hood and makes the following call:where the
&updateDatais agithub.CreateUpdateEnvironmentstruct.Looking at the code it seems that instead of sending nil value for
wait_timerit defaults to 0.This is causing the issue for us, as the API doesn't expect this parameter and returns 422.
I understand why the
omitemptywas removed, so I'm looking at what alternative solutions are possible to ensure environments fully work regardless of the payment plan.