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

fast-dinner-32080

03/12/2020, 12:37 AM
How would I add an output and an input value. Basically trying to take a disk size which is provided by an output and add to it an Input value. This isn't possible to do
Copy code
Size = args.VmTemplate.Apply(x => x.Disks[0].Size ) + args.SrvExtendSize
as well as
Copy code
Size = args.VmTemplate.Apply(x => x.Disks[0].Size ) + args.SrvExtendSize.ToOutput()
So I must be missing something
I can call ToString on each and parse them back to an int but that doesn't seem right at all. Is there a special function to do math against outputs and inputs?
s

straight-flower-13757

03/12/2020, 1:29 AM
I think you can do something similar to this:
Copy code
Output.Tuple<?, int>(args.VmTemplate, args.SrvExtendSize).Apply(t => {
   var (template, extendedSize) = t;
   return template.Disks[0].Size + args.SrvExtendSize;
});
that will take both inputs and make sure that both are counted in/awaited if needed before converting them into a single output.
f

fast-dinner-32080

03/12/2020, 1:51 AM
Ah that seems to work.
Copy code
Size = Output.Tuple(args.VmTemplate, args.SrvExtendSize).Apply(t => {
    var (template, extendedSize) = t;
    return template.Disks[0].Size + extendedSize;
}),
It just seems like a lot of work to just add two ints.
Thanks for the reply!!
s

straight-flower-13757

03/12/2020, 1:55 AM
Welcome, been there before 😄