-
Notifications
You must be signed in to change notification settings - Fork 515
/
clusterinfo.go
75 lines (65 loc) · 2.45 KB
/
clusterinfo.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
package clusters
// The following constants are used as keys into the cluster info map data structure
const (
ClusterInfoIdKey = "id"
ClusterInfoNameKey = "name"
ClusterInfoProviderKey = "provider"
ClusterInfoProjectKey = "project"
ClusterInfoAccountKey = "account"
ClusterInfoRegionKey = "region"
ClusterInfoProvisionerKey = "provisioner"
ClusterInfoProfileKey = "clusterProfile"
ClusterInfoLogCollectionKey = "logCollection"
ClusterInfoProductAnalyticsKey = "productAnalytics"
ClusterInfoErrorReportingKey = "errorReporting"
ClusterInfoValuesReportingKey = "valuesReporting"
ClusterInfoThanosEnabledKey = "thanosEnabled"
ClusterInfoThanosOffsetKey = "thanosOffset"
ClusterInfoVersionKey = "version"
)
// ClusterInfo holds attributes of Cluster from metrics pulled from Prometheus
type ClusterInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Profile string `json:"profile"`
Provider string `json:"provider"`
Account string `json:"account"`
Project string `json:"project"`
Region string `json:"region"`
Provisioner string `json:"provisioner"`
}
// Clone creates a copy of ClusterInfo and returns it
func (ci *ClusterInfo) Clone() *ClusterInfo {
if ci == nil {
return nil
}
return &ClusterInfo{
ID: ci.ID,
Name: ci.Name,
Profile: ci.Profile,
Provider: ci.Provider,
Account: ci.Account,
Project: ci.Project,
Region: ci.Region,
Provisioner: ci.Provisioner,
}
}
type ClusterMap interface {
// GetClusterIDs returns a slice containing all of the cluster identifiers.
GetClusterIDs() []string
// AsMap returns the cluster map as a standard go map
AsMap() map[string]*ClusterInfo
// InfoFor returns the ClusterInfo entry for the provided clusterID or nil if it
// doesn't exist
InfoFor(clusterID string) *ClusterInfo
// NameFor returns the name of the cluster provided the clusterID.
NameFor(clusterID string) string
// NameIDFor returns an identifier in the format "<clusterName>/<clusterID>" if the cluster has an
// assigned name. Otherwise, just the clusterID is returned.
NameIDFor(clusterID string) string
}
// ClusterInfoProvider is a contract which is capable of performing cluster info lookups.
type ClusterInfoProvider interface {
// GetClusterInfo returns a string map containing the local/remote connected cluster info
GetClusterInfo() map[string]string
}