-
Notifications
You must be signed in to change notification settings - Fork 0
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 Boolean Mismatch Error for treat_urls_as_media and trust_remote_code #33
base: main
Are you sure you want to change the base?
Conversation
func normalizeIndexSettings(state *IndexResourceModel, newState *IndexResourceModel) { | ||
// Handle boolean defaults | ||
if state.Settings.TreatUrlsAndPointersAsMedia.IsNull() && | ||
!newState.Settings.TreatUrlsAndPointersAsMedia.ValueBool() { |
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 newState.Settings.TreatUrlsAndPointersAsMedia.ValueBool()
falsey if the boolean value is set to false? If so, this logic would be wrong, so want to check.
@@ -519,6 +519,48 @@ func (r *indicesResource) findAndCreateState(indices []go_marqo.IndexDetail, ind | |||
return nil, false | |||
} | |||
|
|||
func normalizeIndexSettings(state *IndexResourceModel, newState *IndexResourceModel) { |
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 feels very brittle to changes in schema. In the worst case, adding new fields could potentially cause existing indexes to be deleted if we don't update this function.
Feels like it should have a more systematic solution, i.e. walk the newState
fields and descendant fields, and propagate nullish values.
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 thought so as well. So I'm not super happy with it yet.
problems:
- user does not define these fields so they are null
- api returns default values
- mismatch between null and the default values
Manual Solutions I've tried
- set incoming fields to null if they are null locally (not ideal, want to show full state to user)
- set undefined fields with the default value before create (not good, default value drift from cloud is a possibility)
Both don't seem appealing.
I'm looking for a way to indicate to terraform that some fields will be undefined in the user's statefile but should be expected from the api. Looking through the terraform documentation I've found this which seems to fit the function
No description provided.