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

Feat: add prevent_auto_deploy flag to create without deploy #804

Merged
merged 5 commits into from
Mar 12, 2024

Conversation

tomer-landesman
Copy link
Contributor

@tomer-landesman tomer-landesman commented Mar 12, 2024

Issue & Steps to Reproduce / Feature Request

we want to support the new prevent_auto_deploy argument of the create envirionment API.

using the property, the user can skip the deployment of the environment in env0 and only create it on resource create. updating and destroying should remain the same

Solution

  • add support for the new prevent_auto_deploy api

Manual QA against dev

image

@TomerHeber TomerHeber changed the title FEAT: add prevent_auto_deploy flag to create without deploy Feat: add prevent_auto_deploy flag to create without deploy Mar 12, 2024
@@ -138,6 +138,7 @@ type EnvironmentCreate struct {
IsRemoteBackend *bool `json:"isRemoteBackend,omitempty" tfschema:"-"`
Type string `json:"type,omitempty"`
DriftDetectionRequest *DriftDetectionRequest `json:"driftDetectionRequest,omitempty" tfschema:"-"`
PreventAutoDeploy *bool `json:"preventAutoDeploy,omitempty" tfschema:"-"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is it a pointer, is it okay to always pass false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if it won't be a pointer and the user won't specify it - will it evaluate to false? I think we could always pass it but is it really better?

Copy link
Collaborator

Choose a reason for hiding this comment

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

it simplifies the code significantly.

But it depends on the API. Some of the API's params do have "3" values: "pass nothing", "false", "true".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can try passing false as default. let me see

Copy link
Collaborator

Choose a reason for hiding this comment

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

not a big deal in this case...
I approved the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it anyway cause it should be simpler - can you take a quick look?

Copy link
Collaborator

Choose a reason for hiding this comment

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

unit test is failing...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea I gave up on the bool change, it failing to much tests now 😅

"prevent_auto_deploy": {
Type: schema.TypeBool,
Description: "use this flag to prevent auto deploy on environment creation",
Optional: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

if it's okay to always pass false, you can add a default: false.

),
},
{
Config: resourceConfigCreate(resourceType, resourceName, map[string]interface{}{
Copy link
Collaborator

Choose a reason for hiding this comment

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

this step isn't required here...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it fails without it - care to explain what it does?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It tests for an error. Weird that it would fail without it.
What's the error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry my bad, had to fix the assertions as well - the API of those tests is confusing AF 😅
removed unnecessary step

@@ -799,6 +804,11 @@ func getCreatePayload(d *schema.ResourceData, apiClient client.ApiClientInterfac
payload.PullRequestPlanDeployments = boolPtr(val.(bool))
}

//lint:ignore SA1019 reason: https://github.com/hashicorp/terraform-plugin-sdk/issues/817
if val, exists := d.GetOkExists("prevent_auto_deploy"); exists {
Copy link
Collaborator

Choose a reason for hiding this comment

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

you're missing more use-cases.

Search for the string "auto_deploy_on_path_changes_only"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why tho? I'm interested only in Create flow - update and delete are not interesting to me (even if this property is changed - nothing should be sone because its not really persisted at the backend)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Understood!

@github-actions github-actions bot added the ready to merge PR approved - can be merged once the PR owner is ready label Mar 12, 2024
This reverts commit 9f102e0.
@tomer-landesman tomer-landesman merged commit 625a1fb into main Mar 12, 2024
6 checks passed
@tomer-landesman tomer-landesman deleted the feat-prevent-auto-deploy branch March 12, 2024 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-client feature 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.

2 participants