Bläddra i källkod

Cleanup code which sanitized hardcoded value "AKIXXX" (#3515)

Signed-off-by: thomasvn <thomasvn.dev@gmail.com>
Thomas Nguyen 4 månader sedan
förälder
incheckning
625baa6df8

+ 0 - 18
pkg/cloud/aws/provider.go

@@ -542,12 +542,6 @@ func (aws *AWS) UpdateConfig(r io.Reader, updateType string) (*models.CustomPric
 				return err
 			}
 
-			// If the sample nil service key name is set, zero it out so that it is not
-			// misinterpreted as a real service key.
-			if asfi.ServiceKeyName == "AKIXXX" {
-				asfi.ServiceKeyName = ""
-			}
-
 			c.ServiceKeyName = asfi.ServiceKeyName
 			if asfi.ServiceKeySecret != "" {
 				c.ServiceKeySecret = asfi.ServiceKeySecret
@@ -566,12 +560,6 @@ func (aws *AWS) UpdateConfig(r io.Reader, updateType string) (*models.CustomPric
 				return err
 			}
 
-			// If the sample nil service key name is set, zero it out so that it is not
-			// misinterpreted as a real service key.
-			if aai.ServiceKeyName == "AKIXXX" {
-				aai.ServiceKeyName = ""
-			}
-
 			c.AthenaBucketName = aai.AthenaBucketName
 			c.AthenaRegion = aai.AthenaRegion
 			c.AthenaDatabase = aai.AthenaDatabase
@@ -1715,12 +1703,6 @@ func (aws *AWS) loadAWSAuthSecret(force bool) (*AWSAccessKey, error) {
 		return nil, err
 	}
 
-	// If the sample nil service key name is set, zero it out so that it is not
-	// misinterpreted as a real service key.
-	if ak.AccessKeyID == "AKIXXX" {
-		ak.AccessKeyID = ""
-	}
-
 	awsSecret = &ak
 	return awsSecret, nil
 }

+ 0 - 6
pkg/cloud/config/watcher.go

@@ -207,12 +207,6 @@ func (cfw *ConfigFileWatcher) GetConfigs() []cloud.KeyedConfig {
 			aai.AccountID = customPricing.ProjectID
 		}
 
-		// If the sample nil service key name is set, zero it out so that it is not
-		// misinterpreted as a real service key.
-		if aai.ServiceKeyName == "AKIXXX" {
-			aai.ServiceKeyName = ""
-		}
-
 		kc := aws.ConvertAwsAthenaInfoToConfig(aai)
 		configs = append(configs, kc)
 		return configs

+ 0 - 7
pkg/cloud/provider/provider.go

@@ -123,13 +123,6 @@ func NewProvider(cache clustercache.ClusterCache, apiKey string, config *config.
 		cp.accountID = providerConfig.customPricing.ClusterAccountID
 	}
 
-	providerConfig.Update(func(cp *models.CustomPricing) error {
-		if cp.ServiceKeyName == "AKIXXX" {
-			cp.ServiceKeyName = ""
-		}
-		return nil
-	})
-
 	switch cp.provider {
 	case opencost.CSVProvider:
 		log.Infof("Using CSV Provider with CSV at %s", env.GetCSVPath())

+ 0 - 12
pkg/cloud/provider/providerconfig.go

@@ -73,12 +73,6 @@ func (pc *ProviderConfig) onConfigFileUpdated(changeType config.ChangeType, data
 		if pc.customPricing.SpotGPU == "" {
 			pc.customPricing.SpotGPU = DefaultPricing().SpotGPU // Migration for users without this value set by default.
 		}
-
-		// If the sample nil service key name is set, zero it out so that it is not
-		// misinterpreted as a real service key.
-		if pc.customPricing.ServiceKeyName == "AKIXXX" {
-			pc.customPricing.ServiceKeyName = ""
-		}
 	}
 }
 
@@ -147,12 +141,6 @@ func (pc *ProviderConfig) loadConfig(writeIfNotExists bool) (*models.CustomPrici
 		pc.customPricing.SpotGPU = DefaultPricing().SpotGPU // Migration for users without this value set by default.
 	}
 
-	// If the sample nil service key name is set, zero it out so that it is not
-	// misinterpreted as a real service key.
-	if pc.customPricing.ServiceKeyName == "AKIXXX" {
-		pc.customPricing.ServiceKeyName = ""
-	}
-
 	return pc.customPricing, nil
 }
 

+ 1 - 7
pkg/env/costmodel.go

@@ -164,13 +164,7 @@ func IsEmitDeprecatedMetrics() bool {
 // GetAWSAccessKeyID returns the environment variable value for AWSAccessKeyIDEnvVar which represents
 // the AWS access key for authentication
 func GetAWSAccessKeyID() string {
-	awsAccessKeyID := env.Get(AWSAccessKeyIDEnvVar, "")
-	// If the sample nil service key name is set, zero it out so that it is not
-	// misinterpreted as a real service key.
-	if awsAccessKeyID == "AKIXXX" {
-		awsAccessKeyID = ""
-	}
-	return awsAccessKeyID
+	return env.Get(AWSAccessKeyIDEnvVar, "")
 }
 
 // GetAWSAccessKeySecret returns the environment variable value for AWSAccessKeySecretEnvVar which represents