@@ -103,16 +103,24 @@ func LoadConfigFromEnv(config *ClientConfig) (*ClientConfig, error) {
103103 log .Printf ("ClientSecret env value found and set" )
104104
105105 // EnvironmentConfig
106+ config .Environment .APIType = getEnvOrDefault ("API_TYPE" , config .Environment .APIType )
107+ log .Printf ("APIType env value found and set to: %s" , config .Environment .APIType )
108+
106109 config .Environment .InstanceName = getEnvOrDefault ("INSTANCE_NAME" , config .Environment .InstanceName )
107110 log .Printf ("InstanceName env value found and set to: %s" , config .Environment .InstanceName )
108111
109112 config .Environment .OverrideBaseDomain = getEnvOrDefault ("OVERRIDE_BASE_DOMAIN" , config .Environment .OverrideBaseDomain )
110113 log .Printf ("OverrideBaseDomain env value found and set to: %s" , config .Environment .OverrideBaseDomain )
111114
112- config .Environment .APIType = getEnvOrDefault ("API_TYPE" , config .Environment .APIType )
113- log .Printf ("APIType env value found and set to: %s" , config .Environment .APIType )
115+ config .Environment .TenantID = getEnvOrDefault ("TENANT_ID" , config .Environment .TenantID )
116+ log .Printf ("TenantID env value found and set to: %s" , config .Environment .TenantID )
117+
118+ config .Environment .TenantName = getEnvOrDefault ("TENANT_NAME" , config .Environment .TenantName )
119+ log .Printf ("TenantName env value found and set to: %s" , config .Environment .TenantName )
114120
115121 // ClientOptions
122+
123+ // Logging
116124 config .ClientOptions .Logging .LogLevel = getEnvOrDefault ("LOG_LEVEL" , config .ClientOptions .Logging .LogLevel )
117125 log .Printf ("LogLevel env value found and set to: %s" , config .ClientOptions .Logging .LogLevel )
118126
@@ -128,15 +136,29 @@ func LoadConfigFromEnv(config *ClientConfig) (*ClientConfig, error) {
128136 config .ClientOptions .Logging .HideSensitiveData = parseBool (getEnvOrDefault ("HIDE_SENSITIVE_DATA" , strconv .FormatBool (config .ClientOptions .Logging .HideSensitiveData )))
129137 log .Printf ("HideSensitiveData env value found and set to: %t" , config .ClientOptions .Logging .HideSensitiveData )
130138
139+ // Cookies
140+ config .ClientOptions .Cookies .EnableCookieJar = parseBool (getEnvOrDefault ("ENABLE_COOKIE_JAR" , strconv .FormatBool (config .ClientOptions .Cookies .EnableCookieJar )))
141+ log .Printf ("EnableCookieJar env value found and set to: %t" , config .ClientOptions .Cookies .EnableCookieJar )
142+
143+ // Load specific cookies from environment variable
144+ cookieStr := getEnvOrDefault ("CUSTOM_COOKIES" , "" )
145+ if cookieStr != "" {
146+ config .ClientOptions .Cookies .CustomCookies = parseCookiesFromString (cookieStr )
147+ log .Printf ("CustomCookies env value found and set" )
148+ }
149+
150+ // Retry
131151 config .ClientOptions .Retry .MaxRetryAttempts = parseInt (getEnvOrDefault ("MAX_RETRY_ATTEMPTS" , strconv .Itoa (config .ClientOptions .Retry .MaxRetryAttempts )), DefaultMaxRetryAttempts )
132152 log .Printf ("MaxRetryAttempts env value found and set to: %d" , config .ClientOptions .Retry .MaxRetryAttempts )
133153
134154 config .ClientOptions .Retry .EnableDynamicRateLimiting = parseBool (getEnvOrDefault ("ENABLE_DYNAMIC_RATE_LIMITING" , strconv .FormatBool (config .ClientOptions .Retry .EnableDynamicRateLimiting )))
135155 log .Printf ("EnableDynamicRateLimiting env value found and set to: %t" , config .ClientOptions .Retry .EnableDynamicRateLimiting )
136156
157+ // Concurrency
137158 config .ClientOptions .Concurrency .MaxConcurrentRequests = parseInt (getEnvOrDefault ("MAX_CONCURRENT_REQUESTS" , strconv .Itoa (config .ClientOptions .Concurrency .MaxConcurrentRequests )), DefaultMaxConcurrentRequests )
138159 log .Printf ("MaxConcurrentRequests env value found and set to: %d" , config .ClientOptions .Concurrency .MaxConcurrentRequests )
139160
161+ // timeouts
140162 config .ClientOptions .Timeout .TokenRefreshBufferPeriod = parseDuration (getEnvOrDefault ("TOKEN_REFRESH_BUFFER_PERIOD" , config .ClientOptions .Timeout .TokenRefreshBufferPeriod .String ()), DefaultTokenBufferPeriod )
141163 log .Printf ("TokenRefreshBufferPeriod env value found and set to: %s" , config .ClientOptions .Timeout .TokenRefreshBufferPeriod )
142164
@@ -328,3 +350,18 @@ func setLoggerDefaultValues(config *ClientConfig) {
328350 // Log completion of setting default values
329351 log .Println ("Default values set for logger configuration" )
330352}
353+
354+ // parseCookiesFromString parses a semi-colon separated string of key=value pairs into a map.
355+ func parseCookiesFromString (cookieStr string ) map [string ]string {
356+ cookies := make (map [string ]string )
357+ pairs := strings .Split (cookieStr , ";" )
358+ for _ , pair := range pairs {
359+ kv := strings .SplitN (pair , "=" , 2 )
360+ if len (kv ) == 2 {
361+ key := strings .TrimSpace (kv [0 ])
362+ value := strings .TrimSpace (kv [1 ])
363+ cookies [key ] = value
364+ }
365+ }
366+ return cookies
367+ }
0 commit comments