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

refactor: update all enum members to be ALL_CAPS - part II #2989

Merged
merged 5 commits into from
Jun 21, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ export class PipelineDeployStackAction extends cdk.Construct {
function cfnCapabilities(adminPermissions: boolean, capabilities?: cfn.CloudFormationCapabilities[]): cfn.CloudFormationCapabilities[] {
if (adminPermissions && capabilities === undefined) {
// admin true default capability to NamedIAM and AutoExpand
return [cfn.CloudFormationCapabilities.NamedIAM, cfn.CloudFormationCapabilities.AutoExpand];
return [cfn.CloudFormationCapabilities.NAMED_IAM, cfn.CloudFormationCapabilities.AUTO_EXPAND];
} else if (capabilities === undefined) {
// else capabilities are undefined set AnonymousIAM and AutoExpand
return [cfn.CloudFormationCapabilities.AnonymousIAM, cfn.CloudFormationCapabilities.AutoExpand];
return [cfn.CloudFormationCapabilities.ANONYMOUS_IAM, cfn.CloudFormationCapabilities.AUTO_EXPAND];
} else {
// else capabilities are defined use them
return capabilities;
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/app-delivery/test/integ.cicd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const app = new cdk.App();
const stack = new cdk.Stack(app, 'CICD');
const pipeline = new codepipeline.Pipeline(stack, 'CodePipeline', {
artifactBucket: new s3.Bucket(stack, 'ArtifactBucket', {
removalPolicy: cdk.RemovalPolicy.Destroy
removalPolicy: cdk.RemovalPolicy.DESTROY
})
});
const sourceOutput = new codepipeline.Artifact('Artifact_CICDGitHubF8BA7ADD');
Expand All @@ -19,7 +19,7 @@ const source = new cpactions.GitHubSourceAction({
owner: 'awslabs',
repo: 'aws-cdk',
oauthToken: cdk.SecretValue.plainText('DummyToken'),
trigger: cpactions.GitHubTrigger.Poll,
trigger: cpactions.GitHubTrigger.POLL,
output: sourceOutput,
});
pipeline.addStage({
Expand All @@ -35,7 +35,7 @@ new cicd.PipelineDeployStackAction(stack, 'DeployStack', {
executeChangeSetRunOrder: 999,
input: sourceOutput,
adminPermissions: false,
capabilities: [cfn.CloudFormationCapabilities.None],
capabilities: [cfn.CloudFormationCapabilities.NONE],
});

app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -106,35 +106,35 @@ export = nodeunit.testCase({
stage: selfUpdateStage1,
stack: pipelineStack,
input: selfUpdatingStack.synthesizedApp,
capabilities: [cfn.CloudFormationCapabilities.NamedIAM],
capabilities: [cfn.CloudFormationCapabilities.NAMED_IAM],
adminPermissions: false,
});
new PipelineDeployStackAction(pipelineStack, 'DeployStack', {
stage: selfUpdateStage2,
stack: stackWithNoCapability,
input: selfUpdatingStack.synthesizedApp,
capabilities: [cfn.CloudFormationCapabilities.None],
capabilities: [cfn.CloudFormationCapabilities.NONE],
adminPermissions: false,
});
new PipelineDeployStackAction(pipelineStack, 'DeployStack2', {
stage: selfUpdateStage3,
stack: stackWithAnonymousCapability,
input: selfUpdatingStack.synthesizedApp,
capabilities: [cfn.CloudFormationCapabilities.AnonymousIAM],
capabilities: [cfn.CloudFormationCapabilities.ANONYMOUS_IAM],
adminPermissions: false,
});
new PipelineDeployStackAction(pipelineStack, 'DeployStack3', {
stage: selfUpdateStage4,
stack: stackWithAutoExpandCapability,
input: selfUpdatingStack.synthesizedApp,
capabilities: [cfn.CloudFormationCapabilities.AutoExpand],
capabilities: [cfn.CloudFormationCapabilities.AUTO_EXPAND],
adminPermissions: false,
});
new PipelineDeployStackAction(pipelineStack, 'DeployStack4', {
stage: selfUpdateStage5,
stack: stackWithAnonymousAndAutoExpandCapability,
input: selfUpdatingStack.synthesizedApp,
capabilities: [cfn.CloudFormationCapabilities.AnonymousIAM, cfn.CloudFormationCapabilities.AutoExpand],
capabilities: [cfn.CloudFormationCapabilities.ANONYMOUS_IAM, cfn.CloudFormationCapabilities.AUTO_EXPAND],
adminPermissions: false,
});
expect(pipelineStack).to(haveResource('AWS::CodePipeline::Pipeline', hasPipelineAction({
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assert/test/test.have-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export = {
function mkStack(template: any): cxapi.CloudFormationStackArtifact {
const assembly = new cxapi.CloudAssemblyBuilder();
assembly.addArtifact('test', {
type: cxapi.ArtifactType.AwsCloudFormationStack,
type: cxapi.ArtifactType.AWS_CLOUDFORMATION_STACK,
environment: cxapi.EnvironmentUtils.format('123456789', 'us-west-2'),
properties: {
templateFile: 'template.json'
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/assets/lib/fs/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FollowMode } from './follow-mode';
import { shouldExclude, shouldFollow } from './utils';

export function copyDirectory(srcDir: string, destDir: string, options: CopyOptions = { }, rootDir?: string) {
const follow = options.follow !== undefined ? options.follow : FollowMode.External;
const follow = options.follow !== undefined ? options.follow : FollowMode.EXTERNAL;
const exclude = options.exclude || [];

rootDir = rootDir || srcDir;
Expand All @@ -24,7 +24,7 @@ export function copyDirectory(srcDir: string, destDir: string, options: CopyOpti

const destFilePath = path.join(destDir, file);

let stat: fs.Stats | undefined = follow === FollowMode.Always
let stat: fs.Stats | undefined = follow === FollowMode.ALWAYS
? fs.statSync(sourceFilePath)
: fs.lstatSync(sourceFilePath);

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assets/lib/fs/fingerprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface FingerprintOptions extends CopyOptions {
export function fingerprint(fileOrDirectory: string, options: FingerprintOptions = { }) {
const hash = crypto.createHash('sha256');
_hashField(hash, 'options.extra', options.extra || '');
const follow = options.follow || FollowMode.External;
const follow = options.follow || FollowMode.EXTERNAL;
_hashField(hash, 'options.follow', follow);

const rootDirectory = fs.statSync(fileOrDirectory).isDirectory()
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/assets/lib/fs/follow-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ export enum FollowMode {
/**
* Never follow symlinks.
*/
Never = 'never',
NEVER = 'never',

/**
* Materialize all symlinks, whether they are internal or external to the source directory.
*/
Always = 'always',
ALWAYS = 'always',

/**
* Only follows symlinks that are external to the source directory.
*/
External = 'external',
EXTERNAL = 'external',

// ----------------- TODO::::::::::::::::::::::::::::::::::::::::::::
/**
Expand All @@ -25,5 +25,5 @@ export enum FollowMode {
*
* If the copy operation runs into an external symlink, it will fail.
*/
BlockExternal = 'internal-only',
BLOCK_EXTERNAL = 'internal-only',
}
8 changes: 4 additions & 4 deletions packages/@aws-cdk/assets/lib/fs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ export function shouldExclude(exclude: string[], filePath: string): boolean {
*/
export function shouldFollow(mode: FollowMode, sourceRoot: string, realPath: string): boolean {
switch (mode) {
case FollowMode.Always:
case FollowMode.ALWAYS:
return fs.existsSync(realPath);
case FollowMode.External:
case FollowMode.EXTERNAL:
return !_isInternal() && fs.existsSync(realPath);
case FollowMode.BlockExternal:
case FollowMode.BLOCK_EXTERNAL:
return _isInternal() && fs.existsSync(realPath);
case FollowMode.Never:
case FollowMode.NEVER:
return false;
default:
throw new Error(`Unsupported FollowMode: ${mode}`);
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/assets/test/fs/test.fs-copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export = {

// WHEN
copyDirectory(path.join(__dirname, 'fixtures', 'symlinks'), outdir, {
follow: FollowMode.Always
follow: FollowMode.ALWAYS
});

// THEN
Expand All @@ -60,7 +60,7 @@ export = {

// WHEN
copyDirectory(path.join(__dirname, 'fixtures', 'symlinks'), outdir, {
follow: FollowMode.Never
follow: FollowMode.NEVER
});

// THEN
Expand All @@ -83,7 +83,7 @@ export = {

// WHEN
copyDirectory(path.join(__dirname, 'fixtures', 'symlinks'), outdir, {
follow: FollowMode.External
follow: FollowMode.EXTERNAL
});

// THEN
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/assets/test/fs/test.fs-fingerprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ export = {
// now dir2 contains a symlink to a file in dir1

// WHEN
const original = libfs.fingerprint(dir2, { follow: libfs.FollowMode.Never });
const original = libfs.fingerprint(dir2, { follow: libfs.FollowMode.NEVER });

// now change the contents of the target
fs.writeFileSync(target, 'changning you!');
const afterChange = libfs.fingerprint(dir2, { follow: libfs.FollowMode.Never });
const afterChange = libfs.fingerprint(dir2, { follow: libfs.FollowMode.NEVER });

// revert the content to original and expect hash to be reverted
fs.writeFileSync(target, content);
const afterRevert = libfs.fingerprint(dir2, { follow: libfs.FollowMode.Never });
const afterRevert = libfs.fingerprint(dir2, { follow: libfs.FollowMode.NEVER });

// THEN
test.deepEqual(original, afterChange);
Expand Down
24 changes: 12 additions & 12 deletions packages/@aws-cdk/assets/test/fs/test.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export = {

const mockFsExists = ImportMock.mockFunction(fs, 'existsSync', true);
try {
test.ok(util.shouldFollow(FollowMode.Always, sourceRoot, linkTarget));
test.ok(util.shouldFollow(FollowMode.ALWAYS, sourceRoot, linkTarget));
test.ok(mockFsExists.calledOnceWith(linkTarget));
test.done();
} finally {
Expand All @@ -47,7 +47,7 @@ export = {
const linkTarget = path.join('alternate', 'referent');
const mockFsExists = ImportMock.mockFunction(fs, 'existsSync', true);
try {
test.ok(util.shouldFollow(FollowMode.Always, sourceRoot, linkTarget));
test.ok(util.shouldFollow(FollowMode.ALWAYS, sourceRoot, linkTarget));
test.ok(mockFsExists.calledOnceWith(linkTarget));
test.done();
} finally {
Expand All @@ -60,7 +60,7 @@ export = {
const linkTarget = path.join(sourceRoot, 'referent');
const mockFsExists = ImportMock.mockFunction(fs, 'existsSync', false);
try {
test.ok(!util.shouldFollow(FollowMode.Always, sourceRoot, linkTarget));
test.ok(!util.shouldFollow(FollowMode.ALWAYS, sourceRoot, linkTarget));
test.ok(mockFsExists.calledOnceWith(linkTarget));
test.done();
} finally {
Expand All @@ -73,7 +73,7 @@ export = {
const linkTarget = path.join('alternate', 'referent');
const mockFsExists = ImportMock.mockFunction(fs, 'existsSync', false);
try {
test.ok(!util.shouldFollow(FollowMode.Always, sourceRoot, linkTarget));
test.ok(!util.shouldFollow(FollowMode.ALWAYS, sourceRoot, linkTarget));
test.ok(mockFsExists.calledOnceWith(linkTarget));
test.done();
} finally {
Expand All @@ -88,7 +88,7 @@ export = {
const linkTarget = path.join(sourceRoot, 'referent');
const mockFsExists = ImportMock.mockFunction(fs, 'existsSync');
try {
test.ok(!util.shouldFollow(FollowMode.External, sourceRoot, linkTarget));
test.ok(!util.shouldFollow(FollowMode.EXTERNAL, sourceRoot, linkTarget));
test.ok(mockFsExists.notCalled);
test.done();
} finally {
Expand All @@ -101,7 +101,7 @@ export = {
const linkTarget = path.join('alternate', 'referent');
const mockFsExists = ImportMock.mockFunction(fs, 'existsSync', true);
try {
test.ok(util.shouldFollow(FollowMode.External, sourceRoot, linkTarget));
test.ok(util.shouldFollow(FollowMode.EXTERNAL, sourceRoot, linkTarget));
test.ok(mockFsExists.calledOnceWith(linkTarget));
test.done();
} finally {
Expand All @@ -114,7 +114,7 @@ export = {
const linkTarget = path.join('alternate', 'referent');
const mockFsExists = ImportMock.mockFunction(fs, 'existsSync', false);
try {
test.ok(!util.shouldFollow(FollowMode.External, sourceRoot, linkTarget));
test.ok(!util.shouldFollow(FollowMode.EXTERNAL, sourceRoot, linkTarget));
test.ok(mockFsExists.calledOnceWith(linkTarget));
test.done();
} finally {
Expand All @@ -129,7 +129,7 @@ export = {
const linkTarget = path.join(sourceRoot, 'referent');
const mockFsExists = ImportMock.mockFunction(fs, 'existsSync', true);
try {
test.ok(util.shouldFollow(FollowMode.BlockExternal, sourceRoot, linkTarget));
test.ok(util.shouldFollow(FollowMode.BLOCK_EXTERNAL, sourceRoot, linkTarget));
test.ok(mockFsExists.calledOnceWith(linkTarget));
test.done();
} finally {
Expand All @@ -142,7 +142,7 @@ export = {
const linkTarget = path.join(sourceRoot, 'referent');
const mockFsExists = ImportMock.mockFunction(fs, 'existsSync', false);
try {
test.ok(!util.shouldFollow(FollowMode.BlockExternal, sourceRoot, linkTarget));
test.ok(!util.shouldFollow(FollowMode.BLOCK_EXTERNAL, sourceRoot, linkTarget));
test.ok(mockFsExists.calledOnceWith(linkTarget));
test.done();
} finally {
Expand All @@ -155,7 +155,7 @@ export = {
const linkTarget = path.join('alternate', 'referent');
const mockFsExists = ImportMock.mockFunction(fs, 'existsSync');
try {
test.ok(!util.shouldFollow(FollowMode.BlockExternal, sourceRoot, linkTarget));
test.ok(!util.shouldFollow(FollowMode.BLOCK_EXTERNAL, sourceRoot, linkTarget));
test.ok(mockFsExists.notCalled);
test.done();
} finally {
Expand All @@ -170,7 +170,7 @@ export = {
const linkTarget = path.join(sourceRoot, 'referent');
const mockFsExists = ImportMock.mockFunction(fs, 'existsSync');
try {
test.ok(!util.shouldFollow(FollowMode.Never, sourceRoot, linkTarget));
test.ok(!util.shouldFollow(FollowMode.NEVER, sourceRoot, linkTarget));
test.ok(mockFsExists.notCalled);
test.done();
} finally {
Expand All @@ -183,7 +183,7 @@ export = {
const linkTarget = path.join('alternate', 'referent');
const mockFsExists = ImportMock.mockFunction(fs, 'existsSync');
try {
test.ok(!util.shouldFollow(FollowMode.Never, sourceRoot, linkTarget));
test.ok(!util.shouldFollow(FollowMode.NEVER, sourceRoot, linkTarget));
test.ok(mockFsExists.notCalled);
test.done();
} finally {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class Deployment extends Resource {
});

if (props.retainDeployments) {
this.resource.options.deletionPolicy = CfnDeletionPolicy.Retain;
this.resource.options.deletionPolicy = CfnDeletionPolicy.RETAIN;
}

this.api = props.api;
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/usage-plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export interface ThrottlingPerMethod {
* Type of Usage Plan Key. Currently the only supported type is 'ApiKey'
*/
export enum UsagePlanKeyType {
ApiKey = 'API_KEY'
API_KEY = 'API_KEY'
}

/**
Expand Down Expand Up @@ -181,7 +181,7 @@ export class UsagePlan extends Resource {
public addApiKey(apiKey: IApiKey): void {
new CfnUsagePlanKey(this, 'UsagePlanKeyResource', {
keyId: apiKey.keyId,
keyType: UsagePlanKeyType.ApiKey,
keyType: UsagePlanKeyType.API_KEY,
usagePlanId: this.usagePlanId
});
}
Expand Down
Loading