dazzling-oxygen-84405
09/29/2024, 12:31 PMpulumi.output
doesn't work on classes, e.g. in pulumi.output(new URL()).apply(url => ...)
inside the apply, url
is no longer an instance of URL
, but just a plain object.little-cartoon-10569
09/29/2024, 7:23 PMdazzling-oxygen-84405
09/29/2024, 7:28 PMif (Object.getPrototypeOf(x) == Object.prototype) {
// Is a plain-old-object, recurse into values (existing logic)
} else {
// Is a custom class, don't recurse (new)
}
little-cartoon-10569
09/29/2024, 7:35 PMlittle-cartoon-10569
09/29/2024, 7:38 PMObject.getPrototypeOf(url) == (new URL()).prototype
would be the right check?little-cartoon-10569
09/29/2024, 7:38 PMdazzling-oxygen-84405
09/29/2024, 7:41 PMpulumi.output
function, not my code. I expect to be able to do this:
function foo(x: pulumi.Input<URL>) {
pulumi.output(x).apply(url => /* use url as an instance of URL() here */ )
}
and it currently doesn't work.dazzling-oxygen-84405
09/29/2024, 7:42 PM.apply()
, url
is a plain old object, not an instance of URL
. Because pulumi.output
strips the prototype information. I don't think this is intentional, hence the bug report.little-cartoon-10569
09/29/2024, 7:45 PMdazzling-oxygen-84405
09/29/2024, 7:56 PMprototype
is the class definition), then pulumi shouldn't try to recursively unwrap it, and just treat it as opaque.dazzling-oxygen-84405
09/29/2024, 7:57 PMlittle-cartoon-10569
09/29/2024, 7:57 PMlittle-cartoon-10569
09/29/2024, 8:02 PMnew MyResource().nestedResource
is an Output<MyComponentResource>
then I guess we wouldn't want it unwrapped.
Tough one.