Răsfoiți Sursa

disable legacy api option for scale

Ajay Tripathy 5 ani în urmă
părinte
comite
be58a76c03
2 a modificat fișierele cu 13 adăugiri și 4 ștergeri
  1. 4 0
      pkg/cloud/gcpprovider.go
  2. 9 4
      pkg/env/costmodelenv.go

+ 4 - 0
pkg/cloud/gcpprovider.go

@@ -309,6 +309,10 @@ func (gcp *GCP) UpdateConfig(r io.Reader, updateType string) (*CustomPricing, er
 // "start" and "end" are dates of the format YYYY-MM-DD
 // "start" and "end" are dates of the format YYYY-MM-DD
 // "aggregator" is the tag used to determine how to allocate those assets, ie namespace, pod, etc.
 // "aggregator" is the tag used to determine how to allocate those assets, ie namespace, pod, etc.
 func (gcp *GCP) ExternalAllocations(start string, end string, aggregators []string, filterType string, filterValue string, crossCluster bool) ([]*OutOfClusterAllocation, error) {
 func (gcp *GCP) ExternalAllocations(start string, end string, aggregators []string, filterType string, filterValue string, crossCluster bool) ([]*OutOfClusterAllocation, error) {
+	if env.LegacyExternalCostsAPIDisabled() {
+		return nil, fmt.Errorf("Legacy External Allocations API disabled.")
+	}
+
 	c, err := gcp.Config.GetCustomPricingData()
 	c, err := gcp.Config.GetCustomPricingData()
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err

+ 9 - 4
pkg/env/costmodelenv.go

@@ -15,8 +15,8 @@ const (
 	AWSAccessKeySecretEnvVar = "AWS_SECRET_ACCESS_KEY"
 	AWSAccessKeySecretEnvVar = "AWS_SECRET_ACCESS_KEY"
 	AWSClusterIDEnvVar       = "AWS_CLUSTER_ID"
 	AWSClusterIDEnvVar       = "AWS_CLUSTER_ID"
 
 
-	AzureStorageAccessKeyEnvVar = "AZURE_STORAGE_ACCESS_KEY"
-	AzureStorageAccountNameEnvVar = "AZURE_STORAGE_ACCOUNT"
+	AzureStorageAccessKeyEnvVar     = "AZURE_STORAGE_ACCESS_KEY"
+	AzureStorageAccountNameEnvVar   = "AZURE_STORAGE_ACCOUNT"
 	AzureStorageContainerNameEnvVar = "AZURE_STORAGE_CONTAINER"
 	AzureStorageContainerNameEnvVar = "AZURE_STORAGE_CONTAINER"
 
 
 	KubecostNamespaceEnvVar        = "KUBECOST_NAMESPACE"
 	KubecostNamespaceEnvVar        = "KUBECOST_NAMESPACE"
@@ -61,8 +61,9 @@ const (
 
 
 	UTCOffsetEnvVar = "UTC_OFFSET"
 	UTCOffsetEnvVar = "UTC_OFFSET"
 
 
-	CacheWarmingEnabledEnvVar = "CACHE_WARMING_ENABLED"
-	ETLEnabledEnvVar          = "ETL_ENABLED"
+	CacheWarmingEnabledEnvVar    = "CACHE_WARMING_ENABLED"
+	ETLEnabledEnvVar             = "ETL_ENABLED"
+	LegacyExternalAPIDisabledVar = "LEGACY_EXTERNAL_API_DISABLED"
 )
 )
 
 
 // GetAWSAccessKeyID returns the environment variable value for AWSAccessKeyIDEnvVar which represents
 // GetAWSAccessKeyID returns the environment variable value for AWSAccessKeyIDEnvVar which represents
@@ -336,3 +337,7 @@ func IsCacheWarmingEnabled() bool {
 func IsETLEnabled() bool {
 func IsETLEnabled() bool {
 	return GetBool(ETLEnabledEnvVar, true)
 	return GetBool(ETLEnabledEnvVar, true)
 }
 }
+
+func LegacyExternalCostsAPIDisabled() bool {
+	return GetBool(LegacyExternalAPIDisabledVar, false)
+}