-
Notifications
You must be signed in to change notification settings - Fork 7
/
structure_source_domain_settings.go
52 lines (44 loc) · 1.28 KB
/
structure_source_domain_settings.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
package main
// Flatteners
func flattenSourceDomainSettings(in []*DomainSettings) []interface{} {
if in == nil {
return []interface{}{}
}
out := make([]interface{}, 0, len(in))
for i := range in {
var obj = make(map[string]interface{})
obj["password"] = in[i].Password
obj["forest_name"] = in[i].ForestName
obj["port"] = in[i].Port
obj["user"] = in[i].User
obj["use_ssl"] = in[i].UseSSL
obj["authorization_type"] = in[i].AuthorizationType
obj["domain_dn"] = in[i].DomainDN
obj["servers"] = toArrayInterface(in[i].Servers)
out = append(out, obj)
}
return out
}
// Expanders
func expandSourceDomainSettings(p []interface{}) []*DomainSettings {
if len(p) == 0 || p[0] == nil {
return []*DomainSettings{}
}
out := make([]*DomainSettings, 0, len(p))
for i := range p {
obj := DomainSettings{}
in := p[i].(map[string]interface{})
obj.Password = in["password"].(string)
obj.ForestName = in["forest_name"].(string)
obj.User = in["user"].(string)
obj.UseSSL = in["use_ssl"].(bool)
obj.AuthorizationType = in["authorization_type"].(string)
if v, ok := in["servers"].([]interface{}); ok && len(v) > 0 {
obj.Servers = toArrayString(v)
}
obj.Port = in["port"].(string)
obj.DomainDN = in["domain_dn"].(string)
out = append(out, &obj)
}
return out
}