-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: add HNS support for storage bucket #11852
base: main
Are you sure you want to change the base?
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Hello! I am a robot. Tests will require approval from a repository maintainer to run. @rileykarson, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look. You can help make sure that review is quick by doing a self-review and by running impacted tests locally. |
"hierarchical_namespace": { | ||
Type: schema.TypeList, | ||
MaxItems: 1, | ||
Optional: true, |
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.
I think the whole block should be configured with ForceNew behavior. This block can not be changes or remove from the config once it is configured, Right?
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.
Yes updated block with ForceNew
Apart from the field behavior comments, Please check bucket deletion. If the bucket is configured with |
Schema: map[string]*schema.Schema{ | ||
"enabled": { | ||
Type: schema.TypeBool, | ||
Default: false, |
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.
No need to set Default: false, If it is not API default. I believe this field should marked with Required=true as I can see that empty "hierarchical_namespace" won't be returned in the API response.
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.
removed Default
"enabled": { | ||
Type: schema.TypeBool, | ||
Default: false, | ||
Optional: true, |
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.
Can remove this in favor of Required: true,
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.
removed Optional and added required true
->> ran manual test case locally as below
so no code changes needed for force_destroy for HNS bucket update: added force destroy test case in acceptance tests |
Description: `The bucket's HNS support, which defines bucket can organize folders in logical file system structure`, | ||
Elem : &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"enabled": { |
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.
Should we mark this field with ForceNew as well since it is not mutable?
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.
currently this block contains only one resource I see no need of adding again here as the whole block is enforce with ForceNew true,
please suggest otherwise I will add ForceNew also at enabled field level @kautikdk
@@ -880,6 +900,12 @@ func resourceStorageBucketUpdate(d *schema.ResourceData, meta interface{}) error | |||
} | |||
} | |||
|
|||
if d.HasChange("hierarchical_namespace") { | |||
if v, ok := d.GetOk("hierarchical_namespace"); ok { | |||
sb.HierarchicalNamespace = expandBucketHierachicalNamespace(v.([]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.
I believe, There is no need for checking this block in update as the block is marked with ForceNew which will never allow having updates for the block.
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.
removed this block
Config: testAccStorageBucket_basic_hns(bucketName), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr( | ||
"google_storage_bucket.bucket", "hierarchical_namespace.0.enabled", "true"), |
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.
Since we are not adding update tests, It would be worth adding test for false
value as well.
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.
added false test case
`, bucketName) | ||
} | ||
|
||
func testAccStorageBucket_basic_hns_with_data(bucketName string, enabled bool, forceDestroy bool) string { |
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.
Not sure where are we adding data here?
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.
in config we are creating the bucket and in check we are calling testAccCheckStorageBucketPutItem where a file is uploaded to bucket,
I debugged the test case with TF_LOG=DEBUG and it executed as below
- bucket created
- object uploaded to bucket
- after test is successful, in infra cleaning step, as we enforced force_destroy true, objects got deleted and then bucket deleted
@kautikdk
Adds support to enable hierarchical_namespace for storage buckets
Release Note Template for Downstream PRs (will be copied)