fix(api): Correctly apply BOUNDARY_MAX_RETRIES env var (#5385)
The api.Client was first checking for the environment variable, and then resetting the max retries to 2, thus overriding the environment variable value. In addition, the cli would set max retries to zero if the environment variable was not set. This would mean that by default the max retries would be zero, and if the environment variable was set, the max retries would be 2, regardless of the actual value for the environment variable. This fixes the order in which the environment variables are read, to ensure they take precedence.
This commit is contained in:
1 parent
02fe1b42d3
commit
5329f926b6
4 files changed
+102
-6
No files matched your search
+5
-6
@@ -172,12 +172,6 @@ func DefaultConfig() (*Config, error) {
|
||||
TLSConfig: &TLSConfig{},
|
||||
}
|
||||
|
||||
// We read the environment now; after DefaultClient returns we can override
|
||||
// values from command line flags, which should take precedence.
|
||||
if err := config.ReadEnvironment(); err != nil {
|
||||
return config, fmt.Errorf("failed to read environment: %w", err)
|
||||
}
|
||||
|
||||
transport := config.HttpClient.Transport.(*http.Transport)
|
||||
transport.TLSHandshakeTimeout = 10 * time.Second
|
||||
transport.TLSClientConfig = &tls.Config{
|
||||
@@ -188,6 +182,11 @@ func DefaultConfig() (*Config, error) {
|
||||
config.MaxRetries = 2
|
||||
config.Headers = make(http.Header)
|
||||
|
||||
// Read from environment last to ensure it takes precedence.
|
||||
if err := config.ReadEnvironment(); err != nil {
|
||||
return config, fmt.Errorf("failed to read environment: %w", err)
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user