-
Notifications
You must be signed in to change notification settings - Fork 90
/
structures.go
74 lines (68 loc) · 1.88 KB
/
structures.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
package argocd
import (
application "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func expandApplicationDestinations(ds *schema.Set) (
result []application.ApplicationDestination) {
for _, dest := range ds.List() {
result = append(result, expandApplicationDestination(dest))
}
return
}
func expandSyncWindows(sws []interface{}) (
result []*application.SyncWindow) {
for _, _sw := range sws {
sw := _sw.(map[string]interface{})
result = append(
result,
&application.SyncWindow{
Applications: expandStringList(sw["applications"].([]interface{})),
Clusters: expandStringList(sw["clusters"].([]interface{})),
Duration: sw["duration"].(string),
Kind: sw["kind"].(string),
ManualSync: sw["manual_sync"].(bool),
Namespaces: expandStringList(sw["namespaces"].([]interface{})),
Schedule: sw["schedule"].(string),
},
)
}
return
}
func expandK8SGroupKind(groupKinds *schema.Set) (
result []meta.GroupKind) {
for _, _gk := range groupKinds.List() {
gk := _gk.(map[string]interface{})
result = append(result, meta.GroupKind{
Group: gk["group"].(string),
Kind: gk["kind"].(string),
})
}
return
}
func flattenK8SGroupKinds(gks []meta.GroupKind) (
result []map[string]string) {
for _, gk := range gks {
result = append(result, map[string]string{
"group": gk.Group,
"kind": gk.Kind,
})
}
return
}
func flattenSyncWindows(sws application.SyncWindows) (
result []map[string]interface{}) {
for _, sw := range sws {
result = append(result, map[string]interface{}{
"applications": sw.Applications,
"clusters": sw.Clusters,
"duration": sw.Duration,
"kind": sw.Kind,
"manual_sync": sw.ManualSync,
"namespaces": sw.Namespaces,
"schedule": sw.Schedule,
})
}
return
}