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

Add versioning for google storage buckets #381

Merged
merged 4 commits into from
Sep 15, 2017

Conversation

Stelminator
Copy link
Contributor

@Stelminator Stelminator commented Sep 1, 2017

Fixes #390

@Stelminator
Copy link
Contributor Author

still needs tests.

@rosbo
Copy link
Contributor

rosbo commented Sep 6, 2017

Fixes #390. Waiting on tests to before merging. Let me know if you need help with that.

@@ -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{}{
Copy link
Contributor

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 {
Copy link
Contributor

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

@Stelminator Stelminator force-pushed the google_storage_bucket_versioning branch from b172054 to 28a988c Compare September 14, 2017 23:49
@Stelminator
Copy link
Contributor Author

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.

@Stelminator Stelminator changed the title add versioning for google storage buckets [WIP] add versioning for google storage buckets Sep 15, 2017
@rosbo rosbo changed the title [WIP] add versioning for google storage buckets Add versioning for google storage buckets Sep 15, 2017
@rosbo
Copy link
Contributor

rosbo commented Sep 15, 2017

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

@rosbo rosbo merged commit 43e749c into hashicorp:master Sep 15, 2017
@Stelminator
Copy link
Contributor Author

Awesome, Thanks!

negz pushed a commit to negz/terraform-provider-google that referenced this pull request Oct 17, 2017
chrisst pushed a commit to chrisst/terraform-provider-google that referenced this pull request Nov 9, 2018
luis-silva pushed a commit to luis-silva/terraform-provider-google that referenced this pull request May 21, 2019
@ghost
Copy link

ghost commented Mar 31, 2020

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!

@ghost ghost locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Set object versioning for google storage buckets
2 participants