Skip to content

Commit 6522d18

Browse files
authored
Improve databricks_git_credential resource by correctly handle new fields (#4854)
## Changes <!-- Summary of your changes that are easy to understand --> SDK 0.75.0 brought two new optional fields, so documented them and correctly handle zero-values. Also, refactored unit tests to use Mock framework instead of HTTP fixtures ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [x] `make test` run locally - [x] relevant change in `docs/` folder - [x] covered with integration tests in `internal/acceptance` - [x] using Go SDK - [ ] using TF Plugin Framework - [x] has entry in `NEXT_CHANGELOG.md` file
1 parent fbb4a87 commit 6522d18

File tree

4 files changed

+180
-221
lines changed

4 files changed

+180
-221
lines changed

NEXT_CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
* Document new fields in `databricks_model_serving` and deprecate `invalid_keywords` and `valid_topics` in AI Gateway configuration ([#4851](https://github.com/databricks/terraform-provider-databricks/pull/4851)).
1414
* Added support for Alert V2 in `databricks_permissions` ([#4831](https://github.com/databricks/terraform-provider-databricks/pull/4831)).
1515
* Replace instead of dropping Delta `databricks_sql_table` ([#2424](https://github.com/databricks/terraform-provider-databricks/pull/2424)).
16-
* Added `clean_rooms_clean_room` resource and data sources ([#4844](https://github.com/databricks/terraform-provider-databricks/pull/4844)).
17-
* Added `external_metadata` resource and data sources ([#4844](https://github.com/databricks/terraform-provider-databricks/pull/4844)).
18-
* Added `materialized_features_feature_tag` resource and data sources ([#4844](https://github.com/databricks/terraform-provider-databricks/pull/4844)).
16+
* Added `databricks_clean_rooms_clean_room` resource and data sources ([#4844](https://github.com/databricks/terraform-provider-databricks/pull/4844)).
17+
* Added `databricks_external_metadata` resource and data sources ([#4844](https://github.com/databricks/terraform-provider-databricks/pull/4844)).
18+
* Added `databricks_materialized_features_feature_tag` resource and data sources ([#4844](https://github.com/databricks/terraform-provider-databricks/pull/4844)).
19+
* Improve `databricks_git_credential` resource by correctly handle new fields ([#4854](https://github.com/databricks/terraform-provider-databricks/pull/4854)).
1920

2021
### Bug Fixes
2122

docs/resources/git_credential.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ The following arguments are supported:
3838
* `personal_access_token` - (Optional, required for some Git providers) The personal access token used to authenticate to the corresponding Git provider. If value is not provided, it's sourced from the first environment variable of [`GITHUB_TOKEN`](https://registry.terraform.io/providers/integrations/github/latest/docs#oauth--personal-access-token), [`GITLAB_TOKEN`](https://registry.terraform.io/providers/gitlabhq/gitlab/latest/docs#required), or [`AZDO_PERSONAL_ACCESS_TOKEN`](https://registry.terraform.io/providers/microsoft/azuredevops/latest/docs#argument-reference), that has a non-empty value.
3939
* `git_username` - (Optional, required for some Git providers) user name at Git provider.
4040
* `git_provider` - (Required) case insensitive name of the Git provider. Following values are supported right now (could be a subject for a change, consult [Git Credentials API documentation](https://docs.databricks.com/dev-tools/api/latest/gitcredentials.html)): `gitHub`, `gitHubEnterprise`, `bitbucketCloud`, `bitbucketServer`, `azureDevOpsServices`, `gitLab`, `gitLabEnterpriseEdition`, `awsCodeCommit`, `azureDevOpsServicesAad`.
41+
* `is_default_for_provider` - (Optional) boolean flag specifying if the credential is the default for the given provider type.
42+
* `name` - (Optional) the name of the git credential, used for identification and ease of lookup.
4143
* `force` - (Optional) specify if settings need to be enforced.
4244

4345
## Attribute Reference

repos/resource_git_credential.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ func ResourceGitCredential() common.Resource {
9292
if err != nil {
9393
return err
9494
}
95+
if d.HasChange("is_default_for_provider") {
96+
req.ForceSendFields = append(req.ForceSendFields, "IsDefaultForProvider")
97+
}
98+
if d.HasChange("name") {
99+
req.ForceSendFields = append(req.ForceSendFields, "Name")
100+
}
95101
return w.GitCredentials.Update(ctx, req)
96102
},
97103
Delete: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {

0 commit comments

Comments
 (0)