Skip to content

Commit

Permalink
Add guid for datasource IBM-Cloud#1724 of resource instance and suppr…
Browse files Browse the repository at this point in the history
…ess error on creating or reading tags
  • Loading branch information
hkantare committed Jul 21, 2020
1 parent 95e0ee0 commit 38b714b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
8 changes: 8 additions & 0 deletions ibm/data_source_ibm_resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ func dataSourceIBMResourceInstance() *schema.Resource {
Computed: true,
Description: "CRN of resource instance",
},

"guid": {
Type: schema.TypeString,
Computed: true,
Description: "Guid of resource instance",
},

ResourceName: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -193,6 +200,7 @@ func dataSourceIBMResourceInstanceRead(d *schema.ResourceData, meta interface{})
d.Set(ResourceCRN, instance.Crn.String())
d.Set(ResourceStatus, instance.State)
d.Set(ResourceGroupName, instance.ResourceGroupName)
d.Set("guid", instance.Guid)
if len(instance.Extensions) == 0 {
d.Set("extensions", instance.Extensions)
} else {
Expand Down
8 changes: 4 additions & 4 deletions ibm/resource_ibm_resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ func resourceIBMResourceInstanceCreate(d *schema.ResourceData, meta interface{})
oldList, newList := d.GetChange("tags")
err = UpdateTagsUsingCRN(oldList, newList, meta, instance.Crn.String())
if err != nil {
return fmt.Errorf(
"Error on create of resource instance tags (%s) tags: %s", d.Id(), err)
log.Printf(
"Error on create of resource instance (%s) tags: %s", d.Id(), err)
}
}

Expand All @@ -304,7 +304,7 @@ func resourceIBMResourceInstanceRead(d *schema.ResourceData, meta interface{}) e

tags, err := GetTagsUsingCRN(meta, instance.Crn.String())
if err != nil {
return fmt.Errorf(
log.Printf(
"Error on get of resource instance tags (%s) tags: %s", d.Id(), err)
}
d.Set("tags", tags)
Expand Down Expand Up @@ -421,7 +421,7 @@ func resourceIBMResourceInstanceUpdate(d *schema.ResourceData, meta interface{})
err = UpdateTagsUsingCRN(oldList, newList, meta, instance.Crn.String())
if err != nil {
log.Printf(
"Error on update of resource vpc (%s) tags: %s", d.Id(), err)
"Error on update of resource instance (%s) tags: %s", d.Id(), err)
}
}

Expand Down
1 change: 1 addition & 0 deletions website/docs/d/resource_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ The following attributes are exported:
* `status` - The status of resource instance.
* `plan` - The plan for the service offering used by this resource instance.
* `extensions` - The extended metadata as a map associated with the resource instance.
* `guid`- Guid of the resource instance.

0 comments on commit 38b714b

Please sign in to comment.