Skip to content

Commit

Permalink
feat(Storage): enable hierarchical namespace (#7292)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwarajanand authored May 6, 2024
1 parent 9ad2e3d commit c6f645f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Storage/src/StorageClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
27 changes: 27 additions & 0 deletions Storage/tests/System/ManageBucketsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -464,4 +479,16 @@ public function autoclassConfigs()
[['enabled' => true, 'terminalStorageClass' => 'ARCHIVE']],
];
}

public function hnsConfigs()
{
return [
[[], false],
[['hierarchicalNamespace' => ['enabled' => false,]], false],
[[
'hierarchicalNamespace' => ['enabled' => true,],
'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => true]]
], true],
];
}
}

0 comments on commit c6f645f

Please sign in to comment.