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

Adds enterprise_config_resource_name field to cloudbuild trigger resource in order to support github enter… #13739

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/7236.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
cloudbuild: added `github.enterprise_config_resource_name` field to `google_cloudbuild_trigger` resource
```
23 changes: 23 additions & 0 deletions google/resource_cloudbuild_trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,12 @@ One of 'trigger_template', 'github', 'pubsub_config' or 'webhook_config' must be
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enterprise_config_resource_name": {
Type: schema.TypeString,
Optional: true,
Description: `The resource name of the github enterprise config that should be applied to this installation.
For example: "projects/{$projectId}/locations/{$locationId}/githubEnterpriseConfigs/{$configId}"`,
},
"name": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1908,6 +1914,8 @@ func flattenCloudBuildTriggerGithub(v interface{}, d *schema.ResourceData, confi
flattenCloudBuildTriggerGithubPullRequest(original["pullRequest"], d, config)
transformed["push"] =
flattenCloudBuildTriggerGithubPush(original["push"], d, config)
transformed["enterprise_config_resource_name"] =
flattenCloudBuildTriggerGithubEnterpriseConfigResourceName(original["enterpriseConfigResourceName"], d, config)
return []interface{}{transformed}
}
func flattenCloudBuildTriggerGithubOwner(v interface{}, d *schema.ResourceData, config *Config) interface{} {
Expand Down Expand Up @@ -1976,6 +1984,10 @@ func flattenCloudBuildTriggerGithubPushTag(v interface{}, d *schema.ResourceData
return v
}

func flattenCloudBuildTriggerGithubEnterpriseConfigResourceName(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}

func flattenCloudBuildTriggerBitbucketServerTriggerConfig(v interface{}, d *schema.ResourceData, config *Config) interface{} {
if v == nil {
return nil
Expand Down Expand Up @@ -2953,6 +2965,13 @@ func expandCloudBuildTriggerGithub(v interface{}, d TerraformResourceData, confi
transformed["push"] = transformedPush
}

transformedEnterpriseConfigResourceName, err := expandCloudBuildTriggerGithubEnterpriseConfigResourceName(original["enterprise_config_resource_name"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedEnterpriseConfigResourceName); val.IsValid() && !isEmptyValue(val) {
transformed["enterpriseConfigResourceName"] = transformedEnterpriseConfigResourceName
}

return transformed, nil
}

Expand Down Expand Up @@ -3054,6 +3073,10 @@ func expandCloudBuildTriggerGithubPushTag(v interface{}, d TerraformResourceData
return v, nil
}

func expandCloudBuildTriggerGithubEnterpriseConfigResourceName(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandCloudBuildTriggerBitbucketServerTriggerConfig(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down
25 changes: 25 additions & 0 deletions website/docs/r/cloudbuild_trigger.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,26 @@ resource "google_cloudbuild_trigger" "bbs-pull-request-trigger" {
filename = "cloudbuild.yaml"
}
```
## Example Usage - Cloudbuild Trigger Github Enterprise


```hcl
resource "google_cloudbuild_trigger" "ghe-trigger" {
name = "terraform-ghe-trigger"
location = "us-central1"

github {
owner = "hashicorp"
name = "terraform-provider-google"
push {
branch = "^main$"
}
enterprise_config_resource_name = "projects/123456789/locations/us-central1/githubEnterpriseConfigs/configID"
}

filename = "cloudbuild.yaml"
}
```

## Argument Reference

Expand Down Expand Up @@ -774,6 +794,11 @@ The following arguments are supported:
filter to match changes in refs, like branches or tags. Specify only one of `pull_request` or `push`.
Structure is [documented below](#nested_push).

* `enterprise_config_resource_name` -
(Optional)
The resource name of the github enterprise config that should be applied to this installation.
For example: "projects/{$projectId}/locations/{$locationId}/githubEnterpriseConfigs/{$configId}"


<a name="nested_pull_request"></a>The `pull_request` block supports:

Expand Down