diff --git a/docs/data-sources/bitbucket_cloud_integration.md b/docs/data-sources/bitbucket_cloud_integration.md index a26e1d4c..6a8c58bc 100644 --- a/docs/data-sources/bitbucket_cloud_integration.md +++ b/docs/data-sources/bitbucket_cloud_integration.md @@ -23,3 +23,4 @@ data "spacelift_bitbucket_cloud_integration" "bitbucket_cloud_integration" {} - `id` (String) The ID of this resource. - `username` (String) Bitbucket Cloud username +- `webhook_url` (String) Bitbucket Cloud integration webhook URL diff --git a/spacelift/data_bitbucket_cloud_integration.go b/spacelift/data_bitbucket_cloud_integration.go index 440321a3..14a56488 100644 --- a/spacelift/data_bitbucket_cloud_integration.go +++ b/spacelift/data_bitbucket_cloud_integration.go @@ -10,9 +10,11 @@ import ( ) var bitbucketCloudFields = struct { - Username string + Username string + WebhookURL string }{ - Username: "username", + Username: "username", + WebhookURL: "webhook_url", } func dataBitbucketCloudIntegration() *schema.Resource { @@ -27,6 +29,11 @@ func dataBitbucketCloudIntegration() *schema.Resource { Description: "Bitbucket Cloud username", Computed: true, }, + bitbucketCloudFields.WebhookURL: { + Type: schema.TypeString, + Description: "Bitbucket Cloud integration webhook URL", + Computed: true, + }, }, } } @@ -34,7 +41,8 @@ func dataBitbucketCloudIntegration() *schema.Resource { func dataBitbucketCloudIntegrationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var query struct { BitbucketCloudIntegration *struct { - Username string `graphql:"username"` + Username string `graphql:"username"` + WebhookURL string `graphql:"webhookUrl"` } `graphql:"bitbucketCloudIntegration"` } @@ -49,6 +57,7 @@ func dataBitbucketCloudIntegrationRead(ctx context.Context, d *schema.ResourceDa d.SetId("spacelift_bitbucket_cloud_integration_id") // TF expects id to be set otherwise it will fail d.Set(bitbucketCloudFields.Username, bitbucketCloudIntegration.Username) + d.Set(bitbucketCloudFields.WebhookURL, bitbucketCloudIntegration.WebhookURL) return nil } diff --git a/spacelift/data_bitbucket_cloud_integration_test.go b/spacelift/data_bitbucket_cloud_integration_test.go index 390e1f97..55ba0ca4 100644 --- a/spacelift/data_bitbucket_cloud_integration_test.go +++ b/spacelift/data_bitbucket_cloud_integration_test.go @@ -9,13 +9,24 @@ import ( ) func TestBitbucketCloudIntegrationData(t *testing.T) { - testSteps(t, []resource.TestStep{{ - Config: ` + testSteps(t, []resource.TestStep{ + { + Config: ` data "spacelift_bitbucket_cloud_integration" "test" {} `, - Check: Resource( - "data.spacelift_bitbucket_cloud_integration.test", - Attribute("username", IsNotEmpty()), - ), - }}) + Check: Resource( + "data.spacelift_bitbucket_cloud_integration.test", + Attribute("username", IsNotEmpty()), + ), + }, + { + Config: ` + data "spacelift_bitbucket_cloud_integration" "test" {} + `, + Check: Resource( + "data.spacelift_bitbucket_cloud_integration.test", + Attribute("webhook_url", IsNotEmpty()), + ), + }, + }) }