-
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?
Changes from 1 commit
d940e4f
71da0ba
d0efd3c
f876dfc
469834f
4abfd7d
63ebc1a
f110095
7f4d6da
93b765c
88c828d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -549,6 +549,23 @@ func ResourceStorageBucket() *schema.Resource { | |
}, | ||
}, | ||
}, | ||
"hierarchical_namespace": { | ||
Type: schema.TypeList, | ||
MaxItems: 1, | ||
Optional: true, | ||
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 commentThe 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 commentThe 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 |
||
Type: schema.TypeBool, | ||
Default: false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. removed Default |
||
Optional: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can remove this in favor of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed Optional and added required true |
||
ForceNew: true, | ||
Description: `Set this enabled flag to true when folders with logical files structure. Default value is false.`, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
UseJSONNumber: true, | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,46 @@ import ( | |
"google.golang.org/api/storage/v1" | ||
) | ||
|
||
func TestAccStorageBucket_basic_hns(t *testing.T) { | ||
t.Parallel() | ||
|
||
bucketName := acctest.TestBucketName(t) | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
CheckDestroy: testAccStorageBucketDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added false test case |
||
), | ||
}, | ||
{ | ||
ResourceName: "google_storage_bucket.bucket", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"force_destroy"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccStorageBucket_basic_hns(bucketName string) string { | ||
return fmt.Sprintf(` | ||
resource "google_storage_bucket" "bucket" { | ||
name = "%s" | ||
location = "US" | ||
uniform_bucket_level_access = true | ||
hierarchical_namespace { | ||
enabled = true | ||
} | ||
} | ||
`, bucketName) | ||
} | ||
|
||
func TestAccStorageBucket_basic(t *testing.T) { | ||
t.Parallel() | ||
|
||
|
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