@@ -103,16 +103,24 @@ func LoadConfigFromEnv(config *ClientConfig) (*ClientConfig, error) {
103
103
log .Printf ("ClientSecret env value found and set" )
104
104
105
105
// 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
+
106
109
config .Environment .InstanceName = getEnvOrDefault ("INSTANCE_NAME" , config .Environment .InstanceName )
107
110
log .Printf ("InstanceName env value found and set to: %s" , config .Environment .InstanceName )
108
111
109
112
config .Environment .OverrideBaseDomain = getEnvOrDefault ("OVERRIDE_BASE_DOMAIN" , config .Environment .OverrideBaseDomain )
110
113
log .Printf ("OverrideBaseDomain env value found and set to: %s" , config .Environment .OverrideBaseDomain )
111
114
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 )
114
120
115
121
// ClientOptions
122
+
123
+ // Logging
116
124
config .ClientOptions .Logging .LogLevel = getEnvOrDefault ("LOG_LEVEL" , config .ClientOptions .Logging .LogLevel )
117
125
log .Printf ("LogLevel env value found and set to: %s" , config .ClientOptions .Logging .LogLevel )
118
126
@@ -128,15 +136,29 @@ func LoadConfigFromEnv(config *ClientConfig) (*ClientConfig, error) {
128
136
config .ClientOptions .Logging .HideSensitiveData = parseBool (getEnvOrDefault ("HIDE_SENSITIVE_DATA" , strconv .FormatBool (config .ClientOptions .Logging .HideSensitiveData )))
129
137
log .Printf ("HideSensitiveData env value found and set to: %t" , config .ClientOptions .Logging .HideSensitiveData )
130
138
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
131
151
config .ClientOptions .Retry .MaxRetryAttempts = parseInt (getEnvOrDefault ("MAX_RETRY_ATTEMPTS" , strconv .Itoa (config .ClientOptions .Retry .MaxRetryAttempts )), DefaultMaxRetryAttempts )
132
152
log .Printf ("MaxRetryAttempts env value found and set to: %d" , config .ClientOptions .Retry .MaxRetryAttempts )
133
153
134
154
config .ClientOptions .Retry .EnableDynamicRateLimiting = parseBool (getEnvOrDefault ("ENABLE_DYNAMIC_RATE_LIMITING" , strconv .FormatBool (config .ClientOptions .Retry .EnableDynamicRateLimiting )))
135
155
log .Printf ("EnableDynamicRateLimiting env value found and set to: %t" , config .ClientOptions .Retry .EnableDynamicRateLimiting )
136
156
157
+ // Concurrency
137
158
config .ClientOptions .Concurrency .MaxConcurrentRequests = parseInt (getEnvOrDefault ("MAX_CONCURRENT_REQUESTS" , strconv .Itoa (config .ClientOptions .Concurrency .MaxConcurrentRequests )), DefaultMaxConcurrentRequests )
138
159
log .Printf ("MaxConcurrentRequests env value found and set to: %d" , config .ClientOptions .Concurrency .MaxConcurrentRequests )
139
160
161
+ // timeouts
140
162
config .ClientOptions .Timeout .TokenRefreshBufferPeriod = parseDuration (getEnvOrDefault ("TOKEN_REFRESH_BUFFER_PERIOD" , config .ClientOptions .Timeout .TokenRefreshBufferPeriod .String ()), DefaultTokenBufferPeriod )
141
163
log .Printf ("TokenRefreshBufferPeriod env value found and set to: %s" , config .ClientOptions .Timeout .TokenRefreshBufferPeriod )
142
164
@@ -328,3 +350,18 @@ func setLoggerDefaultValues(config *ClientConfig) {
328
350
// Log completion of setting default values
329
351
log .Println ("Default values set for logger configuration" )
330
352
}
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