[Feature] Add support for custom HTTP headers and URL path prefix #1340
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes are proposed in this pull request?
Add two new configuration options to enable the SDK to work with HTTP proxies:
map[string]string): Custom headers added to all API requestsstring): Path prefix prepended to all API URLsThese options can be configured via:
DATABRICKS_HTTP_HEADERS(format:key1=value1;key2=value2) andDATABRICKS_HTTP_PATH_PREFIXhttp_headersandhttp_path_prefixFiles changed:
config/config.go: Added new config fields with struct tagsconfig/config_attribute.go: Added support for parsingmap[string]stringfrom environment variablesconfig/api_client.go: Added request visitors for applying headers and path prefixHow is this tested?
Existing CI.
Also added unit tests in
config/config_test.go:TestConfig_HTTPHeaders: Verifies headers are applied to requestsTestConfig_HTTPPathPrefix: Verifies path prefix is prependedTestConfig_HTTPHeadersAndPathPrefix: Verifies both work togetherTestConfig_HTTPHeadersFromEnvVar: Verifies env var parsing for headersTestConfig_HTTPPathPrefixFromEnvVar: Verifies env var parsing for path prefixTestParseMapFromString: Verifies map parsing edge cases