-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add versioning for google storage buckets #381
Add versioning for google storage buckets #381
Conversation
still needs tests. |
Fixes #390. Waiting on tests to before merging. Let me know if you need help with that. |
google/resource_storage_bucket.go
Outdated
@@ -351,6 +382,11 @@ func resourceStorageBucketRead(d *schema.ResourceData, meta interface{}) error { | |||
d.Set("storage_class", res.StorageClass) | |||
d.Set("location", res.Location) | |||
d.Set("cors", flattenCors(res.Cors)) | |||
versioning := make([]map[string]interface{}, 0, 1) | |||
versioning = append(versioning, map[string]interface{}{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract this in a new method called flattenBucketVersioning
for consistency.
See this method for an example: https://github.com/terraform-providers/terraform-provider-google/blob/master/google/resource_sql_database_instance.go#L1037
@@ -282,6 +304,15 @@ func resourceStorageBucketUpdate(d *schema.ResourceData, meta interface{}) error | |||
} | |||
} | |||
|
|||
if d.HasChange("versioning") { | |||
if v, ok := d.GetOk("versioning"); ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a new expandBucketVersioning
method to avoid code duplication and keep consistency with other resources.
See example here: https://github.com/terraform-providers/terraform-provider-google/blob/master/google/resource_compute_instance_group_manager.go#L740
b172054
to
28a988c
Compare
Sorry for the delay. I've updated my branch with the requested changes and a shot at a test. I'm not sure what else to add except to rewrite the commit messages/squash. |
Thanks Christopher for adding versioning. Great work. I fixed one small bug (the Versioning field returned by the API is null if not set) and pushed it to your branch. No need to squash it yourself. We (maintainers) always squash/merge when merging into master. TF_ACC=1 go test ./google -v -run TestAccStorageBucket_ -timeout 120m
=== RUN TestAccStorageBucket_import
--- PASS: TestAccStorageBucket_import (2.65s)
=== RUN TestAccStorageBucket_basic
--- PASS: TestAccStorageBucket_basic (2.54s)
=== RUN TestAccStorageBucket_lowercaseLocation
--- PASS: TestAccStorageBucket_lowercaseLocation (6.22s)
=== RUN TestAccStorageBucket_customAttributes
--- PASS: TestAccStorageBucket_customAttributes (5.96s)
=== RUN TestAccStorageBucket_lifecycleRules
--- PASS: TestAccStorageBucket_lifecycleRules (2.24s)
=== RUN TestAccStorageBucket_storageClass
--- PASS: TestAccStorageBucket_storageClass (6.52s)
=== RUN TestAccStorageBucket_update
--- PASS: TestAccStorageBucket_update (17.55s)
=== RUN TestAccStorageBucket_forceDestroy
--- PASS: TestAccStorageBucket_forceDestroy (18.13s)
=== RUN TestAccStorageBucket_versioning
--- PASS: TestAccStorageBucket_versioning (2.86s)
=== RUN TestAccStorageBucket_cors
--- PASS: TestAccStorageBucket_cors (2.40s)
PASS
ok github.com/terraform-providers/terraform-provider-google/google 67.205s |
Awesome, Thanks! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
Fixes #390