Skip to content

Commit 1f39f5e

Browse files
authored
Added databricks_git_credentials pat discovery from common environment variables (#1353)
1 parent cdcb3e5 commit 1f39f5e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

docs/resources/git_credential.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ resource "databricks_git_credential" "ado" {
2323

2424
The following arguments are supported:
2525

26-
* `personal_access_token` - (Required) The personal access token used to authenticate to the corresponding Git provider.
26+
* `personal_access_token` - (Required) 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.
2727
* `git_username` - (Required) user name at Git provider.
2828
* `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`.
2929
* `force` - (Optional) specify if settings need to be enforced - right now, Databricks allows only single Git credential, so if it's already configured, the apply operation will fail.

repos/resource_git_credential.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ func ResourceGitCredential() *schema.Resource {
7171
Type: schema.TypeBool,
7272
Optional: true,
7373
}
74+
s["personal_access_token"].DefaultFunc = schema.MultiEnvDefaultFunc([]string{
75+
"GITHUB_TOKEN", // https://registry.terraform.io/providers/integrations/github/latest/docs
76+
"GITLAB_TOKEN", // https://registry.terraform.io/providers/gitlabhq/gitlab/latest/docs
77+
"AZDO_PERSONAL_ACCESS_TOKEN", // https://registry.terraform.io/providers/microsoft/azuredevops/latest/docs
78+
}, nil)
7479
return s
7580
})
7681

0 commit comments

Comments
 (0)