Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: approve_plan_automatically attribute fails for sub_environment #954

Merged
merged 6 commits into from
Sep 15, 2024

Conversation

TomerHeber
Copy link
Collaborator

Issue & Steps to Reproduce / Feature Request

fixes #947

Solution

  1. For workflow - always pass RequiredUserApproval as false in the deploy payload (for the root env).
  2. Updated acceptance tests.
  3. Updated harness tests.

@@ -1179,6 +1190,11 @@ func getDeployPayload(d *schema.ResourceData, apiClient client.ApiClientInterfac
payload.BlueprintRevision = revision.(string)
}

// For 'Workflows', the 'root' environment should never require a user approval.
if _, ok := d.GetOk("sub_environment_configuration"); ok {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be needed...
This might be a bug in the backend...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that the backend will error if this is 'undefined'.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be overridden by a project policy, this is a good extra step anyways.

@@ -415,7 +415,8 @@ func setEnvironmentSchema(ctx context.Context, d *schema.ResourceData, environme
d.Set("output", string(environment.LatestDeploymentLog.Output))
}

if environment.RequiresApproval != nil {
// Don't update this value for workflow environments - this value should always be 'false'.
if _, isWorkflow := d.GetOk("sub_environment_configuration"); !isWorkflow && environment.RequiresApproval != nil {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't modify the schema for workflow environment...
generally this would not be required... however due to the change in line 1195 (which I believe is a backend issue) - I had to add this here.

(see my comment in line 1195).

Copy link

@weinguy-env0 weinguy-env0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I'll ask for another pair of eyes on this one

}

// For 'Workflows', the 'root' environment should never require an approval.
if _, ok := d.GetOk("sub_environment_configuration"); ok {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we reuse the isWorkflow from line 980?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! fixed!

Comment on lines 991 to 993
// For 'Workflows', the 'root' environment should never require an approval.
if _, ok := d.GetOk("sub_environment_configuration"); ok {
payload.RequiresApproval = boolPtr(false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this if block is different than the one above?
I'm a bit confused

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 986 - is the use-case when someone excplicitly set 'approve_plan_automatically' to 'false' and it's a workflow - in that case we can quickly error out as bad schema set by the user.

line 992 - is the use-case where it's a workflow - the value is forced to be 'false'.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test of wrong terraform configuration where customer put approve_plan_automatically = false?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added b1d22bb

@github-actions github-actions bot added the ready to merge PR approved - can be merged once the PR owner is ready label Sep 15, 2024
@TomerHeber TomerHeber merged commit fdd9ac5 into main Sep 15, 2024
6 checks passed
@TomerHeber TomerHeber deleted the fix-workflow-approve-plan-#947 branch September 15, 2024 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix integration-tests provider ready to merge PR approved - can be merged once the PR owner is ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

approve_plan_automatically attribute fails for sub_environment
3 participants