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

Fix metadata for storage bucket object #6271

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/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