-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
cluster.go
46 lines (39 loc) · 1.39 KB
/
cluster.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
package cmdutils
import (
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
"github.com/weaveworks/eksctl/pkg/ctl/cmdutils/filter"
"github.com/weaveworks/eksctl/pkg/eks"
)
// ApplyFilter applies nodegroup filters and returns a log function
func ApplyFilter(clusterConfig *api.ClusterConfig, ngFilter filter.NodegroupFilter) func() {
var (
filteredNodeGroups []*api.NodeGroup
filteredManagedNodeGroups []*api.ManagedNodeGroup
)
for _, ng := range clusterConfig.NodeGroups {
if ngFilter.Match(ng.NameString()) {
filteredNodeGroups = append(filteredNodeGroups, ng)
}
}
for _, ng := range clusterConfig.ManagedNodeGroups {
if ngFilter.Match(ng.NameString()) {
filteredManagedNodeGroups = append(filteredManagedNodeGroups, ng)
}
}
clusterConfig.NodeGroups, clusterConfig.ManagedNodeGroups = filteredNodeGroups, filteredManagedNodeGroups
return func() {
ngFilter.LogInfo(clusterConfig)
}
}
// ToKubeNodeGroups combines managed and unmanaged nodegroups and returns a slice of eks.KubeNodeGroup containing
// both types of nodegroups
func ToKubeNodeGroups(clusterConfig *api.ClusterConfig) []eks.KubeNodeGroup {
var kubeNodeGroups []eks.KubeNodeGroup
for _, ng := range clusterConfig.NodeGroups {
kubeNodeGroups = append(kubeNodeGroups, ng)
}
for _, ng := range clusterConfig.ManagedNodeGroups {
kubeNodeGroups = append(kubeNodeGroups, ng)
}
return kubeNodeGroups
}