https://pulumi.com logo
Title
c

creamy-nail-67991

09/10/2021, 7:59 AM
Hi, I am looking to convert InputList<T> to InputList<Union<string, T>>. I have written the following code to do it but at least in my mind this conversion should be automatic under some operator. I understand that T for Input<T> / Output<T> is opaque but I want to make sure I am not missing something
InputList<Union<string, FrontDoorProtocol>> protocols = new InputList<Union<string, FrontDoorProtocol>>();
await foreach (var protocol in acceptedProtocols)
{
	protocols.Add(protocol);
}
return protocols;
1
b

bumpy-grass-54508

09/10/2021, 1:29 PM
i think you can do it with Apply instead of async/await - something like
InputList<string> acceptedProtocols = ...

InputList<Union<string, FrontDoorProtocol>> protocols = acceptedProtocols.Apply(list =>
   list.Select(x => buildUnion(x, ...));
c

creamy-nail-67991

09/10/2021, 2:28 PM
Thank you @bumpy-grass-54508 I think this will work. I completely missed the fact that has a
Union.From()
factory method
👍 1
AcceptedProtocols = rule.AcceptedProtocols.Apply(protocolArray => protocolArray.Select(Union<string, FrontDoorProtocol>.FromT1))
Just for completeness in case someone else looks that thread.