https://pulumi.com logo
#general
Title
# general
r

rapid-lamp-57703

03/18/2020, 8:55 AM
Hi guys - I'm like a dog with a bone sometimes.. Just experimenting... and i wondered.. ok so i can upload a folder full of arbitary files - fine - but what if i wanted to output and array of the Uri strings... so I am trying to create an [Output] of type Immutable Array. I've tried shoving all sorts into it.. now I am just trying static test to POC it.. but it still doesn't work.
[Output]
public Output<ImmutableArray<string>> UploadedUri { get; set; } = Output.Create(ImmutableArray.Create<string>("123"));
Any tips or pointers? how do i get an array of things? I've seen dictionary before.. but not list/array.
t

tall-librarian-49374

03/18/2020, 9:08 AM
LGTM. What’s the error?
r

rapid-lamp-57703

03/18/2020, 9:27 AM
Stack trace about the types only being allow to be immutable types... I have further simplified it.. and I have some output... now i need to increase the complexity and have it return more than "123" 🙂
This is the stack trace - but I wouldn't worry about it as i am inching forward again now.
ok so i have experimented and gotten my list and dict of strings being output... the drama I have is i want my SourceUri from Blob in the array. I can't seem to access the underlying string in those Output<string> and when i try and create a list of Output<string> i get an error... any tips?
public Output<ImmutableArray<Output<string>>> UploadedUri { get; set; }
i am guessing that i want that to just be public Output<ImmutableArray<string>> UploadedUri { get; set; } - but to do that i need to get at the strings hidden behind uploadedFile.SourceUri;
I've achieved what i wanted to do by changing the types within my array from Output<string> to object? eg public Output<ImmutableArray<object?>> UploadedUri { get; set; } instead of public Output<ImmutableArray<Output<string>> UploadedUri { get; set; } Jonathh  [4:45 PM] it seems to be the way as the examples return dicts of <string, object?> - it is quite messy.... but works i guess
t

tall-librarian-49374

03/18/2020, 5:23 PM
Output<ImmutableArray<Output<string>>
doesn’t sound right to me. You should be able to process whatever you have to
Output<ImmutableArray<string>>
. Flatten the output.
r

rapid-lamp-57703

03/19/2020, 12:55 PM
i can't get access to the string behind the outputs - is problem number one
so I have a Output<String> that i want to put into an array of strings. how do i get the string out?
the object? works btw.. it is just messy.
t

tall-librarian-49374

03/19/2020, 2:13 PM
So I don’t have your code but this may help:
Copy code
Output<ImmutableArray<Output<string>>> notGood =
    Output.Create(new[] {Output.Create("1"), Output.Create("2")}.ToImmutableArray());
Output<ImmutableArray<string>> better = notGood.Apply(vs =>
     Output.All(vs.Select(v => (Input<string>)v).ToImmutableArray()));
It turns out that
Output.All
doesn’t accept outputs… We should probably add an overload for that.
r

rapid-lamp-57703

03/19/2020, 2:16 PM
thanks - i'll take a look at that.. the array of outputs does work.. but you have to 'mask' the inner outputs as objects if that makes sense
t

tall-librarian-49374

03/19/2020, 2:20 PM
It just feels wrong to me 😉