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.
This commit is contained in:
parent
fdc4c64789
commit
20e5f7734a
|
@ -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<URN>[];
|
||||
readonly __aliases?: Input<URN>[];
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
|
Loading…
Reference in a new issue