From 9dc82ec7732eda591e43c29c6c20f5bc7c4cac18 Mon Sep 17 00:00:00 2001 From: Vishwaraj Anand Date: Sun, 5 May 2024 18:24:36 +0000 Subject: [PATCH 1/2] feat(Storage): Enable hierarchical namespace --- Storage/src/StorageClient.php | 2 ++ Storage/tests/System/ManageBucketsTest.php | 29 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Storage/src/StorageClient.php b/Storage/src/StorageClient.php index b08d0796416..a0c671eee2b 100644 --- a/Storage/src/StorageClient.php +++ b/Storage/src/StorageClient.php @@ -292,6 +292,8 @@ function (array $bucket) use ($userProject) { * set in conjunction. For more information, see * [Bucket Locations](https://cloud.google.com/storage/docs/locations). * **Defaults to** `"US"`. + * @type array $hierarchicalNamespace The hierarchical namespace configuration + * on this bucket. * @type array $customPlacementConfig The bucket's dual regions. For more * information, see * [Bucket Locations](https://cloud.google.com/storage/docs/locations). diff --git a/Storage/tests/System/ManageBucketsTest.php b/Storage/tests/System/ManageBucketsTest.php index 1b2d23a11a5..fa23f133d5d 100644 --- a/Storage/tests/System/ManageBucketsTest.php +++ b/Storage/tests/System/ManageBucketsTest.php @@ -104,6 +104,21 @@ public function testCreatesDualRegionBucket() ); } + /** + * @dataProvider hnsConfigs + */ + public function testCreateBucketsWithHnsConfigs($hnsConfig, $expectedHnsEnabled) + { + $name = uniqid(self::TESTING_PREFIX); + + $this->assertFalse(self::$client->bucket($name)->exists()); + $bucket = self::createBucket(self::$client, $name, $hnsConfig); + + $this->assertTrue(self::$client->bucket($name)->exists()); + $this->assertEquals($name, $bucket->name()); + $this->assertEquals($expectedHnsEnabled, $bucket->info()['hierarchicalNamespace']['enabled'] ?? false); + } + public function testUpdateBucket() { $options = [ @@ -464,4 +479,18 @@ public function autoclassConfigs() [['enabled' => true, 'terminalStorageClass' => 'ARCHIVE']], ]; } + + public function hnsConfigs() + { + return [ + [[], false], + [['hierarchicalNamespace' => ['enabled' => false,]], false], + // TODO: Test cases fails because of no uniformBucketLevelAccess + // [['hierarchicalNamespace' => ['enabled' => true,]], false], + [[ + 'hierarchicalNamespace' => ['enabled' => true,], + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => true]] + ], true], + ]; + } } From f1ecf51bf0d81d331682e529cab70736157f226d Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Mon, 6 May 2024 09:07:10 -0700 Subject: [PATCH 2/2] Update Storage/tests/System/ManageBucketsTest.php --- Storage/tests/System/ManageBucketsTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/Storage/tests/System/ManageBucketsTest.php b/Storage/tests/System/ManageBucketsTest.php index fa23f133d5d..59f97ac69fe 100644 --- a/Storage/tests/System/ManageBucketsTest.php +++ b/Storage/tests/System/ManageBucketsTest.php @@ -485,8 +485,6 @@ public function hnsConfigs() return [ [[], false], [['hierarchicalNamespace' => ['enabled' => false,]], false], - // TODO: Test cases fails because of no uniformBucketLevelAccess - // [['hierarchicalNamespace' => ['enabled' => true,]], false], [[ 'hierarchicalNamespace' => ['enabled' => true,], 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => true]]