Skip to content

Commit 2540d08

Browse files
authored
feat: cdn support more params (#1169)
1 parent f507025 commit 2540d08

File tree

4 files changed

+2774
-136
lines changed

4 files changed

+2774
-136
lines changed

tencentcloud/internal/helper/helper.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import (
44
"bytes"
55
"crypto/rand"
66
"encoding/base64"
7+
"encoding/json"
78
"fmt"
9+
"reflect"
810
"sort"
911
"strings"
1012
"time"
@@ -100,6 +102,21 @@ func StringsContain(ss []string, str string) bool {
100102
return false
101103
}
102104

105+
func DiffSupressJSON(k, olds, news string, d *schema.ResourceData) bool {
106+
var oldJson interface{}
107+
err := json.Unmarshal([]byte(olds), &oldJson)
108+
if err != nil {
109+
return olds == news
110+
}
111+
var newJson interface{}
112+
err = json.Unmarshal([]byte(news), &newJson)
113+
if err != nil {
114+
return olds == news
115+
}
116+
flag := reflect.DeepEqual(oldJson, newJson)
117+
return flag
118+
}
119+
103120
/*
104121
Serialize slice into the usage document
105122
eg["status_change","abnormal"] will be "`abnormal`,`status_change`"
@@ -129,6 +146,15 @@ func InterfacesHeadMap(d *schema.ResourceData, key string) (result map[string]in
129146
return
130147
}
131148

149+
func SetMapInterfaces(d *schema.ResourceData, key string, values ...map[string]interface{}) error {
150+
val := make([]interface{}, 0, len(values))
151+
for i := range values {
152+
item := values[i]
153+
val = append(val, item)
154+
}
155+
return d.Set(key, val)
156+
}
157+
132158
func InterfaceToMap(d map[string]interface{}, key string) (result map[string]interface{}, ok bool) {
133159
if v, ok := d[key]; ok {
134160
if len(v.([]interface{})) != 1 {

0 commit comments

Comments
 (0)