فهرست منبع

Merge pull request #487 from kubecost/bolt/cluster-profile

Include Cluster Profile on ClusterInfo
Matt Bolt 5 سال پیش
والد
کامیت
667f1179c7
2فایلهای تغییر یافته به همراه15 افزوده شده و 0 حذف شده
  1. 8 0
      pkg/costmodel/router.go
  2. 7 0
      pkg/env/costmodelenv.go

+ 8 - 0
pkg/costmodel/router.go

@@ -50,6 +50,7 @@ var (
 	productAnalyticsEnabled         bool   = env.IsProductAnalyticsEnabled()
 	errorReportingEnabled           bool   = env.IsErrorReportingEnabled()
 	valuesReportingEnabled          bool   = env.IsValuesReportingEnabled()
+	clusterProfile                  string = env.GetClusterProfile()
 	multiclusterDBBasicAuthUsername string = env.GetMultiClusterBasicAuthUsername()
 	multiclusterDBBasicAuthPW       string = env.GetMultiClusterBasicAuthPassword()
 )
@@ -625,6 +626,13 @@ func (p *Accesses) ClusterInfo(w http.ResponseWriter, r *http.Request, ps httpro
 		klog.Infof("Could not get k8s version info: %s", err.Error())
 	}
 
+	// Ensure we create the info object if it doesn't exist
+	if data == nil {
+		data = make(map[string]string)
+	}
+
+	data["clusterProfile"] = clusterProfile
+
 	// Include Product Reporting Flags with Cluster Info
 	writeReportingFlags(data)
 

+ 7 - 0
pkg/env/costmodelenv.go

@@ -7,6 +7,7 @@ const (
 
 	KubecostNamespaceEnvVar        = "KUBECOST_NAMESPACE"
 	ClusterIDEnvVar                = "CLUSTER_ID"
+	ClusterProfileEnvVar           = "CLUSTER_PROFILE"
 	PrometheusServerEndpointEnvVar = "PROMETHEUS_SERVER_ENDPOINT"
 	MaxQueryConcurrencyEnvVar      = "MAX_QUERY_CONCURRENCY"
 	RemoteEnabledEnvVar            = "REMOTE_WRITE_ENABLED"
@@ -55,6 +56,12 @@ func GetKubecostNamespace() string {
 	return Get(KubecostNamespaceEnvVar, "kubecost")
 }
 
+// GetClusterProfile returns the environment variable value for ClusterProfileEnvVar which
+// represents the cluster profile configured for
+func GetClusterProfile() string {
+	return Get(ClusterProfileEnvVar, "development")
+}
+
 // GetClusterID returns the environment variable value for ClusterIDEnvVar which represents the
 // configurable identifier used for multi-cluster metric emission.
 func GetClusterID() string {