Skip to content

Commit

Permalink
add feedback from Luca
Browse files Browse the repository at this point in the history
  • Loading branch information
msambol committed Nov 6, 2023
1 parent d066055 commit 0d0c990
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/@aws-cdk/aws-glue-alpha/lib/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export interface DatabaseProps {
readonly locationUri?: string;

/**
* The description of the database.
* A description of the database.
*
* @default - none.
* @default - no database description
*/
readonly description?: string;
}
Expand Down Expand Up @@ -94,12 +94,6 @@ export class Database extends Resource implements IDatabase {
* Location URI of this database.
*/
public readonly locationUri?: string;

/**
* Description of this database.
*/
public readonly description?: string;

constructor(scope: Construct, id: string, props: DatabaseProps = {}) {
super(scope, id, {
physicalName: props.databaseName ??
Expand All @@ -108,11 +102,13 @@ export class Database extends Resource implements IDatabase {
}),
});

this.description = props.description;
if (props.description !== undefined) {
validateDescription(props.description);
}

let databaseInput: CfnDatabase.DatabaseInputProperty = {
name: this.physicalName,
description: this.description,
description: props.description,
};

if (props.locationUri !== undefined) {
Expand Down Expand Up @@ -151,3 +147,9 @@ function validateLocationUri(locationUri: string): void {
throw new Error(`locationUri length must be (inclusively) between 1 and 1024, but was ${locationUri.length}`);
}
}

function validateDescription(description: string): void {
if (description.length > 2048) {
throw new Error(`description length must be less than or equal to 2048, but was ${description.length}`);
}
}
8 changes: 8 additions & 0 deletions packages/@aws-cdk/aws-glue-alpha/test/database.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ test('locationUri length must be <= 1024', () => {
).toThrow();
});

test('description length must be <= 2048', () => {
expect(() =>
new glue.Database(stack, 'Database', {
description: 'a'.repeat(2049),
}),
).toThrow();
});

test('can specify a physical name', () => {
new glue.Database(stack, 'Database', {
databaseName: 'my_database',
Expand Down

0 comments on commit 0d0c990

Please sign in to comment.