I have a DiffSuppressFunc, which sanitizes the string and removes the extra spaces or new lines on the string.
Basically the existing functionality works, like user provides a string as “abc \n”, “abc” get saved to state file and we suppress this diff.
Now when moving to plugin framework, I am not able to get rid of this.
I have created a ModifyPlan( function for this
like this
configKey := plan.Key.ValueString()
// State value is already normalized from the API
stateKey := state.Key.ValueString()
// If the normalized config matches the state, use the state value
if suppressKeyDiff(stateKey, configKey) {
plan.Key = state.Key
resp.Plan.Set(ctx, plan)
}
This isn’t working, on create, I am getting
Error: Provider produced inconsistent result after apply
produced an unexpected new value: .key: was cty.StringVal("abc\n"), but now cty.StringVal("abc").
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.