Skip to content

Commit

Permalink
Adding "name" to Cloud Build resource
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
WillBeebe authored and modular-magician committed Oct 18, 2019
1 parent 7ba8fef commit 307a8d5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
27 changes: 27 additions & 0 deletions google/resource_cloud_build_trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ func resourceCloudBuildTrigger() *schema.Resource {
Type: schema.TypeString,
},
},
"name": {
Type: schema.TypeString,
Optional: true,
},
"substitutions": {
Type: schema.TypeMap,
Optional: true,
Expand Down Expand Up @@ -232,6 +236,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 +357,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 +400,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 +520,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 +719,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

0 comments on commit 307a8d5

Please sign in to comment.