From 20e5f7734ac0d4c7cd4c6764b74bded5b0a0fc8f Mon Sep 17 00:00:00 2001 From: Luke Hoban Date: Mon, 10 Jun 2019 06:24:38 -0700 Subject: [PATCH] Handle older parent resources When an older pulumi/pulumi is used for a parent than that used for a chid resoruce, it was possible for the `__aliases` property to be undefined. These changes handle that case, and make the recently added private properties of Resource optional to better represent the fact that instances of Resource may not have these values set. --- sdk/nodejs/resource.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sdk/nodejs/resource.ts b/sdk/nodejs/resource.ts index 981ba0271..885f907f3 100644 --- a/sdk/nodejs/resource.ts +++ b/sdk/nodejs/resource.ts @@ -144,14 +144,14 @@ export abstract class Resource { * A list of aliases applied to this resource. */ // tslint:disable-next-line:variable-name - readonly __aliases: Input[]; + readonly __aliases?: Input[]; /** * @internal * The name assigned to the resource at construction. */ // tslint:disable-next-line:variable-name - private readonly __name: string; + private readonly __name?: string; /** * @internal @@ -217,8 +217,10 @@ export abstract class Resource { // Make a copy of the aliases array, and add to it any implicit aliases inherited from its parent opts.aliases = [...(opts.aliases || [])]; - for (const parentAlias of opts.parent.__aliases) { - opts.aliases.push(inheritedChildAlias(name, opts.parent.__name, parentAlias, t)); + for (const parentAlias of (opts.parent.__aliases || [])) { + if (opts.parent.__name) { + opts.aliases.push(inheritedChildAlias(name, opts.parent.__name, parentAlias, t)); + } } this.__providers = opts.parent.__providers;