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 ability to enable hierarchical namespace on buckets #2453

Merged
merged 3 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
feat: add ability to enable hierarchical namespace on buckets
  • Loading branch information
ddelgrosso1 committed May 3, 2024
commit 3f4667bea9422ddbf51fe6f41c1d3dbdcf7a12a5
3 changes: 3 additions & 0 deletions src/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ export interface BucketMetadata extends BaseMetadata {
encryption?: {
defaultKmsKeyName?: string;
} | null;
hierarchicalNamespace?: {
enabled?: boolean;
};
iamConfiguration?: {
publicAccessPrevention?: string;
uniformBucketLevelAccess?: {
Expand Down
4 changes: 4 additions & 0 deletions src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ export interface CreateBucketRequest {
customPlacementConfig?: CustomPlacementConfig;
dra?: boolean;
enableObjectRetention?: boolean;
hierarchicalNamespace?: {
enabled?: boolean;
};
location?: string;
multiRegional?: boolean;
nearline?: boolean;
Expand Down Expand Up @@ -868,6 +871,7 @@ export class Storage extends Service {
* @property {boolean} [dra=false] Specify the storage class as Durable Reduced
* Availability.
* @property {boolean} [enableObjectRetention=false] Specifiy whether or not object retention should be enabled on this bucket.
* @property {object} [hierarchicalNamespace.enabled=false] Specify whether or not to enable hierarchical namespace on this bucket.
* @property {string} [location] Specify the bucket's location. If specifying
* a dual-region, the `customPlacementConfig` property should be set in conjunction.
* For more information, see {@link https://cloud.google.com/storage/docs/locations| Bucket Locations}.
Expand Down
40 changes: 40 additions & 0 deletions system-test/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,46 @@
});
});

describe.only('bucket hierarchical namespace', async () => {

Check failure on line 1515 in system-test/storage.ts

View workflow job for this annotation

GitHub Actions / lint

'describe.only' is restricted from being used
let bucket: Bucket;

beforeEach(() => {
bucket = storage.bucket(generateName());
});

afterEach(async () => {
try {
await bucket.delete();
} catch {
//Ignore errors
}
});

it('should create a bucket without hierarchical namespace enabled (implicit)', async () => {
await storage.createBucket(bucket.name);
const [metadata] = await bucket.getMetadata();
assert.strictEqual(metadata.hierarchicalNamespace, undefined);
});

it('should create a bucket without hierarchical namespace enabled (explicit)', async () => {
await storage.createBucket(bucket.name, {
hierarchicalNamespace: {enabled: false},
});
const [metadata] = await bucket.getMetadata();
assert(metadata.hierarchicalNamespace);
assert.strictEqual(metadata.hierarchicalNamespace.enabled, false);
});

it('should create a bucket with hierarchical namespace enabled', async () => {
await storage.createBucket(bucket.name, {
hierarchicalNamespace: {enabled: true},
});
const [metadata] = await bucket.getMetadata();
assert(metadata.hierarchicalNamespace);
assert.strictEqual(metadata.hierarchicalNamespace.enabled, true);
});
});

describe('bucket retention policies', () => {
describe('bucket', () => {
it('should create a bucket with a retention policy', async () => {
Expand Down
15 changes: 15 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,21 @@ describe('Storage', () => {
storage.createBucket(BUCKET_NAME, {enableObjectRetention: true}, done);
});

it('should allow enabling hierarchical namespace', done => {
storage.request = (
reqOpts: DecorateRequestOptions,
callback: Function
) => {
assert.strictEqual(reqOpts.json.hierarchicalNamespace.enabled, true);
callback();
};
storage.createBucket(
BUCKET_NAME,
{hierarchicalNamespace: {enabled: true}},
done
);
});

describe('storage classes', () => {
it('should expand metadata.archive', done => {
storage.request = (reqOpts: DecorateRequestOptions) => {
Expand Down
Loading