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

Don't make ACL comparisons if objects are missing #3970

Merged
merged 1 commit into from
Jul 3, 2019
Merged
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
16 changes: 13 additions & 3 deletions google/resource_storage_object_acl.go
Original file line number Diff line number Diff line change
@@ -58,10 +58,20 @@ func resourceStorageObjectAcl() *schema.Resource {
// makes configs with or without that line indistinguishable.
func resourceStorageObjectAclDiff(diff *schema.ResourceDiff, meta interface{}) error {
config := meta.(*Config)
bucket := diff.Get("bucket").(string)
object := diff.Get("object").(string)
bucket, ok := diff.GetOk("bucket")
if !ok {
// During `plan` when this is interpolated from a resource that hasn't been created yet
// required fields may not be present yet
return nil
}
object, ok := diff.GetOk("object")
if !ok {
// During `plan` when this is interpolated from a resource that hasn't been created yet
// required fields may not be present yet
return nil
}

sObject, err := config.clientStorage.Objects.Get(bucket, object).Projection("full").Do()
sObject, err := config.clientStorage.Objects.Get(bucket.(string), object.(string)).Projection("full").Do()
if err != nil {
// Failing here is OK! Generally, it means we are at Create although it could mean the resource is gone.
// Create won't show the object owner being given