Skip to content

Commit

Permalink
remove stack and stage private fields from GuStack
Browse files Browse the repository at this point in the history
These can be replaced with the new getParam helper.
  • Loading branch information
akash1810 committed Feb 12, 2021
1 parent c913f5d commit c1f0888
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/constructs/core/parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export class GuStringParameter extends GuParameter {
}

export class GuStageParameter extends GuParameter {
constructor(scope: GuStack, id: string = "Stage") {
public static readonly defaultId = "Stage";
constructor(scope: GuStack, id: string = GuStageParameter.defaultId) {
super(scope, id, {
type: "String",
description: "Stage name",
Expand All @@ -41,7 +42,8 @@ export class GuStageParameter extends GuParameter {
}

export class GuStackParameter extends GuParameter {
constructor(scope: GuStack, id: string = "Stack") {
public static readonly defaultId = "Stack";
constructor(scope: GuStack, id: string = GuStackParameter.defaultId) {
super(scope, id, {
type: "String",
description: "Name of this stack",
Expand Down
10 changes: 4 additions & 6 deletions src/constructs/core/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,18 @@ export interface GuStackProps extends StackProps {
* ```
*/
export class GuStack extends Stack {
private readonly _stage: GuStageParameter;
private readonly _stack: GuStackParameter;
private readonly _app: string;

private params: Map<string, GuParameter>;

public readonly migratedFromCloudFormation: boolean;

get stage(): string {
return this._stage.valueAsString;
return this.getParam(GuStageParameter.defaultId).valueAsString;
}

get stack(): string {
return this._stack.valueAsString;
return this.getParam(GuStackParameter.defaultId).valueAsString;
}

get app(): string {
Expand Down Expand Up @@ -95,8 +93,8 @@ export class GuStack extends Stack {

this.params = new Map<string, GuParameter>();

this._stage = new GuStageParameter(this);
this._stack = new GuStackParameter(this);
new GuStageParameter(this);
new GuStackParameter(this);
this._app = props.app;

this.addTag(TrackingTag.Key, TrackingTag.Value);
Expand Down

0 comments on commit c1f0888

Please sign in to comment.