Skip to content

Commit

Permalink
fix linting issues, update tests, fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wulfmann committed Nov 12, 2020
1 parent 7971a6d commit 4abf28f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
19 changes: 16 additions & 3 deletions packages/@aws-cdk/aws-codebuild/lib/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,18 @@ abstract class ProjectBase extends Resource implements IProject {
}
}

/**
* Statuses for Log Configurations
*/
export enum LogStatus {
/**
* Enables the log configuration
*/
ENABLED='ENABLED',

/**
* Disables the log configuration
*/
DISABLED='DISABLED'
}

Expand All @@ -419,6 +429,7 @@ export interface S3LogsConfig {

/**
* The path prefix for S3 logs
* @default - no prefix
*/
readonly prefix?: string;

Expand All @@ -440,6 +451,7 @@ export interface CloudwatchLogsConfig {

/**
* The prefix of the stream name of the Amazon CloudWatch Logs
* @default - no prefix
*/
readonly prefix?: string;

Expand Down Expand Up @@ -1120,10 +1132,11 @@ export class Project extends ProjectBase {

if (props.logsConfig?.s3) {
const s3Logs = props.logsConfig.s3;

s3Config = {
status: s3Logs.status || LogStatus.DISABLED,
status: s3Logs.status || LogStatus.ENABLED,
location: `${s3Logs.bucket.bucketName}${s3Logs.prefix}`,
encryptionDisabled: s3Logs.encrypted || true,
encryptionDisabled: s3Logs.encrypted ?? false,
};
} else {
s3Config = undefined;
Expand All @@ -1132,7 +1145,7 @@ export class Project extends ProjectBase {
if (props.logsConfig?.cloudwatch) {
const cloudWatchLogs = props.logsConfig.cloudwatch;
cloudwatchConfig = {
status: cloudWatchLogs.status || LogStatus.DISABLED,
status: cloudWatchLogs.status || LogStatus.ENABLED,
groupName: cloudWatchLogs.logGroup.logGroupName,
streamName: cloudWatchLogs.prefix,
};
Expand Down
12 changes: 6 additions & 6 deletions packages/@aws-cdk/aws-codebuild/test/test.project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,10 +624,10 @@ export = {
// THEN
expect(stack).to(haveResourceLike('AWS::CodeBuild::Project', {
LogsConfig: objectLike({
S3LogsConfig: {
GroupName: 'MyLogGroup',
StreamName: '/my-logs',
CloudWatchLogs: {
GroupName: 'MyLogGroupName',
Status: 'ENABLED',
StreamName: '/my-logs',
},
}),
}));
Expand All @@ -638,7 +638,7 @@ export = {
'logs config - s3'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const bucket = s3.Bucket.fromBucketName(stack, 'Bucket', 'MyBucketName');
const bucket = s3.Bucket.fromBucketName(stack, 'LogBucket', 'MyBucketName');

// WHEN
new codebuild.Project(stack, 'Project', {
Expand All @@ -657,10 +657,10 @@ export = {
// THEN
expect(stack).to(haveResourceLike('AWS::CodeBuild::Project', {
LogsConfig: objectLike({
S3LogsConfig: {
S3Logs: {
EncryptionDisabled: false,
Location: 'MyBucketName/my-logs',
Status: 'ENABLED',
Encrypted: true,
},
}),
}));
Expand Down

0 comments on commit 4abf28f

Please sign in to comment.