forked from cloudflare/terraform-provider-cloudflare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
39 lines (33 loc) · 824 Bytes
/
utils.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
package cloudflare
import "github.com/hashicorp/terraform/helper/schema"
func expandInterfaceToStringList(list interface{}) []string {
ifaceList := list.([]interface{})
vs := make([]string, 0, len(ifaceList))
for _, v := range ifaceList {
vs = append(vs, v.(string))
}
return vs
}
func flattenStringList(list []string) []interface{} {
vs := make([]interface{}, 0, len(list))
for _, v := range list {
vs = append(vs, v)
}
return vs
}
func flattenIntList(list []int) []interface{} {
vs := make([]interface{}, 0, len(list))
for _, v := range list {
vs = append(vs, v)
}
return vs
}
func IntIdentity(i interface{}) int {
return i.(int)
}
func HashByMapKey(key string) func(v interface{}) int {
return func(v interface{}) int {
m := v.(map[string]interface{})
return schema.HashString(m[key])
}
}