Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bitbucket Data Center support #1303

Merged
merged 12 commits into from
May 15, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
ENHANCEMENTS:
* Rebrand Terraform Cloud to HCP Terraform by @sebasslash [#1328](https://github.com/hashicorp/terraform-provider-tfe/pull/1328)
* Adds `post_apply` to list of possible `stages` for Run Tasks by @carolinaborim [#1307](https://github.com/hashicorp/terraform-provider-tfe/pull/1307)
* `r/tfe_oauth_client`: Add Bitbucket Data Center support with the `bitbucket_data_center` option for `service_provider` by @zainq11 [#1303](https://github.com/hashicorp/terraform-provider-tfe/pull/1304)
zainq11 marked this conversation as resolved.
Show resolved Hide resolved

FEATURES:
* `d/tfe_oauth_client`: Add `project_ids` attribute, by @Netra2104 [1148](https://github.com/hashicorp/terraform-provider-tfe/pull/1148)
Expand Down
1 change: 1 addition & 0 deletions internal/provider/data_source_oauth_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func dataSourceTFEOAuthClient() *schema.Resource {
string(tfe.ServiceProviderAzureDevOpsServer),
string(tfe.ServiceProviderAzureDevOpsServices),
string(tfe.ServiceProviderBitbucket),
string(tfe.ServiceProviderBitbucketDataCenter),
string(tfe.ServiceProviderBitbucketServer),
string(tfe.ServiceProviderBitbucketServerLegacy),
string(tfe.ServiceProviderGithub),
Expand Down
5 changes: 3 additions & 2 deletions internal/provider/resource_tfe_oauth_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func resourceTFEOAuthClient() *schema.Resource {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
// this field is only for BitBucket Server, and requires these other
// this field is only for BitBucket Data Center, and requires these other
RequiredWith: []string{"secret", "key"},
},

Expand All @@ -98,6 +98,7 @@ func resourceTFEOAuthClient() *schema.Resource {
string(tfe.ServiceProviderAzureDevOpsServices),
string(tfe.ServiceProviderBitbucket),
string(tfe.ServiceProviderBitbucketServer),
string(tfe.ServiceProviderBitbucketDataCenter),
string(tfe.ServiceProviderGithub),
string(tfe.ServiceProviderGithubEE),
string(tfe.ServiceProviderGitlab),
Expand Down Expand Up @@ -157,7 +158,7 @@ func resourceTFEOAuthClientCreate(d *schema.ResourceData, meta interface{}) erro
if serviceProvider == tfe.ServiceProviderAzureDevOpsServer {
options.PrivateKey = tfe.String(privateKey)
}
if serviceProvider == tfe.ServiceProviderBitbucketServer {
if serviceProvider == tfe.ServiceProviderBitbucketServer || serviceProvider == tfe.ServiceProviderBitbucketDataCenter {
zainq11 marked this conversation as resolved.
Show resolved Hide resolved
options.RSAPublicKey = tfe.String(rsaPublicKey)
options.Secret = tfe.String(secret)
}
Expand Down
12 changes: 6 additions & 6 deletions internal/provider/resource_tfe_oauth_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ func TestAccTFEOAuthClient_rsaKeys(t *testing.T) {
testAccCheckTFEOAuthClientExists("tfe_oauth_client.foobar", oc),
testAccCheckTFEOAuthClientAttributes(oc),
resource.TestCheckResourceAttr(
"tfe_oauth_client.foobar", "api_url", "https://bbs.example.com"),
"tfe_oauth_client.foobar", "api_url", "https://bbdc.example.com"),
resource.TestCheckResourceAttr(
"tfe_oauth_client.foobar", "http_url", "https://bbs.example.com"),
"tfe_oauth_client.foobar", "http_url", "https://bbdc.example.com"),
resource.TestCheckResourceAttr(
"tfe_oauth_client.foobar", "service_provider", "bitbucket_server"),
"tfe_oauth_client.foobar", "service_provider", "bitbucket_data_center"),
resource.TestCheckResourceAttr(
"tfe_oauth_client.foobar", "key", "1e4843e138b0d44911a50d15e0f7cee4"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -200,9 +200,9 @@ resource "tfe_organization" "foobar" {
resource "tfe_oauth_client" "foobar" {
organization = tfe_organization.foobar.id
name = "foobar_oauth"
api_url = "https://bbs.example.com"
http_url = "https://bbs.example.com"
service_provider = "bitbucket_server"
api_url = "https://bbdc.example.com"
http_url = "https://bbdc.example.com"
service_provider = "bitbucket_data_center"
key = "1e4843e138b0d44911a50d15e0f7cee4"
secret = <<EOT
-----BEGIN RSA PRIVATE KEY-----
Expand Down
2 changes: 1 addition & 1 deletion website/docs/cdktf/csharp/d/oauth_client.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ be set.
* `OauthClientId` - (Optional) ID of the OAuth client.
* `Organization` - (Optional) The name of the organization in which to search.
* `ServiceProvider` - (Optional) The API identifier of the OAuth service provider. If set,
must be one of: `AdoServer`, `AdoServices`, `BitbucketHosted`, `BitbucketServer`,
must be one of: `AdoServer`, `AdoServices`,`BitbucketDataCenter`, `BitbucketHosted`, `BitbucketServer`(deprecated),
`Github`, `GithubEnterprise`, `GitlabHosted`, `GitlabCommunityEdition`, or
`GitlabEnterpriseEdition`.

Expand Down
28 changes: 14 additions & 14 deletions website/docs/cdktf/csharp/r/oauth_client.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ class MyConvertedCode : TerraformStack
}
```

#### BitBucket Server Usage
#### BitBucket Data Center Usage

See [documentation for HCP Terraform and Terraform Enterprise setup](https://developer.hashicorp.com/terraform/cloud-docs/vcs/bitbucket-server).
See [documentation for HCP Terraform and Terraform Enterprise setup](https://developer.hashicorp.com/terraform/cloud-docs/vcs/bitbucket-data-center).

When using BitBucket Server, you must use three required fields: `Key`, `Secret`, `RsaPublicKey`.
When using BitBucket Data Center, you must use three required fields: `Key`, `Secret`, `RsaPublicKey`.


```csharp
Expand All @@ -88,10 +88,10 @@ class MyConvertedCode : TerraformStack
public MyConvertedCode(Construct scope, string name) : base(scope, name)
{
new OauthClient.OauthClient(this, "test", new OauthClientConfig {
ApiUrl = "https://bbs.example.com",
HttpUrl = "https://bss.example.com",
ApiUrl = "https://bbdc.example.com",
HttpUrl = "https://bbdc.example.com",
Key = "<consumer key>",
Name = "my-bbs-oauth-client",
Name = "my-bbdc-oauth-client",
Organization = "my-org-name",
RsaPublicKey = @"-----BEGIN PUBLIC KEY-----
content
Expand All @@ -101,7 +101,7 @@ class MyConvertedCode : TerraformStack
content
-----END RSA PRIVATE KEY-----
",
ServiceProvider = "bitbucket_server"
ServiceProvider = "bitbucket_data_center"
});
}
}
Expand All @@ -121,20 +121,20 @@ The following arguments are supported:
* `PrivateKey` - (Required for `AdoServer`) The text of the private key associated with your Azure DevOps Server account
* `Key` - The OAuth Client key can refer to a Consumer Key, Application Key,
or another type of client key for the VCS provider.
* `Secret` - (Required for `BitbucketServer`) The OAuth Client secret is used for BitBucket Server, this secret is the
the text of the SSH private key associated with your BitBucket Server
* `Secret` - (Required for `BitbucketDataCenter`) The OAuth Client secret is used for BitBucket Data Center, this secret is the
the text of the SSH private key associated with your BitBucket Data Center
Application Link.
* `RsaPublicKey` - (Required for `BitbucketServer`) Required for BitBucket
Server in conjunction with the secret. Not used for any other providers. The
text of the SSH public key associated with your BitBucket Server Application
* `RsaPublicKey` - (Required for `BitbucketDataCenter`) Required for BitBucket
Data Center in conjunction with the secret. Not used for any other providers. The
text of the SSH public key associated with your BitBucket Data Center Application
Link.
* `ServiceProvider` - (Required) The VCS provider being connected with. Valid
options are `AdoServer`, `AdoServices`, `BitbucketHosted`, `BitbucketServer`, `Github`, `GithubEnterprise`, `GitlabHosted`,
options are `AdoServer`, `AdoServices`, `BitbucketHosted`, `BitbucketDataCenter`, `BitbucketServer`(deprecated), `Github`, `GithubEnterprise`, `GitlabHosted`,
`GitlabCommunityEdition`, or `GitlabEnterpriseEdition`.

## Attributes Reference

* `Id` - The ID of the OAuth client.
* `OauthTokenId` - The ID of the OAuth token associated with the OAuth client.

<!-- cache-key: cdktf-0.17.0-pre.15 input-0dea494ef76c038939d94b5ae6a0e741e36a87509a350f558cd11d098bf1bde9 -->
<!-- cache-key: cdktf-0.17.0-pre.15 input-0dea494ef76c038939d94b5ae6a0e741e36a87509a350f558cd11d098bf1bde9 -->
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ The `VcsRepo` block supports:
For most VCS providers outside of BitBucket Cloud and Azure DevOps, this will match the `Identifier`
string.
* `Identifier` - (Required) A reference to your VCS repository in the format
`<organization>/<repository>` where `<organization>` and `<repository>` refer to the organization (or project key, for Bitbucket Server)
`<organization>/<repository>` where `<organization>` and `<repository>` refer to the organization (or project key, for Bitbucket Data Center)
and repository in your VCS provider. The format for Azure DevOps is `<ado organization>/<ado project>/_git/<ado repository>`.
* `OauthTokenId` - (Optional) Token ID of the VCS Connection (OAuth Connection Token) to use. This conflicts with `GithubAppInstallationId` and can only be used if `GithubAppInstallationId` is not used.
* `GithubAppInstallationId` - (Optional) The installation id of the Github App. This conflicts with `OauthTokenId` and can only be used if `OauthTokenId` is not used.
Expand Down
4 changes: 2 additions & 2 deletions website/docs/cdktf/go/d/oauth_client.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ be set.
* `OauthClientId` - (Optional) ID of the OAuth client.
* `Organization` - (Optional) The name of the organization in which to search.
* `ServiceProvider` - (Optional) The API identifier of the OAuth service provider. If set,
must be one of: `AdoServer`, `AdoServices`, `BitbucketHosted`, `BitbucketServer`,
must be one of: `AdoServer`, `AdoServices`, `BitbucketDataCenter`, `BitbucketHosted`, `BitbucketServer`(deprecated),
`Github`, `GithubEnterprise`, `GitlabHosted`, `GitlabCommunityEdition`, or
`GitlabEnterpriseEdition`.

Expand All @@ -109,4 +109,4 @@ In addition to all arguments above, the following attributes are exported:
* `ServiceProvider` - The API identifier of the OAuth service provider.
* `ServiceProviderDisplayName` - The display name of the OAuth service provider.

<!-- cache-key: cdktf-0.17.0-pre.15 input-59b4bcbbb310e7ee913a245f3c751829442542dbcf1bbb4c87ac286043b69348 -->
<!-- cache-key: cdktf-0.17.0-pre.15 input-59b4bcbbb310e7ee913a245f3c751829442542dbcf1bbb4c87ac286043b69348 -->
28 changes: 14 additions & 14 deletions website/docs/cdktf/go/r/oauth_client.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ func newMyConvertedCode(scope construct, name *string) *myConvertedCode {
}
```

#### BitBucket Server Usage
#### BitBucket Data Center Usage

See [documentation for HCP Terraform and Terraform Enterprise setup](https://developer.hashicorp.com/terraform/cloud-docs/vcs/bitbucket-server).
See [documentation for HCP Terraform and Terraform Enterprise setup](https://developer.hashicorp.com/terraform/cloud-docs/vcs/bitbucket-data-center).

When using BitBucket Server, you must use three required fields: `Key`, `Secret`, `RsaPublicKey`.
When using BitBucket Data Center, you must use three required fields: `Key`, `Secret`, `RsaPublicKey`.


```go
Expand All @@ -94,14 +94,14 @@ func newMyConvertedCode(scope construct, name *string) *myConvertedCode {
this := &myConvertedCode{}
cdktf.NewTerraformStack_Override(this, scope, name)
oauthClient.NewOauthClient(this, jsii.String("test"), &oauthClientConfig{
apiUrl: jsii.String("https://bbs.example.com"),
httpUrl: jsii.String("https://bss.example.com"),
apiUrl: jsii.String("https://bbdc.example.com"),
httpUrl: jsii.String("https://bbdc.example.com"),
key: jsii.String("<consumer key>"),
name: jsii.String("my-bbs-oauth-client"),
name: jsii.String("my-bbdc-oauth-client"),
organization: jsii.String("my-org-name"),
rsaPublicKey: jsii.String("-----BEGIN PUBLIC KEY-----\ncontent\n-----END PUBLIC KEY-----\n"),
secret: jsii.String("-----BEGIN RSA PRIVATE KEY-----\ncontent\n-----END RSA PRIVATE KEY-----\n"),
serviceProvider: jsii.String("bitbucket_server"),
serviceProvider: jsii.String("bitbucket_data_center"),
})
return this
}
Expand All @@ -121,20 +121,20 @@ The following arguments are supported:
* `PrivateKey` - (Required for `AdoServer`) The text of the private key associated with your Azure DevOps Server account
* `Key` - The OAuth Client key can refer to a Consumer Key, Application Key,
or another type of client key for the VCS provider.
* `Secret` - (Required for `BitbucketServer`) The OAuth Client secret is used for BitBucket Server, this secret is the
the text of the SSH private key associated with your BitBucket Server
* `Secret` - (Required for `BitbucketDataCenter`) The OAuth Client secret is used for Bitbucket Data Center, this secret is the
the text of the SSH private key associated with your Bitbucket Data Center
Application Link.
* `RsaPublicKey` - (Required for `BitbucketServer`) Required for BitBucket
Server in conjunction with the secret. Not used for any other providers. The
text of the SSH public key associated with your BitBucket Server Application
* `RsaPublicKey` - (Required for `BitbucketDataCenter`) Required for Bitbucket Data Center
in conjunction with the secret. Not used for any other providers. The
text of the SSH public key associated with your Bitbucket Data Center Application
Link.
* `ServiceProvider` - (Required) The VCS provider being connected with. Valid
options are `AdoServer`, `AdoServices`, `BitbucketHosted`, `BitbucketServer`, `Github`, `GithubEnterprise`, `GitlabHosted`,
options are `AdoServer`, `AdoServices`, `BitbucketDataCenter`, `BitbucketHosted`, `BitbucketServer`(deprecated), `Github`, `GithubEnterprise`, `GitlabHosted`,
`GitlabCommunityEdition`, or `GitlabEnterpriseEdition`.

## Attributes Reference

* `Id` - The ID of the OAuth client.
* `OauthTokenId` - The ID of the OAuth token associated with the OAuth client.

<!-- cache-key: cdktf-0.17.0-pre.15 input-0dea494ef76c038939d94b5ae6a0e741e36a87509a350f558cd11d098bf1bde9 -->
<!-- cache-key: cdktf-0.17.0-pre.15 input-0dea494ef76c038939d94b5ae6a0e741e36a87509a350f558cd11d098bf1bde9 -->
2 changes: 1 addition & 1 deletion website/docs/cdktf/go/r/registry_module.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ The `VcsRepo` block supports:
For most VCS providers outside of BitBucket Cloud and Azure DevOps, this will match the `Identifier`
string.
* `Identifier` - (Required) A reference to your VCS repository in the format
`<organization>/<repository>` where `<organization>` and `<repository>` refer to the organization (or project key, for Bitbucket Server)
`<organization>/<repository>` where `<organization>` and `<repository>` refer to the organization (or project key, for Bitbucket Data Center)
and repository in your VCS provider. The format for Azure DevOps is `<ado organization>/<ado project>/_git/<ado repository>`.
* `OauthTokenId` - (Optional) Token ID of the VCS Connection (OAuth Connection Token) to use. This conflicts with `GithubAppInstallationId` and can only be used if `GithubAppInstallationId` is not used.
* `GithubAppInstallationId` - (Optional) The installation id of the Github App. This conflicts with `OauthTokenId` and can only be used if `OauthTokenId` is not used.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/cdktf/java/d/oauth_client.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ be set.
* `oauthClientId` - (Optional) ID of the OAuth client.
* `organization` - (Optional) The name of the organization in which to search.
* `serviceProvider` - (Optional) The API identifier of the OAuth service provider. If set,
must be one of: `adoServer`, `adoServices`, `bitbucketHosted`, `bitbucketServer`,
must be one of: `adoServer`, `adoServices`, `bitbucketDataCenter`, `bitbucketHosted`, `bitbucketServer`(deprecated),
`github`, `githubEnterprise`, `gitlabHosted`, `gitlabCommunityEdition`, or
`gitlabEnterpriseEdition`.

Expand Down
30 changes: 15 additions & 15 deletions website/docs/cdktf/java/r/oauth_client.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ public class MyConvertedCode extends TerraformStack {
}
```

#### BitBucket Server Usage
#### BitBucket Data Center Usage

See [documentation for HCP Terraform and Terraform Enterprise setup](https://developer.hashicorp.com/terraform/cloud-docs/vcs/bitbucket-server).
See [documentation for HCP Terraform and Terraform Enterprise setup](https://developer.hashicorp.com/terraform/cloud-docs/vcs/bitbucket-data-center).

When using BitBucket Server, you must use three required fields: `key`, `secret`, `rsaPublicKey`.
When using BitBucket Data Center, you must use three required fields: `key`, `secret`, `rsaPublicKey`.


```java
Expand All @@ -82,14 +82,14 @@ public class MyConvertedCode extends TerraformStack {
public MyConvertedCode(Construct scope, String name) {
super(scope, name);
new OauthClient(this, "test", new OauthClientConfig()
.apiUrl("https://bbs.example.com")
.httpUrl("https://bss.example.com")
.apiUrl("https://bbdc.example.com")
.httpUrl("https://bbdc.example.com")
.key("<consumer key>")
.name("my-bbs-oauth-client")
.name("my-bbdc-oauth-client")
.organization("my-org-name")
.rsaPublicKey("-----BEGIN PUBLIC KEY-----\ncontent\n-----END PUBLIC KEY-----\n")
.secret("-----BEGIN RSA PRIVATE KEY-----\ncontent\n-----END RSA PRIVATE KEY-----\n")
.serviceProvider("bitbucket_server")
.serviceProvider("bitbucket_data_center")
);
}
}
Expand All @@ -109,20 +109,20 @@ The following arguments are supported:
* `privateKey` - (Required for `adoServer`) The text of the private key associated with your Azure DevOps Server account
* `key` - The OAuth Client key can refer to a Consumer Key, Application Key,
or another type of client key for the VCS provider.
* `secret` - (Required for `bitbucketServer`) The OAuth Client secret is used for BitBucket Server, this secret is the
the text of the SSH private key associated with your BitBucket Server
Application Link.
* `rsaPublicKey` - (Required for `bitbucketServer`) Required for BitBucket
Server in conjunction with the secret. Not used for any other providers. The
text of the SSH public key associated with your BitBucket Server Application
* `secret` - (Required for `bitbucketDataCenter`) The OAuth Client secret is used for Bitbucket Data Center, this secret is the
the text of the SSH private key associated with your BitBucket Data Center
Application Link.
* `rsaPublicKey` - (Required for `bitbucketDataCenter`) Required for BitBucket
Data Center in conjunction with the secret. Not used for any other providers. The
text of the SSH public key associated with your BitBucket Data Center Application
Link.
* `serviceProvider` - (Required) The VCS provider being connected with. Valid
options are `adoServer`, `adoServices`, `bitbucketHosted`, `bitbucketServer`, `github`, `githubEnterprise`, `gitlabHosted`,
options are `adoServer`, `adoServices`, `bitbucketHosted`, `bitbucketServer`(deprecated), `bitbucketDataCenter`, `github`, `githubEnterprise`, `gitlabHosted`,
`gitlabCommunityEdition`, or `gitlabEnterpriseEdition`.

## Attributes Reference

* `id` - The ID of the OAuth client.
* `oauthTokenId` - The ID of the OAuth token associated with the OAuth client.

<!-- cache-key: cdktf-0.17.0-pre.15 input-0dea494ef76c038939d94b5ae6a0e741e36a87509a350f558cd11d098bf1bde9 -->
<!-- cache-key: cdktf-0.17.0-pre.15 input-0dea494ef76c038939d94b5ae6a0e741e36a87509a350f558cd11d098bf1bde9 -->
2 changes: 1 addition & 1 deletion website/docs/cdktf/java/r/registry_module.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ The `vcsRepo` block supports:
For most VCS providers outside of BitBucket Cloud and Azure DevOps, this will match the `identifier`
string.
* `identifier` - (Required) A reference to your VCS repository in the format
`<organization>/<repository>` where `<organization>` and `<repository>` refer to the organization (or project key, for Bitbucket Server)
`<organization>/<repository>` where `<organization>` and `<repository>` refer to the organization (or project key, for Bitbucket Data Center)
and repository in your VCS provider. The format for Azure DevOps is `<ado organization>/<ado project>/_git/<ado repository>`.
* `oauthTokenId` - (Optional) Token ID of the VCS Connection (OAuth Connection Token) to use. This conflicts with `githubAppInstallationId` and can only be used if `githubAppInstallationId` is not used.
* `githubAppInstallationId` - (Optional) The installation id of the Github App. This conflicts with `oauthTokenId` and can only be used if `oauthTokenId` is not used.
Expand Down