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

feat: add HNS support for storage bucket #11852

Merged
merged 45 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d940e4f
hns bucket
gurusai-voleti Sep 27, 2024
71da0ba
mmv1/third_party/terraform/services/storage/resource_storage_bucket.g…
gurusai-voleti Sep 27, 2024
d0efd3c
remove default
gurusai-voleti Sep 27, 2024
f876dfc
Merge branch 'GoogleCloudPlatform:main' into main
gurusai-voleti Sep 30, 2024
469834f
add force destroy test case
gurusai-voleti Sep 30, 2024
4abfd7d
update
gurusai-voleti Sep 30, 2024
63ebc1a
corrected params
gurusai-voleti Sep 30, 2024
f110095
update documentation
gurusai-voleti Sep 30, 2024
7f4d6da
add example for hns
gurusai-voleti Sep 30, 2024
93b765c
remove checking change of hns in update block
gurusai-voleti Sep 30, 2024
88c828d
add hns bucket with false testcase
gurusai-voleti Oct 1, 2024
bd8f3d6
Merge branch 'GoogleCloudPlatform:main' into main
gurusai-voleti Oct 3, 2024
df07e05
Merge branch 'GoogleCloudPlatform:main' into main
gurusai-voleti Oct 4, 2024
317c934
Merge branch 'GoogleCloudPlatform:main' into main
gurusai-voleti Oct 8, 2024
7703675
Merge branch 'GoogleCloudPlatform:main' into main
gurusai-voleti Oct 9, 2024
525dae7
Update mmv1/third_party/terraform/services/storage/resource_storage_b…
gurusai-voleti Oct 10, 2024
1500c70
Merge branch 'GoogleCloudPlatform:main' into main
gurusai-voleti Oct 10, 2024
9db5781
Update mmv1/third_party/terraform/services/storage/resource_storage_b…
gurusai-voleti Oct 10, 2024
8da56ed
addressed review comments
gurusai-voleti Oct 10, 2024
a580268
testcase method name change
gurusai-voleti Oct 10, 2024
f621cfa
addressing review comments
gurusai-voleti Oct 10, 2024
baacad5
update testcase and move testcases to last
gurusai-voleti Oct 11, 2024
b8ee11a
Update mmv1/third_party/terraform/services/storage/resource_storage_b…
gurusai-voleti Oct 14, 2024
f37f638
Update mmv1/third_party/terraform/services/storage/resource_storage_b…
gurusai-voleti Oct 14, 2024
f195934
Update mmv1/third_party/terraform/services/storage/resource_storage_b…
gurusai-voleti Oct 14, 2024
8b10c77
Merge branch 'GoogleCloudPlatform:main' into main
gurusai-voleti Oct 14, 2024
34cea0d
delete folders from bottom to top using list and delete folders API
gurusai-voleti Oct 14, 2024
8f356bb
Merge branch 'main' of github.com:gurusai-voleti/magic-modules
gurusai-voleti Oct 14, 2024
1e1dee9
added testcase for folder delete
gurusai-voleti Oct 14, 2024
c4db88d
added nested folders and a file for testcase data
gurusai-voleti Oct 14, 2024
74d39c5
updates
gurusai-voleti Oct 14, 2024
4de8500
updates
gurusai-voleti Oct 14, 2024
d81b07b
update testcase with empty folders
gurusai-voleti Oct 14, 2024
57c8683
update empty folder testcase
gurusai-voleti Oct 14, 2024
a3ae2e8
remove redudant testcase
gurusai-voleti Oct 15, 2024
fb569ef
Merge branch 'GoogleCloudPlatform:main' into main
gurusai-voleti Oct 15, 2024
d16b427
Update storage_bucket.html.markdown
gurusai-voleti Oct 15, 2024
3e34a4c
Update mmv1/third_party/terraform/services/storage/resource_storage_b…
gurusai-voleti Oct 16, 2024
bbbf222
add diff suppresscheck for hns flag
gurusai-voleti Oct 16, 2024
10a5124
Merge branch 'GoogleCloudPlatform:main' into main
gurusai-voleti Oct 16, 2024
e670055
updates
gurusai-voleti Oct 16, 2024
71b0caf
Merge branch 'main' of github.com:gurusai-voleti/magic-modules
gurusai-voleti Oct 16, 2024
d896091
update no plan test case
gurusai-voleti Oct 16, 2024
06fa65b
add missing import
gurusai-voleti Oct 16, 2024
e102ce2
update test case
gurusai-voleti Oct 16, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,23 @@ func ResourceStorageBucket() *schema.Resource {
},
},
},
"hierarchical_namespace": {
rileykarson marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
rileykarson marked this conversation as resolved.
Show resolved Hide resolved
rileykarson marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll want to add a DiffSuppressFunc to this top-level field similar to this one: https://github.com/hashicorp/terraform-provider-google-beta/blob/804148d2559f8c6628258cfa232cd81c72ed6233/google-beta/services/container/resource_container_cluster.go#L6814-L6826

We're always storing the full ("hydrated") value in state in our flatten function where null is mapped to an item being present with enabled = false, so if we see a diff from .# (length) of 1 -> 0 and enabled is false, we can return true from the function to suppress the diff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the suggested change for DiffSuppress func

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": {
rileykarson marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeBool,
Default: false,
gurusai-voleti marked this conversation as resolved.
Show resolved Hide resolved
Optional: true,
gurusai-voleti marked this conversation as resolved.
Show resolved Hide resolved
ForceNew: true,
Description: `Set this enabled flag to true when folders with logical files structure. Default value is false.`,
gurusai-voleti marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
},
},
UseJSONNumber: true,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,46 @@ import (
"google.golang.org/api/storage/v1"
)

func TestAccStorageBucket_basic_hns(t *testing.T) {
gurusai-voleti marked this conversation as resolved.
Show resolved Hide resolved
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"),
rileykarson marked this conversation as resolved.
Show resolved Hide resolved
),
},
{
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()

Expand Down
Loading