Skip to content
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

Add a rule for removing diff suppress functions #10167

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/content/develop/breaking-changes/breaking-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ For more information, see
and modifying examples and modules may achieve the intended effect with a smaller blast radius.
* <a name="field-changing-data-format"></a> Modifying how field data is stored in state
* For example, changing the case of a value returned by the API in a flattener or decorder
* Removing diff suppression from a field.
* <a name="field-removing-diff-suppress"></a> Removing diff suppression from a field.
* For MMv1 resources, removing `diff_suppress_func` from a field.
* For handwritten resources, removing `DiffSuppressFunc` from a field.
* Removing update support from a field.
Expand Down
20 changes: 20 additions & 0 deletions tools/diff-processor/rules/rules_field.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var FieldRules = []FieldRule{
fieldRule_DefaultModification,
fieldRule_GrowingMin,
fieldRule_ShrinkingMax,
fieldRule_RemovingDiffSuppress,
fieldRule_ChangingFieldDataFormat,
}

Expand Down Expand Up @@ -211,6 +212,25 @@ func fieldRule_ShrinkingMax_func(old, new *schema.Schema, mc MessageContext) str
return ""
}

var fieldRule_RemovingDiffSuppress = FieldRule{
name: "Removing Diff Suppress Function",
definition: "Diff suppress functions cannot be removed. Otherwise terraform configurations that previously had no diffs would show diffs.",
message: "Field {{field}} lost its diff suppress function",
identifier: "field-removing-diff-suppress",
isRuleBreak: fieldRule_RemovingDiffSuppress_func,
}

func fieldRule_RemovingDiffSuppress_func(old, new *schema.Schema, mc MessageContext) string {
// ignore for added / removed fields
if old == nil || new == nil {
return ""
}
if old.DiffSuppressFunc != nil && new.DiffSuppressFunc == nil {
return populateMessageContext(mc.message, mc)
}
return ""
}

func fieldRulesToRuleArray(frs []FieldRule) []Rule {
var rules []Rule
for _, fr := range frs {
Expand Down
Loading