This repository has been archived by the owner on Sep 30, 2020. It is now read-only.
/
operation_targets.go
78 lines (66 loc) · 1.62 KB
/
operation_targets.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
75
76
77
78
package root
import "strings"
const (
OperationTargetAll = "all"
)
type OperationTargets []string
func AllOperationTargetsAsStringSlice() []string {
return []string{"all"}
}
func AllOperationTargetsWith(nodePoolNames []string, operationTargetNames []string) OperationTargets {
ts := []string{}
ts = append(ts, operationTargetNames...)
ts = append(ts, nodePoolNames...)
return OperationTargets(ts)
}
func OperationTargetsFromStringSlice(targets []string) OperationTargets {
return OperationTargets(targets)
}
func (ts OperationTargets) IncludeWorker(nodePoolName string) bool {
for _, t := range ts {
if t == nodePoolName {
return true
}
}
return false
}
func (ts OperationTargets) IncludeNetwork(networkStackName string) bool {
for _, t := range ts {
if t == networkStackName {
return true
}
}
return false
}
func (ts OperationTargets) IncludeControlPlane(controlPlaneStackName string) bool {
for _, t := range ts {
if t == controlPlaneStackName {
return true
}
}
return false
}
func (ts OperationTargets) IncludeEtcd(etcdStackName string) bool {
for _, t := range ts {
if t == etcdStackName {
return true
}
}
return false
}
func (ts OperationTargets) IncludeAll(cl *Cluster) bool {
return ts.IncludeNetwork(cl.Network().Config.NetworkStackName()) &&
ts.IncludeControlPlane(cl.ControlPlane().Config.ControlPlaneStackName()) &&
ts.IncludeEtcd(cl.Etcd().Config.EtcdStackName())
}
func (ts OperationTargets) IsAll() bool {
for _, t := range ts {
if t == OperationTargetAll {
return true
}
}
return false
}
func (ts OperationTargets) String() string {
return strings.Join(ts, ", ")
}