2
0

clusterinfo.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package clusters
  2. // The following constants are used as keys into the cluster info map data structure
  3. const (
  4. ClusterInfoIdKey = "id"
  5. ClusterInfoNameKey = "name"
  6. ClusterInfoProviderKey = "provider"
  7. ClusterInfoProjectKey = "project"
  8. ClusterInfoAccountKey = "account"
  9. ClusterInfoRegionKey = "region"
  10. ClusterInfoProvisionerKey = "provisioner"
  11. ClusterInfoProfileKey = "clusterProfile"
  12. ClusterInfoLogCollectionKey = "logCollection"
  13. ClusterInfoProductAnalyticsKey = "productAnalytics"
  14. ClusterInfoErrorReportingKey = "errorReporting"
  15. ClusterInfoValuesReportingKey = "valuesReporting"
  16. ClusterInfoThanosEnabledKey = "thanosEnabled"
  17. ClusterInfoThanosOffsetKey = "thanosOffset"
  18. ClusterInfoVersionKey = "version"
  19. )
  20. // ClusterInfo holds attributes of Cluster from metrics pulled from Prometheus
  21. type ClusterInfo struct {
  22. ID string `json:"id"`
  23. Name string `json:"name"`
  24. Profile string `json:"profile"`
  25. Provider string `json:"provider"`
  26. Account string `json:"account"`
  27. Project string `json:"project"`
  28. Region string `json:"region"`
  29. Provisioner string `json:"provisioner"`
  30. }
  31. // Clone creates a copy of ClusterInfo and returns it
  32. func (ci *ClusterInfo) Clone() *ClusterInfo {
  33. if ci == nil {
  34. return nil
  35. }
  36. return &ClusterInfo{
  37. ID: ci.ID,
  38. Name: ci.Name,
  39. Profile: ci.Profile,
  40. Provider: ci.Provider,
  41. Account: ci.Account,
  42. Project: ci.Project,
  43. Region: ci.Region,
  44. Provisioner: ci.Provisioner,
  45. }
  46. }
  47. type ClusterMap interface {
  48. // GetClusterIDs returns a slice containing all of the cluster identifiers.
  49. GetClusterIDs() []string
  50. // AsMap returns the cluster map as a standard go map
  51. AsMap() map[string]*ClusterInfo
  52. // InfoFor returns the ClusterInfo entry for the provided clusterID or nil if it
  53. // doesn't exist
  54. InfoFor(clusterID string) *ClusterInfo
  55. // NameFor returns the name of the cluster provided the clusterID.
  56. NameFor(clusterID string) string
  57. // NameIDFor returns an identifier in the format "<clusterName>/<clusterID>" if the cluster has an
  58. // assigned name. Otherwise, just the clusterID is returned.
  59. NameIDFor(clusterID string) string
  60. }
  61. // ClusterInfoProvider is a contract which is capable of performing cluster info lookups.
  62. type ClusterInfoProvider interface {
  63. // GetClusterInfo returns a string map containing the local/remote connected cluster info
  64. GetClusterInfo() map[string]string
  65. }