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

feat(terraform): add ability to suppress github etag while being noisy when no actual state has been changed #1355

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 2 additions & 1 deletion helper/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,8 @@ func (m schemaMap) internalValidate(topSchemaMap schemaMap, attrsOnly bool) erro
return fmt.Errorf("%s: DefaultFunc is for configurable attributes,"+
"there's nothing to configure on computed-only field", k)
}
if v.DiffSuppressFunc != nil {
// Allow this behavior for etag, which is a special case (being too noisy)
if v.DiffSuppressFunc != nil && k != "etag" {
return fmt.Errorf("%s: DiffSuppressFunc is for suppressing differences"+
" between config and state representation. "+
"There is no config for computed-only field, nothing to compare.", k)
Expand Down
23 changes: 22 additions & 1 deletion helper/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4797,6 +4797,28 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
true,
},

"Etag with DiffSuppressFunc": {
map[string]*Schema{
"etag": {
Type: TypeString,
Computed: true,
DiffSuppressFunc: func(k, oldValue, newValue string, d *ResourceData) bool { return true },
},
},
false,
},

"Non Etag with DiffSuppressFunc": {
map[string]*Schema{
"non_etag": {
Type: TypeString,
Computed: true,
DiffSuppressFunc: func(k, oldValue, newValue string, d *ResourceData) bool { return true },
},
},
true,
},

"DiffSuppressOnRefresh without DiffSuppressFunc": {
map[string]*Schema{
"string": {
Expand Down Expand Up @@ -5064,7 +5086,6 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
}
})
}

}

func TestSchemaMap_DiffSuppress(t *testing.T) {
Expand Down