Add `http_headers` and `http_path_prefix` provider configuration options for HTTP proxy support
Added two new provider configuration options to support HTTP proxy scenarios where custom headers or URL path rewriting are required:
-
http_headers- A map of custom HTTP headers added to all API requests (marked as sensitive) -
http_path_prefix- A path prefix prepended to all API request URLs
Changes:
-
Core Implementation (
internal/providers/client/databricks_client.go):- Added
HTTPConfigstruct to hold custom headers and path prefix - Added
httpTransportWrapperimplementinghttp.RoundTripperthat injects headers and prepends path prefix - Modified
PrepareDatabricksClientto accept optional*HTTPConfigand configure HTTP transport
- Added
-
SDKv2 Provider (
internal/providers/sdkv2/sdkv2.go):- Added
http_headersschema field (TypeMap, optional, sensitive) - Added
http_path_prefixschema field (TypeString, optional) - Updated
ConfigureDatabricksClientto read and pass HTTP config
- Added
-
Plugin Framework Provider (
internal/providers/pluginfw/pluginfw.go):- Added
http_headersschema field (MapAttribute with StringType) - Added
http_path_prefixschema field (StringAttribute) - Updated
configureDatabricksClientto read and pass HTTP config
- Added
-
Unit Tests:
-
internal/providers/client/databricks_client_test.go: Tests forhttpTransportWrapperRoundTrip behavior -
internal/providers/sdkv2/sdkv2_test.go: Schema validation and configuration tests
-
Implementation Details:
- Uses Go SDK's
HTTPTransportfield to inject a customhttp.RoundTripper - Headers are set on each request via
req.Header.Set() - Path prefix is prepended to
req.URL.Path(trailing slashes are trimmed) - Both SDKv2 and Plugin Framework providers share the same underlying client configuration
-
http_headersis marked as sensitive to avoid logging credentials
Example Usage:
provider "databricks" {
host = "https://proxy.example.com"
token = "your-token"
http_headers = {
"X-Custom-Auth" = "auth-value"
}
http_path_prefix = "/proxy"
}
Tests
- [x]
make testruns locally (2615 tests pass) - [x] relevant change in
docs/folder - [x] unit tests for HTTP transport wrapper and schema
- [x] using Go SDK (
config.HTTPTransport) - [x] using TF Plugin Framework
- [x] has entry in
NEXT_CHANGELOG.mdfile
IMHO, it should be done in Go SDK and only then exposed to TF
IMHO, it should be done in Go SDK and only then exposed to TF
@alexott Fair point. I've raised a PR here: https://github.com/databricks/databricks-sdk-go/pull/1340
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:
Trigger: go/deco-tests-run/terraform
Inputs:
- PR number: 5232
- Commit SHA:
51b81181319d99e26edfc8ffb758f5aba38b4fd6
Checks will be approved automatically on success.