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(Storage): Enable hierarchical namespace #7292

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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],
];
}
}
Loading