-
Notifications
You must be signed in to change notification settings - Fork 14
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
Conversation
prevent_auto_deploy
flag to create without deployprevent_auto_deploy
flag to create without deploy
@@ -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:"-"` |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unit test is failing...
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
env0/resource_environment_test.go
Outdated
), | ||
}, | ||
{ | ||
Config: resourceConfigCreate(resourceType, resourceName, map[string]interface{}{ |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood!
This reverts commit 9f102e0.
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
prevent_auto_deploy
apiManual QA against dev