Skip to content

Commit

Permalink
reverting app and stack changes
Browse files Browse the repository at this point in the history
  • Loading branch information
moofish32 committed Oct 28, 2018
1 parent 0e3ab2b commit 932bde9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 78 deletions.
6 changes: 1 addition & 5 deletions packages/@aws-cdk/cdk/lib/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@ import fs = require('fs');
import path = require('path');
import { Stack } from './cloudformation/stack';
import { Construct, MetadataEntry, PATH_SEP, Root } from './core/construct';
import { ITaggable, TagManager } from './core/tag-manager';
import { resolve } from './core/tokens';

/**
* Represents a CDK program.
*/
export class App extends Root implements ITaggable {

public readonly tags: TagManager;
export class App extends Root {
/**
* Initializes a CDK application.
* @param request Optional toolkit request (e.g. for tests)
*/
constructor() {
super();
this.loadContext();
this.tags = new TagManager(this);
}

private get stacks() {
Expand Down
18 changes: 1 addition & 17 deletions packages/@aws-cdk/cdk/lib/cloudformation/stack.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import cxapi = require('@aws-cdk/cx-api');
import { App } from '../app';
import { Construct, PATH_SEP } from '../core/construct';
import { ITaggable, TagManager, Tags } from '../core/tag-manager';
import { resolve, Token } from '../core/tokens';
import { Environment } from '../environment';
import { CloudFormationToken } from './cloudformation-token';
Expand All @@ -23,18 +22,12 @@ export interface StackProps {
* Optional. If not supplied, the HashedNamingScheme will be used.
*/
namingScheme?: IAddressingScheme;

/**
* Tags for the Constructs of this stack
*/
tags?: Tags;
}

/**
* A root construct which represents a single CloudFormation stack.
*/
export class Stack extends Construct implements ITaggable {

export class Stack extends Construct {
/**
* Traverses the tree and looks up for the Stack root.
* @param node A construct in the tree
Expand Down Expand Up @@ -99,11 +92,6 @@ export class Stack extends Construct implements ITaggable {
*/
public readonly name: string;

/**
* Tag Manager for this Stack
*/
public readonly tags: TagManager;

/**
* Creates a new stack.
*
Expand All @@ -118,10 +106,6 @@ export class Stack extends Construct implements ITaggable {

this.logicalIds = new LogicalIDs(props && props.namingScheme ? props.namingScheme : new HashedAddressingScheme());
this.name = name || 'Stack';
const tags = props ? props.tags || {} : {};
this.tags = new TagManager(this, {
initialTags: tags,
});
}

/**
Expand Down
35 changes: 1 addition & 34 deletions packages/@aws-cdk/cdk/test/cloudformation/test.stack.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Test } from 'nodeunit';
import { App, Condition, Construct, Include, ITaggable,
Output, Parameter, Resource, Root, Stack, TagManager, Token } from '../../lib';
import { App, Condition, Construct, Include, Output, Parameter, Resource, Root, Stack, Token } from '../../lib';

export = {
'a stack can be serialized into a CloudFormation template, initially it\'s empty'(test: Test) {
Expand Down Expand Up @@ -190,30 +189,6 @@ export = {

test.done();
},
'Stack Tags can be propagated to children Contructs'(test: Test) {
// GIVEN

// default is propagate
const stack = new Stack(undefined, 'Name', {tags: {
TagKey: 'TagValue',
}});
stack.tags.setTag('TagKey2', 'TagValue2', { propagate: true });
// this tag basically disappears until we implement stack level tags
stack.tags.setTag('TagKey3', 'TagValue3', { propagate: false});

// WHEN

const taggedConstruct = new TaggableConstruct(stack, 'Taggable');

// THEN

test.deepEqual(taggedConstruct.tags.resolve(), [
{key: 'TagKey', value: 'TagValue'},
{key: 'TagKey2', value: 'TagValue2'},
]);

test.done();
}
};

class StackWithPostProcessor extends Stack {
Expand All @@ -231,11 +206,3 @@ class StackWithPostProcessor extends Stack {
return template;
}
}

class TaggableConstruct extends Construct implements ITaggable {
public readonly tags: TagManager;
constructor(parent: Construct, name: string) {
super(parent, name);
this.tags = new TagManager(parent);
}
}
24 changes: 2 additions & 22 deletions packages/@aws-cdk/cdk/test/test.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs = require('fs');
import { Test } from 'nodeunit';
import os = require('os');
import path = require('path');
import { Construct, ITaggable, Resource, Stack, StackProps, TagManager } from '../lib';
import { Construct, Resource, Stack, StackProps } from '../lib';
import { App } from '../lib/app';

function withApp(context: { [key: string]: any } | undefined, block: (app: App) => void) {
Expand Down Expand Up @@ -266,31 +266,11 @@ export = {

test.done();
},
'App Tags can be propagated to all Stacks in the app'(test: Test) {
// Given

const app = new App();
app.tags.setTag('AppName', 'MyApp');

// WHEN
const stack = new Stack(app, 'MyStack');
const stack2 = new Stack(app, 'MyStack2');
const construct = new MyConstruct(stack, 'Mine');
const construct2 = new MyConstruct(stack2, 'Stack2');

// Then
test.deepEqual(construct.tags.resolve(), [{key: 'AppName', value: 'MyApp'}]);
test.deepEqual(construct2.tags.resolve(), [{key: 'AppName', value: 'MyApp'}]);
test.done();
},
};

class MyConstruct extends Construct implements ITaggable {
public readonly tags: TagManager;

class MyConstruct extends Construct {
constructor(parent: Construct, name: string) {
super(parent, name);
this.tags = new TagManager(parent);

new Resource(this, 'r1', { type: 'ResourceType1' });
new Resource(this, 'r2', { type: 'ResourceType2', properties: { FromContext: this.getContext('ctx1') } });
Expand Down

0 comments on commit 932bde9

Please sign in to comment.