Skip to content

Commit

Permalink
Added resource for bitbucket datacenter integration handling (#498)
Browse files Browse the repository at this point in the history
* Bump google.golang.org/grpc from 1.57.0 to 1.57.1

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.57.0 to 1.57.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.57.0...v1.57.1)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* Added resource for bitbucket datacenter integration handling
* Minor improvements
* Adjust bitbucket datacenter resource to recent changes

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Plushnikov, Michail <[email protected]>
Co-authored-by: Piotr Truszkowski <[email protected]>
  • Loading branch information
4 people authored Mar 6, 2024
1 parent 702e125 commit 4e1dd29
Show file tree
Hide file tree
Showing 15 changed files with 549 additions and 47 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ jobs:
SPACELIFT_PROVIDER_TEST_SOURCECODE_BITBUCKETDATACENTER_SPACELEVEL_APIHOST: ${{ secrets.COMMON_SPACELIFT_PROVIDER_TEST_SOURCECODE_BITBUCKETDATACENTER_APIHOST }}
SPACELIFT_PROVIDER_TEST_SOURCECODE_BITBUCKETDATACENTER_SPACELEVEL_WEBHOOKSECRET: ${{ secrets.PROD_SPACELIFT_PROVIDER_TEST_SOURCECODE_BITBUCKETDATACENTER_SPACELEVEL_WEBHOOKSECRET }}
SPACELIFT_PROVIDER_TEST_SOURCECODE_BITBUCKETDATACENTER_SPACELEVEL_WEBHOOKURL: ${{ secrets.PROD_SPACELIFT_PROVIDER_TEST_SOURCECODE_BITBUCKETDATACENTER_SPACELEVEL_WEBHOOKURL }}
SPACELIFT_PROVIDER_TEST_SOURCECODE_BITBUCKETDATACENTER_SPACELEVEL_ACCESSTOKEN: ${{ secrets.COMMON_SPACELIFT_PROVIDER_TEST_SOURCECODE_BITBUCKETDATACENTER_ACCESSTOKEN }}
SPACELIFT_PROVIDER_TEST_SOURCECODE_GITHUBENTERPRISE_DEFAULT_NAME: "GitHub Default"
SPACELIFT_PROVIDER_TEST_SOURCECODE_GITHUBENTERPRISE_DEFAULT_ID: "github-default"
SPACELIFT_PROVIDER_TEST_SOURCECODE_GITHUBENTERPRISE_DEFAULT_APIHOST: ${{ secrets.COMMON_SPACELIFT_PROVIDER_TEST_SOURCECODE_GITHUBENTERPRISE_APIHOST }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ jobs:
SPACELIFT_PROVIDER_TEST_SOURCECODE_BITBUCKETDATACENTER_SPACELEVEL_APIHOST: ${{ secrets.COMMON_SPACELIFT_PROVIDER_TEST_SOURCECODE_BITBUCKETDATACENTER_APIHOST }}
SPACELIFT_PROVIDER_TEST_SOURCECODE_BITBUCKETDATACENTER_SPACELEVEL_WEBHOOKSECRET: ${{ secrets.PREPROD_SPACELIFT_PROVIDER_TEST_SOURCECODE_BITBUCKETDATACENTER_SPACELEVEL_WEBHOOKSECRET }}
SPACELIFT_PROVIDER_TEST_SOURCECODE_BITBUCKETDATACENTER_SPACELEVEL_WEBHOOKURL: ${{ secrets.PREPROD_SPACELIFT_PROVIDER_TEST_SOURCECODE_BITBUCKETDATACENTER_SPACELEVEL_WEBHOOKURL }}
SPACELIFT_PROVIDER_TEST_SOURCECODE_BITBUCKETDATACENTER_SPACELEVEL_ACCESSTOKEN: ${{ secrets.COMMON_SPACELIFT_PROVIDER_TEST_SOURCECODE_BITBUCKETDATACENTER_ACCESSTOKEN }}
SPACELIFT_PROVIDER_TEST_SOURCECODE_GITHUBENTERPRISE_DEFAULT_NAME: "GitHub Default"
SPACELIFT_PROVIDER_TEST_SOURCECODE_GITHUBENTERPRISE_DEFAULT_ID: "github-default"
SPACELIFT_PROVIDER_TEST_SOURCECODE_GITHUBENTERPRISE_DEFAULT_APIHOST: ${{ secrets.COMMON_SPACELIFT_PROVIDER_TEST_SOURCECODE_GITHUBENTERPRISE_APIHOST }}
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/bitbucket_datacenter_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ data "spacelift_bitbucket_datacenter_integration" "bitbucket_datacenter_integrat
- `name` (String) Bitbucket Datacenter integration name
- `space_id` (String) Bitbucket Datacenter integration space id
- `user_facing_host` (String) Bitbucket Datacenter integration user facing host
- `username` (String) Bitbucket Datacenter username
- `username` (String) Username which will be used to authenticate requests for cloning repositories
- `webhook_secret` (String) Bitbucket Datacenter integration webhook secret
- `webhook_url` (String) Bitbucket Datacenter integration webhook URL
70 changes: 70 additions & 0 deletions docs/resources/bitbucket_datacenter_integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "spacelift_bitbucket_datacenter_integration Resource - terraform-provider-spacelift"
subcategory: ""
description: |-
spacelift_bitbucket_datacenter_integration represents details of a bitbucket datacenter integration
---

# spacelift_bitbucket_datacenter_integration (Resource)

`spacelift_bitbucket_datacenter_integration` represents details of a bitbucket datacenter integration

## Example Usage

```terraform
# When a Bitbucket Datacenter server is accessible from the public internet.
resource "spacelift_bitbucket_datacenter_integration" "example" {
name = "Bitbucket integration"
is_default = false
space_id = "root"
api_host = "https://mybitbucket.myorg.com"
user_facing_host = "https://mybitbucket.myorg.com"
username = "bitbucket_user_name"
access_token = "ABCD-EFGhiJKlMNoPQrSTuVWxYz0123456789abCDefGhiJkL"
}
# When a Bitbucket Datacenter server is not accessible from the public internet.
# We need to use "private://" scheme to reach out our VCS Agent pool.
resource "spacelift_bitbucket_datacenter_integration" "private-example" {
name = "Bitbucket integration"
is_default = false
space_id = "root"
api_host = "private://mybitbucket"
user_facing_host = "https://mybitbucket.myorg.com"
username = "bitbucket_user_name"
access_token = "ABCD-EFGhiJKlMNoPQrSTuVWxYz0123456789abCDefGhiJkL"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `access_token` (String, Sensitive) User access token from Bitbucket
- `api_host` (String) The API host where requests will be sent
- `is_default` (Boolean) Bitbucket Datacenter integration is default.
- `name` (String) Bitbucket Datacenter integration name
- `user_facing_host` (String) User Facing Host which will be used for all user-facing URLs displayed in the Spacelift UI
- `username` (String) Username which will be used to authenticate requests for cloning repositories

### Optional

- `description` (String) Bitbucket Datacenter integration description
- `labels` (Set of String) Bitbucket Datacenter integration labels
- `space_id` (String) Bitbucket Datacenter integration space id. Defaults to `root`.

### Read-Only

- `id` (String) Bitbucket Datacenter integration id.
- `webhook_secret` (String, Sensitive) Secret for webhooks originating from Bitbucket repositories
- `webhook_url` (String) URL for webhooks originating from Bitbucket repositories

## Import

Import is supported using the following syntax:

```shell
terraform import spacelift_bitbucket_datacenter_integration.example spacelift_bitbucket_datacenter_integration_id
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import spacelift_bitbucket_datacenter_integration.example spacelift_bitbucket_datacenter_integration_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# When a Bitbucket Datacenter server is accessible from the public internet.
resource "spacelift_bitbucket_datacenter_integration" "example" {
name = "Bitbucket integration"
is_default = false
space_id = "root"
api_host = "https://mybitbucket.myorg.com"
user_facing_host = "https://mybitbucket.myorg.com"
username = "bitbucket_user_name"
access_token = "ABCD-EFGhiJKlMNoPQrSTuVWxYz0123456789abCDefGhiJkL"
}

# When a Bitbucket Datacenter server is not accessible from the public internet.
# We need to use "private://" scheme to reach out our VCS Agent pool.
resource "spacelift_bitbucket_datacenter_integration" "private-example" {
name = "Bitbucket integration"
is_default = false
space_id = "root"
api_host = "private://mybitbucket"
user_facing_host = "https://mybitbucket.myorg.com"
username = "bitbucket_user_name"
access_token = "ABCD-EFGhiJKlMNoPQrSTuVWxYz0123456789abCDefGhiJkL"
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ require (
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect
google.golang.org/grpc v1.57.0 // indirect
google.golang.org/grpc v1.57.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 h1:0nDDozoAU19Qb2HwhXadU8OcsiO/09cnTqhUtq2MEOM=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA=
google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw=
google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo=
google.golang.org/grpc v1.57.1 h1:upNTNqv0ES+2ZOOqACwVtS3Il8M12/+Hz41RCPzAjQg=
google.golang.org/grpc v1.57.1/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
Expand Down
1 change: 1 addition & 0 deletions spacelift/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ var testConfig struct {
APIHost string
WebhookSecret string
WebhookURL string
AccessToken string
}
Repository struct {
Name string
Expand Down
8 changes: 4 additions & 4 deletions spacelift/data_bitbucket_datacenter_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ func dataBitbucketDatacenterIntegration() *schema.Resource {
Description: "Bitbucket Datacenter integration space id",
Computed: true,
},
bitbucketDatacenterUsername: {
bitbucketDatacenterAPIHost: {
Type: schema.TypeString,
Description: "Bitbucket Datacenter username",
Description: "Bitbucket Datacenter integration api host",
Computed: true,
},
bitbucketDatacenterAPIHost: {
bitbucketDatacenterUsername: {
Type: schema.TypeString,
Description: "Bitbucket Datacenter integration api host",
Description: "Username which will be used to authenticate requests for cloning repositories",
Computed: true,
},
bitbucketDatacenterWebhookSecret: {
Expand Down
37 changes: 37 additions & 0 deletions spacelift/internal/structs/bitbucket_datacenter_integration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package structs

import "github.com/shurcooL/graphql"

// BitbucketDatacenterIntegration represents the bitbucket datacenter integration data relevant to the provider.
type BitbucketDatacenterIntegration struct {
ID string `graphql:"id"`
Name string `graphql:"name"`
IsDefault bool `graphql:"isDefault"`
Space struct {
ID string `graphql:"id"`
} `graphql:"space"`
Labels []string `graphql:"labels"`
Description *string `graphql:"description"`
APIHost string `graphql:"apiHost"`
Username string `graphql:"username"`
UserFacingHost string `graphql:"userFacingHost"`
WebhookSecret string `graphql:"webhookSecret"`
WebhookURL string `graphql:"webhookURL"`
}

// CustomVCSInput represents the custom VCS input data.
type CustomVCSInput struct {
Name graphql.String `json:"name"`
SpaceID graphql.ID `json:"spaceID"`
Labels *[]graphql.String `json:"labels"`
Description *graphql.String `json:"description"`
IsDefault *graphql.Boolean `json:"isDefault"`
}

// CustomVCSUpdateInput represents the custom VCS update input data.
type CustomVCSUpdateInput struct {
ID graphql.ID `json:"id"`
SpaceID graphql.ID `json:"space"`
Labels *[]graphql.String `json:"labels"`
Description *graphql.String `json:"description"`
}
77 changes: 39 additions & 38 deletions spacelift/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,44 +100,45 @@ func Provider(commit, version string) plugin.ProviderFunc {
"spacelift_worker_pools": dataWorkerPools(),
},
ResourcesMap: map[string]*schema.Resource{
"spacelift_audit_trail_webhook": resourceAuditTrailWebhook(),
"spacelift_aws_role": resourceAWSRole(),
"spacelift_aws_integration": resourceAWSIntegration(),
"spacelift_aws_integration_attachment": resourceAWSIntegrationAttachment(),
"spacelift_azure_integration": resourceAzureIntegration(),
"spacelift_azure_integration_attachment": resourceAzureIntegrationAttachment(),
"spacelift_blueprint": resourceBlueprint(),
"spacelift_context_attachment": resourceContextAttachment(),
"spacelift_context": resourceContext(),
"spacelift_drift_detection": resourceDriftDetection(),
"spacelift_environment_variable": resourceEnvironmentVariable(),
"spacelift_gcp_service_account": resourceGCPServiceAccount(),
"spacelift_idp_group_mapping": resourceIdpGroupMapping(),
"spacelift_module": resourceModule(),
"spacelift_mounted_file": resourceMountedFile(),
"spacelift_policy_attachment": resourcePolicyAttachment(),
"spacelift_policy": resourcePolicy(),
"spacelift_run": resourceRun(),
"spacelift_space": resourceSpace(),
"spacelift_scheduled_task": resourceScheduledTask(),
"spacelift_scheduled_delete_stack": resourceScheduledDeleteStack(),
"spacelift_security_email": resourceSecurityEmail(),
"spacelift_stack": resourceStack(),
"spacelift_stack_dependency": resourceStackDependency(),
"spacelift_stack_dependency_reference": resourceStackDependencyReference(),
"spacelift_stack_activator": resourceStackActivator(),
"spacelift_stack_destructor": resourceStackDestructor(),
"spacelift_stack_aws_role": resourceStackAWSRole(), // deprecated
"spacelift_stack_gcp_service_account": resourceStackGCPServiceAccount(), // deprecated
"spacelift_saved_filter": resourceSavedFilter(),
"spacelift_terraform_provider": resourceTerraformProvider(),
"spacelift_user": resourceUser(),
"spacelift_vcs_agent_pool": resourceVCSAgentPool(),
"spacelift_webhook": resourceWebhook(),
"spacelift_named_webhook": resourceNamedWebhook(),
"spacelift_named_webhook_secret_header": resourceNamedWebhookSecretHeader(),
"spacelift_worker_pool": resourceWorkerPool(),
"spacelift_version": resourceVersion(),
"spacelift_audit_trail_webhook": resourceAuditTrailWebhook(),
"spacelift_aws_role": resourceAWSRole(),
"spacelift_aws_integration": resourceAWSIntegration(),
"spacelift_aws_integration_attachment": resourceAWSIntegrationAttachment(),
"spacelift_azure_integration": resourceAzureIntegration(),
"spacelift_azure_integration_attachment": resourceAzureIntegrationAttachment(),
"spacelift_blueprint": resourceBlueprint(),
"spacelift_bitbucket_datacenter_integration": resourceBitbucketDatacenterIntegration(),
"spacelift_context_attachment": resourceContextAttachment(),
"spacelift_context": resourceContext(),
"spacelift_drift_detection": resourceDriftDetection(),
"spacelift_environment_variable": resourceEnvironmentVariable(),
"spacelift_gcp_service_account": resourceGCPServiceAccount(),
"spacelift_idp_group_mapping": resourceIdpGroupMapping(),
"spacelift_module": resourceModule(),
"spacelift_mounted_file": resourceMountedFile(),
"spacelift_policy_attachment": resourcePolicyAttachment(),
"spacelift_policy": resourcePolicy(),
"spacelift_run": resourceRun(),
"spacelift_space": resourceSpace(),
"spacelift_scheduled_task": resourceScheduledTask(),
"spacelift_scheduled_delete_stack": resourceScheduledDeleteStack(),
"spacelift_security_email": resourceSecurityEmail(),
"spacelift_stack": resourceStack(),
"spacelift_stack_dependency": resourceStackDependency(),
"spacelift_stack_dependency_reference": resourceStackDependencyReference(),
"spacelift_stack_activator": resourceStackActivator(),
"spacelift_stack_destructor": resourceStackDestructor(),
"spacelift_stack_aws_role": resourceStackAWSRole(), // deprecated
"spacelift_stack_gcp_service_account": resourceStackGCPServiceAccount(), // deprecated
"spacelift_saved_filter": resourceSavedFilter(),
"spacelift_terraform_provider": resourceTerraformProvider(),
"spacelift_user": resourceUser(),
"spacelift_vcs_agent_pool": resourceVCSAgentPool(),
"spacelift_webhook": resourceWebhook(),
"spacelift_named_webhook": resourceNamedWebhook(),
"spacelift_named_webhook_secret_header": resourceNamedWebhookSecretHeader(),
"spacelift_worker_pool": resourceWorkerPool(),
"spacelift_version": resourceVersion(),
},
ConfigureContextFunc: configureProvider(commit, version),
}
Expand Down
Loading

0 comments on commit 4e1dd29

Please sign in to comment.