-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcontainercluster.go
More file actions
45 lines (40 loc) · 1.68 KB
/
containercluster.go
File metadata and controls
45 lines (40 loc) · 1.68 KB
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
package illumioapi
import "strings"
// ContainerCluster represents a Kubernetes cluster
type ContainerCluster struct {
Href string `json:"href,omitempty"`
Name string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
ContainerRuntime string `json:"container_runtime,omitempty"`
ManagerType string `json:"manager_type,omitempty"`
Online *bool `json:"online,omitempty"`
KubelinkVersion string `json:"kubelink_version,omitempty"`
PceFqdn string `json:"pce_fqdn,omitempty"`
Nodes *[]Node `json:"nodes,omitempty"`
}
type Node struct {
Name string `json:"name,omitempty"`
PodSubnet string `json:"pod_subnet,omitempty"`
}
// GetContainerClusters returns a slice of ContainerCluster in the PCE.
// queryParameters can be used for filtering in the form of ["parameter"]="value".
// The first API call to the PCE does not use the async option.
// If the slice length is >=500, it re-runs with async.
func (p *PCE) GetContainerClusters(queryParameters map[string]string) (api APIResponse, err error) {
api, err = p.GetCollection("container_clusters", false, queryParameters, &p.ContainerClustersSlice)
if len(p.ContainerClustersSlice) >= 500 {
p.ContainerClustersSlice = nil
api, err = p.GetCollection("container_clusters", true, queryParameters, &p.ContainerClustersSlice)
}
// Load the PCE with the returned workloads
p.ContainerClusters = make(map[string]ContainerCluster)
for _, c := range p.ContainerClustersSlice {
p.ContainerClusters[c.Href] = c
p.ContainerClusters[c.Name] = c
}
return api, err
}
func (c *ContainerCluster) ID() string {
s := strings.Split(c.Href, "/")
return s[len(s)-1]
}