@@ -21,6 +21,7 @@ import (
2121 "crypto/sha256"
2222 "encoding/base64"
2323 "fmt"
24+ "math/bits"
2425 "strings"
2526)
2627
@@ -59,27 +60,29 @@ const (
5960 ClusterProviderNameKey string = "cluster.appscode.com/provider"
6061 ClusterProfileLabel string = "cluster.appscode.com/profile"
6162
62- AceOrgIDKey string = "ace.appscode.com/org-id"
63- ClientOrgKey string = "ace.appscode.com/client-org"
64- ClientOrgMonitoringKey string = "ace.appscode.com/client-org-monitoring"
65- ClientKeyPrefix string = "client.ace.appscode.com/"
63+ AceOrgIDKey string = "ace.appscode.com/org-id"
64+ AceEnableResourceTrialKey string = "ace.appscode.com/enable-resource-trial"
65+ ClientOrgKey string = "ace.appscode.com/client-org"
66+ ClientOrgMonitoringKey string = "ace.appscode.com/client-org-monitoring"
67+ ClientKeyPrefix string = "client.ace.appscode.com/"
6668
6769 ClusterClaimKeyID string = "id.k8s.io"
6870 ClusterClaimKeyInfo string = "cluster.ace.info"
6971 ClusterClaimKeyFeatures string = "features.ace.info"
7072)
7173
7274type ClusterMetadata struct {
73- UID string `json:"uid" protobuf:"bytes,1,opt,name=uid"`
74- Name string `json:"name,omitempty" protobuf:"bytes,2,opt,name=name"`
75- DisplayName string `json:"displayName,omitempty" protobuf:"bytes,3,opt,name=displayName"`
76- Provider HostingProvider `json:"provider,omitempty" protobuf:"bytes,4,opt,name=provider,casttype=HostingProvider"`
77- OwnerID string `json:"ownerID,omitempty" protobuf:"bytes,5,opt,name=ownerID"`
78- OwnerType string `json:"ownerType,omitempty" protobuf:"bytes,6,opt,name=ownerType"`
79- APIEndpoint string `json:"apiEndpoint,omitempty" protobuf:"bytes,7,opt,name=apiEndpoint"`
80- CABundle string `json:"caBundle,omitempty" protobuf:"bytes,8,opt,name=caBundle"`
81- ManagerID string `json:"managerID,omitempty" protobuf:"bytes,9,opt,name=managerID"`
82- HubClusterID string `json:"hubClusterID,omitempty" protobuf:"bytes,10,opt,name=hubClusterID"`
75+ UID string `json:"uid" protobuf:"bytes,1,opt,name=uid"`
76+ Name string `json:"name,omitempty" protobuf:"bytes,2,opt,name=name"`
77+ DisplayName string `json:"displayName,omitempty" protobuf:"bytes,3,opt,name=displayName"`
78+ Provider HostingProvider `json:"provider,omitempty" protobuf:"bytes,4,opt,name=provider,casttype=HostingProvider"`
79+ OwnerID string `json:"ownerID,omitempty" protobuf:"bytes,5,opt,name=ownerID"`
80+ OwnerType string `json:"ownerType,omitempty" protobuf:"bytes,6,opt,name=ownerType"`
81+ APIEndpoint string `json:"apiEndpoint,omitempty" protobuf:"bytes,7,opt,name=apiEndpoint"`
82+ CABundle string `json:"caBundle,omitempty" protobuf:"bytes,8,opt,name=caBundle"`
83+ ManagerID string `json:"managerID,omitempty" protobuf:"bytes,9,opt,name=managerID"`
84+ HubClusterID string `json:"hubClusterID,omitempty" protobuf:"bytes,10,opt,name=hubClusterID"`
85+ CloudServiceAuthMode string `json:"cloudServiceAuthMode,omitempty" protobuf:"bytes,11,opt,name=cloudServiceAuthMode"`
8386}
8487
8588func (md ClusterMetadata ) Manager () string {
@@ -175,6 +178,18 @@ func (cm ClusterManager) Strings() []string {
175178 return out
176179}
177180
181+ func isPowerOfTwo (n int ) bool {
182+ return n > 0 && (n & (n - 1 )) == 0
183+ }
184+
185+ func (cm ClusterManager ) Name () string {
186+ if ! isPowerOfTwo (int (cm )) {
187+ return cm .String ()
188+ }
189+ idx := bits .TrailingZeros (uint (cm ))
190+ return _ClusterManagerNames [idx ]
191+ }
192+
178193func (cm ClusterManager ) String () string {
179194 return strings .Join (cm .Strings (), "," )
180195}
0 commit comments