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

Adding "name" to Cloud Build resource #4709

Merged
merged 1 commit into from
Oct 29, 2019
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
28 changes: 28 additions & 0 deletions google/resource_cloud_build_trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ func resourceCloudBuildTrigger() *schema.Resource {
Type: schema.TypeString,
},
},
"name": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},
"substitutions": {
Type: schema.TypeMap,
Optional: true,
Expand Down Expand Up @@ -232,6 +237,12 @@ func resourceCloudBuildTriggerCreate(d *schema.ResourceData, meta interface{}) e
config := meta.(*Config)

obj := make(map[string]interface{})
nameProp, err := expandCloudBuildTriggerName(d.Get("name"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("name"); !isEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) {
obj["name"] = nameProp
}
descriptionProp, err := expandCloudBuildTriggerDescription(d.Get("description"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -347,6 +358,9 @@ func resourceCloudBuildTriggerRead(d *schema.ResourceData, meta interface{}) err
if err := d.Set("trigger_id", flattenCloudBuildTriggerTriggerId(res["id"], d)); err != nil {
return fmt.Errorf("Error reading Trigger: %s", err)
}
if err := d.Set("name", flattenCloudBuildTriggerName(res["name"], d)); err != nil {
return fmt.Errorf("Error reading Trigger: %s", err)
}
if err := d.Set("description", flattenCloudBuildTriggerDescription(res["description"], d)); err != nil {
return fmt.Errorf("Error reading Trigger: %s", err)
}
Expand Down Expand Up @@ -387,6 +401,12 @@ func resourceCloudBuildTriggerUpdate(d *schema.ResourceData, meta interface{}) e
}

obj := make(map[string]interface{})
nameProp, err := expandCloudBuildTriggerName(d.Get("name"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("name"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, nameProp)) {
obj["name"] = nameProp
}
descriptionProp, err := expandCloudBuildTriggerDescription(d.Get("description"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -501,6 +521,10 @@ func flattenCloudBuildTriggerTriggerId(v interface{}, d *schema.ResourceData) in
return v
}

func flattenCloudBuildTriggerName(v interface{}, d *schema.ResourceData) interface{} {
return v
}

func flattenCloudBuildTriggerDescription(v interface{}, d *schema.ResourceData) interface{} {
return v
}
Expand Down Expand Up @@ -696,6 +720,10 @@ func flattenCloudBuildTriggerBuildStepWaitFor(v interface{}, d *schema.ResourceD
return v
}

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

func expandCloudBuildTriggerDescription(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/cloudbuild_trigger.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ The following arguments are supported:
- - -


* `name` -
(Optional)
Name of the trigger. Must be unique within the project.

* `description` -
(Optional)
Human-readable description of the trigger.
Expand Down