Skip to content

Commit

Permalink
update repoType to accept bitbucket_server (#6816) (#13027)
Browse files Browse the repository at this point in the history
Co-authored-by: Edward Sun <sunedward@google.com>
Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
Co-authored-by: Edward Sun <sunedward@google.com>
  • Loading branch information
modular-magician and Edward Sun committed Nov 12, 2022
1 parent 59c92f2 commit 3d33fb1
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .changelog/6816.txt
@@ -0,0 +1,3 @@
```release-note:bug
cloudbuild: fixed the failure when BITBUCKET is provided for `repo_type` on `google_cloudbuild_trigger`
```
8 changes: 4 additions & 4 deletions google/resource_cloudbuild_trigger.go
Expand Up @@ -737,9 +737,9 @@ When using Pub/Sub, Webhook or Manual set the file name using git_file_source in
"repo_type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validateEnum([]string{"UNKNOWN", "CLOUD_SOURCE_REPOSITORIES", "GITHUB", "BITBUCKET"}),
ValidateFunc: validateEnum([]string{"UNKNOWN", "CLOUD_SOURCE_REPOSITORIES", "GITHUB", "BITBUCKET_SERVER"}),
Description: `The type of the repo, since it may not be explicit from the repo field (e.g from a URL).
Values can be UNKNOWN, CLOUD_SOURCE_REPOSITORIES, GITHUB, BITBUCKET Possible values: ["UNKNOWN", "CLOUD_SOURCE_REPOSITORIES", "GITHUB", "BITBUCKET"]`,
Values can be UNKNOWN, CLOUD_SOURCE_REPOSITORIES, GITHUB, BITBUCKET_SERVER Possible values: ["UNKNOWN", "CLOUD_SOURCE_REPOSITORIES", "GITHUB", "BITBUCKET_SERVER"]`,
},
"revision": {
Type: schema.TypeString,
Expand Down Expand Up @@ -960,9 +960,9 @@ One of 'trigger_template', 'github', 'pubsub_config' 'webhook_config' or 'source
"repo_type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validateEnum([]string{"UNKNOWN", "CLOUD_SOURCE_REPOSITORIES", "GITHUB", "BITBUCKET"}),
ValidateFunc: validateEnum([]string{"UNKNOWN", "CLOUD_SOURCE_REPOSITORIES", "GITHUB", "BITBUCKET_SERVER"}),
Description: `The type of the repo, since it may not be explicit from the repo field (e.g from a URL).
Values can be UNKNOWN, CLOUD_SOURCE_REPOSITORIES, GITHUB, BITBUCKET Possible values: ["UNKNOWN", "CLOUD_SOURCE_REPOSITORIES", "GITHUB", "BITBUCKET"]`,
Values can be UNKNOWN, CLOUD_SOURCE_REPOSITORIES, GITHUB, BITBUCKET_SERVER Possible values: ["UNKNOWN", "CLOUD_SOURCE_REPOSITORIES", "GITHUB", "BITBUCKET_SERVER"]`,
},
"uri": {
Type: schema.TypeString,
Expand Down
40 changes: 40 additions & 0 deletions google/resource_cloudbuild_trigger_test.go
Expand Up @@ -209,6 +209,27 @@ func TestAccCloudBuildTrigger_fullStep(t *testing.T) {
})
}

func TestAccCloudBuildTrigger_basic_bitbucket(t *testing.T) {
t.Parallel()
name := fmt.Sprintf("tf-test-%d", randInt(t))

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudBuildTriggerDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccCloudBuildTrigger_basic_bitbucket(name),
},
{
ResourceName: "google_cloudbuild_trigger.build_trigger",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccCloudBuildTrigger_basic(name string) string {
return fmt.Sprintf(`
resource "google_cloudbuild_trigger" "build_trigger" {
Expand Down Expand Up @@ -266,6 +287,25 @@ resource "google_cloudbuild_trigger" "build_trigger" {
`, name)
}

func testAccCloudBuildTrigger_basic_bitbucket(name string) string {
return fmt.Sprintf(`
resource "google_cloudbuild_trigger" "build_trigger" {
name = "%s"
description = "acceptance test build trigger on bitbucket"
trigger_template {
branch_name = "main"
repo_name = "some-repo"
}
git_file_source {
path = "cloudbuild.yaml"
uri = "https://bitbucket.org/myorg/myrepo"
revision = "refs/heads/develop"
repo_type = "BITBUCKET_SERVER"
}
}
`, name)
}

func testAccCloudBuildTrigger_basicDisabled(name string) string {
return fmt.Sprintf(`
resource "google_cloudbuild_trigger" "build_trigger" {
Expand Down
8 changes: 4 additions & 4 deletions website/docs/r/cloudbuild_trigger.html.markdown
Expand Up @@ -501,8 +501,8 @@ The following arguments are supported:
* `repo_type` -
(Required)
The type of the repo, since it may not be explicit from the repo field (e.g from a URL).
Values can be UNKNOWN, CLOUD_SOURCE_REPOSITORIES, GITHUB, BITBUCKET
Possible values are `UNKNOWN`, `CLOUD_SOURCE_REPOSITORIES`, `GITHUB`, and `BITBUCKET`.
Values can be UNKNOWN, CLOUD_SOURCE_REPOSITORIES, GITHUB, BITBUCKET_SERVER
Possible values are `UNKNOWN`, `CLOUD_SOURCE_REPOSITORIES`, `GITHUB`, and `BITBUCKET_SERVER`.

* `revision` -
(Optional)
Expand All @@ -523,8 +523,8 @@ The following arguments are supported:
* `repo_type` -
(Required)
The type of the repo, since it may not be explicit from the repo field (e.g from a URL).
Values can be UNKNOWN, CLOUD_SOURCE_REPOSITORIES, GITHUB, BITBUCKET
Possible values are `UNKNOWN`, `CLOUD_SOURCE_REPOSITORIES`, `GITHUB`, and `BITBUCKET`.
Values can be UNKNOWN, CLOUD_SOURCE_REPOSITORIES, GITHUB, BITBUCKET_SERVER
Possible values are `UNKNOWN`, `CLOUD_SOURCE_REPOSITORIES`, `GITHUB`, and `BITBUCKET_SERVER`.

<a name="nested_trigger_template"></a>The `trigger_template` block supports:

Expand Down

0 comments on commit 3d33fb1

Please sign in to comment.