-
Notifications
You must be signed in to change notification settings - Fork 192
fix: Sets default value for WithDefaultAlertsSettings during state import #3105
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
53de463
26f7353
5e67e14
57ddae6
7bc763e
de2589d
7934ad0
af84e38
66e55e9
e11fc3f
bd76a93
d0cb772
57f8e64
4ae2ccc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
resource/mongodbatlas_project: Sets default value for `with_default_alerts_settings` during state import | ||
``` |
oarbusi marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -333,9 +333,13 @@ func (r *projectRS) ImportState(ctx context.Context, req resource.ImportStateReq | |
} | ||
|
||
func updatePlanFromConfig(projectPlanNewPtr, projectPlan *TFProjectRSModel) { | ||
// we need to reset defaults from what was previously in the state: | ||
// https://discuss.hashicorp.com/t/boolean-optional-default-value-migration-to-framework/55932 | ||
EspenAlbert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
projectPlanNewPtr.WithDefaultAlertsSettings = projectPlan.WithDefaultAlertsSettings | ||
// After import the state&plan will be null so we set to true (default value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The user will still get a plan change after import if they have set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is still a possibility, I'm thinking if we should even implement this fix. This sounds like it should be expected behavior that WithDefaultAlertsSettings will not be set during import and maybe something we can call out in our documentation instead. I'd find it harder to explain to users why import shows an update if |
||
if projectPlanNewPtr.WithDefaultAlertsSettings.IsNull() && projectPlan.WithDefaultAlertsSettings.IsNull() { | ||
projectPlanNewPtr.WithDefaultAlertsSettings = types.BoolValue(true) | ||
} else { | ||
// Force value from plan as this is not returned from the API to avoid inconsistent result errors | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it just feels a workaround from an API limitation, have we reached out to the team owning this feature? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand is a create-only parameter that has a side effect of creating alert settings, but I'll check with upstream. Api Docs |
||
projectPlanNewPtr.WithDefaultAlertsSettings = projectPlan.WithDefaultAlertsSettings | ||
} | ||
projectPlanNewPtr.ProjectOwnerID = projectPlan.ProjectOwnerID | ||
if projectPlan.Tags.IsNull() && len(projectPlanNewPtr.Tags.Elements()) == 0 { | ||
projectPlanNewPtr.Tags = types.MapNull(types.StringType) | ||
|
Uh oh!
There was an error while loading. Please reload this page.