https://pulumi.com logo
#dotnet
Title
# dotnet
p

powerful-football-81694

01/16/2020, 6:13 PM
Hi again folks! Another question around mapping/transformation of outputs to inputs: How can I accomplish an
Output.Format()
if my format string is not a string interpolation inline in code, but instead a composite format string (containing
{0}
placeholders) that is fetched from an external source (such as an environment variable)?
If there is just one
Input
I suppose I could call
String.Format()
inside an
.Apply()
on that input.
But in my case there are multiple
Input
that each correspond to a placeholder in the composite format string.
w

white-balloon-205

01/16/2020, 8:44 PM
Right - the answer is effectively always
.Apply
. And if you have multiple inputs
.All().Apply()
. Other things (like
Output.Format
) are effectively all just sugar for common cases - but if your case falls outside of those - you want
.Apply
and maybe
.All
.
👍 1
p

powerful-football-81694

01/16/2020, 8:48 PM
Thanks @white-balloon-205! It’s all slowly beginning to make sense.
t

tall-librarian-49374

01/16/2020, 8:51 PM
Copy code
var a = Output.Create("a");
var b = Output.Create("b");
var c = "{0}+{1}";
var d = Output.All<string>(a, b).Apply(vs => string.Format(c, vs.ToArray()));
1
Doesn’t look great but should work
p

powerful-football-81694

01/16/2020, 8:52 PM
Makes perfect sense @tall-librarian-49374 - thanks!