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

Avoid conflicts with resource attributes called "node" #230

Merged
merged 4 commits into from
Jul 22, 2020
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
10 changes: 5 additions & 5 deletions packages/cdktf/lib/terraform-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export class TerraformElement extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id)

this.node.addMetadata('stacktrace', 'trace')
this.constructNode.addMetadata('stacktrace', 'trace')
this.stack = TerraformStack.of(this);
}

public get node(): Node {
public get constructNode(): Node {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm... Interesting... I am wondering if we should take this into account in constructs 10.x?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential naming conflicts should be a thought of, yes.

return Node.of(this)
}

Expand All @@ -27,17 +27,17 @@ export class TerraformElement extends Construct {
}

public get friendlyUniqueId() {
const node = this.node
const node = this.constructNode
const components = node.scopes.slice(1).map(c => Node.of(c).id);
return components.length > 0 ? makeUniqueId(components) : '';
}

protected get nodeMetadata(): {[key: string]: any} {
return {
metadata: {
path: this.node.path,
path: this.constructNode.path,
uniqueId: this.friendlyUniqueId,
stackTrace: this.node.metadata.find((e) => e.type === 'stacktrace')?.trace
stackTrace: this.constructNode.metadata.find((e) => e.type === 'stacktrace')?.trace
} as TerraformElementMetadata
}
}
Expand Down
5 changes: 2 additions & 3 deletions test/test-providers/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import * as Azure from "./.gen/providers/azurerm";
import * as Google from "./.gen/providers/google";
import * as Kubernetes from "./.gen/providers/kubernetes";
// The following providers still have bugs
// - https://github.com/hashicorp/terraform-cdk/issues/125
// - https://github.com/hashicorp/terraform-cdk/issues/124
//
// import * as Nomad from "./.gen/providers/nomad";
// import * as Vault from "./.gen/providers/vault";
// import * as Consul from "./.gen/providers/consul";
import * as Consul from "./.gen/providers/consul";

export class HelloTerra extends TerraformStack {
constructor(scope: Construct, id: string) {
Expand All @@ -27,7 +26,7 @@ export class HelloTerra extends TerraformStack {
},
]);

[Aws, Azure, Google, Kubernetes];
[Aws, Azure, Google, Kubernetes, Consul];
}
}

Expand Down