forked from tdegiacinto/terraform-provider-elasticsearch
/
diff_suppress_funcs.go
91 lines (74 loc) · 2.07 KB
/
diff_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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main
import (
"encoding/json"
"reflect"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func diffSuppressIndexTemplate(k, old, new string, d *schema.ResourceData) bool {
var oo, no interface{}
if err := json.Unmarshal([]byte(old), &oo); err != nil {
return false
}
if err := json.Unmarshal([]byte(new), &no); err != nil {
return false
}
if om, ok := oo.(map[string]interface{}); ok {
normalizeIndexTemplate(om)
}
if nm, ok := no.(map[string]interface{}); ok {
normalizeIndexTemplate(nm)
}
return reflect.DeepEqual(oo, no)
}
func diffSuppressDestination(k, old, new string, d *schema.ResourceData) bool {
var oo, no interface{}
if err := json.Unmarshal([]byte(old), &oo); err != nil {
return false
}
if err := json.Unmarshal([]byte(new), &no); err != nil {
return false
}
if om, ok := oo.(map[string]interface{}); ok {
normalizeDestination(om)
}
if nm, ok := no.(map[string]interface{}); ok {
normalizeDestination(nm)
}
return reflect.DeepEqual(oo, no)
}
func suppressEquivalentJson(k, old, new string, d *schema.ResourceData) bool {
var oldObj, newObj interface{}
if err := json.Unmarshal([]byte(old), &oldObj); err != nil {
return false
}
if err := json.Unmarshal([]byte(new), &newObj); err != nil {
return false
}
return reflect.DeepEqual(oldObj, newObj)
}
func diffSuppressIndexLifecyclePolicy(k, old, new string, d *schema.ResourceData) bool {
var oo, no interface{}
if err := json.Unmarshal([]byte(old), &oo); err != nil {
return false
}
if err := json.Unmarshal([]byte(new), &no); err != nil {
return false
}
if om, ok := oo.(map[string]interface{}); ok {
normalizeIndexLifecyclePolicy(om)
}
if nm, ok := no.(map[string]interface{}); ok {
normalizeIndexLifecyclePolicy(nm)
}
return reflect.DeepEqual(oo, no)
}
func diffSuppressIngestPipeline(k, old, new string, d *schema.ResourceData) bool {
var oo, no interface{}
if err := json.Unmarshal([]byte(old), &oo); err != nil {
return false
}
if err := json.Unmarshal([]byte(new), &no); err != nil {
return false
}
return reflect.DeepEqual(oo, no)
}