-
Notifications
You must be signed in to change notification settings - Fork 13
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
Chore: add soft delete to configuration variable #866
Chore: add soft delete to configuration variable #866
Conversation
@@ -110,6 +110,11 @@ func resourceConfigurationVariable() *schema.Resource { | |||
Description: "the value of this variable must match provided regular expression (enforced only in env0 UI)", | |||
Optional: true, | |||
}, | |||
"soft_delete": { |
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.
@TomerHeber now that I think about it we could have added it to "environment import resource" as well so that it won't be implicit that its not actually deleted
"soft_delete": { | ||
Type: schema.TypeBool, | ||
Description: "soft delete the configuration variable, once removed from the configuration it won't be deleted from env0", | ||
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.
Please add a default value. This prevents many issues with bool types.
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.
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.
what are the issues?
@@ -237,6 +242,11 @@ func resourceConfigurationVariableUpdate(ctx context.Context, d *schema.Resource | |||
} | |||
|
|||
func resourceConfigurationVariableDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { | |||
// don't delete if soft delete is set | |||
if softDelete, ok := d.GetOk("soft_delete"); ok && softDelete.(bool) { |
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 you put a default you can just get the softDelete.
GetOk does not work properly with booleans...
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.
"soft_delete": { | ||
Type: schema.TypeBool, | ||
Description: "soft delete the configuration variable, once removed from the configuration it won't be deleted from env0", | ||
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.
same here - please add a default.
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.
env0/resource_environment_import.go
Outdated
func resourceEnvironmentImportDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
// don't delete if soft delete is set | ||
if softDelete, ok := d.GetOk("soft_delete"); ok && softDelete.(bool) { |
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.
same here.. once you have a default.. just get the value...
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.
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.
LGTM - just a few small changes required.
…onfiguration-variables-on-removal-#856
@@ -58,6 +58,12 @@ func resourceEnvironmentImport() *schema.Resource { | |||
Description: "iac version of the environment", | |||
Optional: true, | |||
}, | |||
"soft_delete": { | |||
Type: schema.TypeBool, | |||
Description: "soft delete the configuration variable, once removed from the configuration it won't be deleted from env0", |
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.
Is this comment correct? default is 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.
yeah if they set the field ( to true ) it won't delete
I just defaulted it to false so it won't be set by default ( we want soft delete to be explicit )
we generate the code that uses these flags so we'll just set soft_delete = true
we don't really expect customers to use those flags, but we just didn't want the resource to act in unexpected ways without it being explicit
@TomerHeber please also see this commit 22a1e2e |
…onfiguration-variables-on-removal-#856
Issue & Steps to Reproduce / Feature Request
Part of :#856
We need to be able to remove configuration variables from code without actually deleting them
In environment import we initialize variables for the user to review and create an environment from
These resources are not expected to be committed, managed other then applying them once, so we need them to not be removed once the configuration is removed
Edit:
After adding a soft delete flag to config variable it I realized we should have added one to env import resource to make this strange behavior explicit 👍🏻 ( So I added that as well )