forked from rancher/terraform-provider-rke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
structure_rke_cluster_private_registries.go
65 lines (48 loc) · 1.1 KB
/
structure_rke_cluster_private_registries.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
package rke
import (
rancher "github.com/rancher/rke/types"
)
// Flatteners
func flattenRKEClusterPrivateRegistries(p []rancher.PrivateRegistry) []interface{} {
out := []interface{}{}
for _, in := range p {
obj := make(map[string]interface{})
obj["is_default"] = in.IsDefault
if len(in.Password) > 0 {
obj["password"] = in.Password
}
if len(in.URL) > 0 {
obj["url"] = in.URL
}
if len(in.User) > 0 {
obj["user"] = in.User
}
out = append(out, obj)
}
return out
}
// Expanders
func expandRKEClusterPrivateRegistries(p []interface{}) []rancher.PrivateRegistry {
out := []rancher.PrivateRegistry{}
if len(p) == 0 || p[0] == nil {
return out
}
for i := range p {
in := p[i].(map[string]interface{})
obj := rancher.PrivateRegistry{}
if v, ok := in["is_default"].(bool); ok {
obj.IsDefault = v
}
if v, ok := in["password"].(string); ok && len(v) > 0 {
obj.Password = v
}
if v, ok := in["url"].(string); ok && len(v) > 0 {
obj.URL = v
}
if v, ok := in["user"].(string); ok && len(v) > 0 {
obj.User = v
}
out = append(out, obj)
}
return out
}