From cdcb6813f238d172a7bd31f1f1acc2e2cde634bc Mon Sep 17 00:00:00 2001 From: Tianyi Wang Date: Fri, 13 Oct 2023 12:50:27 -0400 Subject: [PATCH] Optimize and Merge user agent appID resolving from env config --- config/env_config.go | 5 +++++ config/resolve.go | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/config/env_config.go b/config/env_config.go index 63ecd02b384..3d972a4bb7f 100644 --- a/config/env_config.go +++ b/config/env_config.go @@ -335,6 +335,11 @@ func (c EnvConfig) getDefaultsMode(ctx context.Context) (aws.DefaultsMode, bool, return c.DefaultsMode, true, nil } +func (c EnvConfig) getAppID(context.Context) (string, bool, error) { + appID := os.Getenv(`AWS_SDK_UA_APP_ID`) + return appID, len(appID) > 0, nil +} + // GetRetryMaxAttempts returns the value of AWS_MAX_ATTEMPTS if was specified, // and not 0. func (c EnvConfig) GetRetryMaxAttempts(ctx context.Context) (int, bool, error) { diff --git a/config/resolve.go b/config/resolve.go index b037053503d..1187e8c4803 100644 --- a/config/resolve.go +++ b/config/resolve.go @@ -113,10 +113,6 @@ func resolveAppID(ctx context.Context, cfg *aws.Config, configs configs) error { return err } - // if app ID is set in env var, it should precedence shared config value - if appID := os.Getenv(`AWS_SDK_UA_APP_ID`); len(appID) > 0 { - ID = appID - } cfg.AppID = ID return nil }