Skip to content

Commit 46df47d

Browse files
authored
Add skip_credentials_validation flag to provider (#554)
This change adds a new optional boolean flag `skip_credentials_validation` to the dbt Cloud provider, similar to the AWS provider implementation. When set to true, the provider will skip the API call that validates credentials during initialization. This is useful for: - Testing scenarios where credential validation is not needed - Custom dbt Cloud API implementations without standard authentication - Environments where the validation endpoint may not be available The flag defaults to false to maintain backward compatibility. Changes: - Added skip_credentials_validation to provider schema - Added SkipCredentialsValidation to provider model - Updated Configure method to pass flag to client - Modified NewClient signature to accept skipCredentialsValidation parameter - Updated validation logic to respect the skip flag - Updated provider documentation
1 parent 55525cf commit 46df47d

4 files changed

Lines changed: 21 additions & 10 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Changes
2+
body: Added skip_credentials_validation flag to provider for skipping credential validation during initialization
3+
time: 2025-11-11T17:17:04.65679+02:00

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ provider "dbtcloud" {
4343
- `max_retries` (Number) The maximum number of retries to attempt for requests that fail due to rate limiting. Defaults to 3 retries.
4444
- `retriable_status_codes` (List of String) List of HTTP status codes that should be retried when encountered. Defaults to [429, 500, 502, 503, 504].
4545
- `retry_interval_seconds` (Number) The number of seconds to wait before retrying a request that failed due to rate limiting. Defaults to 10 seconds.
46+
- `skip_credentials_validation` (Boolean) If set to true, the provider will not validate credentials during initialization. This can be useful for testing and for dbt Cloud API implementations that do not have standard authentication available. Defaults to false.
4647
- `token` (String, Sensitive) API token for your dbt Cloud. Instead of setting the parameter, you can set the environment variable `DBT_CLOUD_TOKEN`

pkg/dbt_cloud/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ type APIError struct {
115115
}
116116

117117
// NewClient -
118-
func NewClient(account_id *int, token *string, host_url *string, maxRetries *int, retryIntervalSeconds *int, retriableStatusCodes []string) (*Client, error) {
118+
func NewClient(account_id *int, token *string, host_url *string, maxRetries *int, retryIntervalSeconds *int, retriableStatusCodes []string, skipCredentialsValidation bool) (*Client, error) {
119119

120120
if (token == nil) || (*token == "") {
121121
return nil, fmt.Errorf("token is set but it is empty")
@@ -138,7 +138,7 @@ func NewClient(account_id *int, token *string, host_url *string, maxRetries *int
138138
}
139139

140140
_, runningAcceptanceTests := os.LookupEnv("TF_ACC")
141-
if !runningAcceptanceTests {
141+
if !runningAcceptanceTests && !skipCredentialsValidation {
142142
url := c.BuildV2URL(ResourceAccounts)
143143

144144
// authenticate

pkg/provider/framework_provider.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ func (p *dbtCloudProvider) Schema(
118118
Optional: true,
119119
Description: "If set to true, the provider will not retry requests that fail due to rate limiting. Defaults to false.",
120120
},
121+
"skip_credentials_validation": schema.BoolAttribute{
122+
Optional: true,
123+
Description: "If set to true, the provider will not validate credentials during initialization. This can be useful for testing and for dbt Cloud API implementations that do not have standard authentication available. Defaults to false.",
124+
},
121125
"retriable_status_codes": schema.ListAttribute{
122126
Optional: true,
123127
ElementType: types.StringType,
@@ -136,13 +140,14 @@ func (p *dbtCloudProvider) Schema(
136140
}
137141

138142
type dbtCloudProviderModel struct {
139-
Token types.String `tfsdk:"token"`
140-
AccountID types.Int64 `tfsdk:"account_id"`
141-
HostURL types.String `tfsdk:"host_url"`
142-
MaxRetries types.Int64 `tfsdk:"max_retries"`
143-
RetryIntervalSeconds types.Int64 `tfsdk:"retry_interval_seconds"`
144-
DisableRetry types.Bool `tfsdk:"disable_retry"`
145-
RetriableStatusCodes types.List `tfsdk:"retriable_status_codes"`
143+
Token types.String `tfsdk:"token"`
144+
AccountID types.Int64 `tfsdk:"account_id"`
145+
HostURL types.String `tfsdk:"host_url"`
146+
MaxRetries types.Int64 `tfsdk:"max_retries"`
147+
RetryIntervalSeconds types.Int64 `tfsdk:"retry_interval_seconds"`
148+
DisableRetry types.Bool `tfsdk:"disable_retry"`
149+
SkipCredentialsValidation types.Bool `tfsdk:"skip_credentials_validation"`
150+
RetriableStatusCodes types.List `tfsdk:"retriable_status_codes"`
146151
}
147152

148153
func (p *dbtCloudProvider) Configure(
@@ -259,7 +264,9 @@ func (p *dbtCloudProvider) Configure(
259264
}
260265
}
261266

262-
client, err := dbt_cloud.NewClient(&accountID, &token, &hostURL, &maxRetries, &retryIntervalSeconds, retriableStatusCodes)
267+
skipCredentialsValidation := config.SkipCredentialsValidation.ValueBool()
268+
269+
client, err := dbt_cloud.NewClient(&accountID, &token, &hostURL, &maxRetries, &retryIntervalSeconds, retriableStatusCodes, skipCredentialsValidation)
263270
if err != nil {
264271
resp.Diagnostics.AddError(
265272
"Unable to Create dbt Cloud API Client",

0 commit comments

Comments
 (0)