/
suppress_funcs.go
55 lines (47 loc) · 1.81 KB
/
suppress_funcs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package vcd
//lint:file-ignore SA1019 ignore deprecated functions
import (
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
// suppressWordToEmptyString is a DiffSuppressFunc which ignore the change from word to empty string "".
// This is useful when API returns some default value but it is not set (and not sent via API) in config.
func suppressWordToEmptyString(word string) schema.SchemaDiffSuppressFunc {
return func(k string, old string, new string, d *schema.ResourceData) bool {
if old == word && new == "" {
return true
}
return false
}
}
// suppressNetworkUpgradedInterface is used to silence the changes in
// property "interface_type" in routed networks.
// In the old the version, the "internal" interface was implicit,
// while in the new one it is one of several.
// This function only considers the "internal" value, as the other interface types
// were not possible in the previous version
func suppressNetworkUpgradedInterface() schema.SchemaDiffSuppressFunc {
return func(k string, old string, new string, d *schema.ResourceData) bool {
if old == "" && new == "internal" {
return true
}
return false
}
}
// falseBoolSuppress suppresses change if value is set to false or is empty
func falseBoolSuppress() schema.SchemaDiffSuppressFunc {
return func(k string, old string, new string, d *schema.ResourceData) bool {
_, isTrue := d.GetOkExists(k)
return !isTrue
}
}
// suppressNewFalse always suppresses when new value is false
func suppressFalse() schema.SchemaDiffSuppressFunc {
return func(k string, old string, new string, d *schema.ResourceData) bool {
return new == "false"
}
}
// suppressCase is a schema.SchemaDiffSuppressFunc which ignore case changes
func suppressCase(k, old, new string, d *schema.ResourceData) bool {
return strings.EqualFold(old, new)
}