Skip to content

Commit

Permalink
Modify and Merge env config logic of retrieving UA appID
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianyi Wang committed Oct 13, 2023
1 parent 14bd3fc commit fcbf63c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions config/env_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const (

awsRetryMaxAttempts = "AWS_MAX_ATTEMPTS"
awsRetryMode = "AWS_RETRY_MODE"
awsSdkAppID = "AWS_SDK_UA_APP_ID"
)

var (
Expand Down Expand Up @@ -248,6 +249,9 @@ type EnvConfig struct {
//
// aws_retry_mode=standard
RetryMode aws.RetryMode

// aws sdk app ID that can be added to user agent header string
AppID string
}

// loadEnvConfig reads configuration values from the OS's environment variables.
Expand Down Expand Up @@ -288,6 +292,8 @@ func NewEnvConfig() (EnvConfig, error) {
cfg.RoleARN = os.Getenv(awsRoleARNEnvVar)
cfg.RoleSessionName = os.Getenv(awsRoleSessionNameEnvVar)

cfg.AppID = os.Getenv(awsSdkAppID)

if err := setEndpointDiscoveryTypeFromEnvVal(&cfg.EnableEndpointDiscovery, []string{awsEnableEndpointDiscoveryEnvVar}); err != nil {
return cfg, err
}
Expand Down Expand Up @@ -336,8 +342,7 @@ func (c EnvConfig) getDefaultsMode(ctx context.Context) (aws.DefaultsMode, bool,
}

func (c EnvConfig) getAppID(context.Context) (string, bool, error) {
appID := os.Getenv(`AWS_SDK_UA_APP_ID`)
return appID, len(appID) > 0, nil
return c.AppID, len(c.AppID) > 0, nil
}

// GetRetryMaxAttempts returns the value of AWS_MAX_ATTEMPTS if was specified,
Expand Down

0 comments on commit fcbf63c

Please sign in to comment.