Skip to content

Commit

Permalink
actually set and read metadata (#3458) (#6271)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored May 1, 2020
1 parent 49c2817 commit 9ca3681
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/3458.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
storage: Fixed setting/reading `google_storage_bucket_object` metadata on API object
```
1 change: 1 addition & 0 deletions google/data_source_google_storage_bucket_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func dataSourceGoogleStorageBucketObjectRead(d *schema.ResourceData, meta interf
d.Set("self_link", res["selfLink"])
d.Set("storage_class", res["storageClass"])
d.Set("md5hash", res["md5Hash"])
d.Set("metadata", res["metadata"])

d.SetId(bucket + "-" + name)

Expand Down
5 changes: 5 additions & 0 deletions google/resource_storage_bucket_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ func resourceStorageBucketObjectCreate(d *schema.ResourceData, meta interface{})
object.ContentType = v.(string)
}

if v, ok := d.GetOk("metadata"); ok {
object.Metadata = convertStringMap(v.(map[string]interface{}))
}

if v, ok := d.GetOk("storage_class"); ok {
object.StorageClass = v.(string)
}
Expand Down Expand Up @@ -249,6 +253,7 @@ func resourceStorageBucketObjectRead(d *schema.ResourceData, meta interface{}) e
d.Set("storage_class", res.StorageClass)
d.Set("self_link", res.SelfLink)
d.Set("output_name", res.Name)
d.Set("metadata", res.Metadata)

d.SetId(objectGetId(res))

Expand Down

0 comments on commit 9ca3681

Please sign in to comment.