This message was deleted.
# general
s
This message was deleted.
l
Anything with "Output" in its type is not available now, only in the future. You either need to wait for it, or use it in a callback that gets called later, when it's available.
The basic documentation is at https://www.pulumi.com/docs/intro/concepts/inputs-outputs/. Look for
ApplyT()
.
r
that's the part i'm having trouble with =/ the docs say it's supposed to support "lifting" but the only example it gives is pulling some element from an array, but that same idea doesn't seem to work with getting a
string
from a
pulumi.StringOutput
as far as i can tell there's nothing on this that will return a
string
https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v3/go/pulumi#StringOutput, and the inner
*OutputState
only seems to include
ApplyT
, which just returns another
pulumi.Output
.
l
Yes, the string is not available yet, you cannot get at it.
r
there has to be some way for me to get it, though. otherwise I could never use an output as a lookup for a resource, right?
l
Did you read the link I posted above, and the code snippet with ApplyT()?
You put your code inside that callback. The callback is called later, when the value is available
r
yeah, that's what i've been trying
l
⬅️ Post your code. Use the "Create a text snippet" function in Slack's "+" menu.
r
I've tried a lot of iterations of trying to get a value for
Name
, which requires a
*string
.
ahh, i think i got it. i need to use
digitalocean.LookupProjectOutput
which will accept and return input/output types
l
Ah, if there's an Output version of a parameter, that definitely helps!
r
yup! i'd definitely like to figure out this problem I'm having at some point, though. the way things are explained it sounds like what I've been doing should work, but it's not. so it makes me feel like the go code is some weird edge case
l
For the ApplyT() in that code you posted: you should need the ApplyT() in this case. Because the Name parameter should take an output, you don't need to convert the name output. You should be able to use it directly. It does look like everything's good...
r
yeah, if i get rid of the
ApplyT
on there it'll complain that it can't assign
pulumi.StringOutput
or
pulumi.StringPtrOutput
(I tried both) to a
*string
l
But nothing in there is a string, is it?
Name
should be an Input, and
projName
is an Output. I guess my golang is not up to this problem.. I should stick with typescript...
r
i do feel like it's some weirdness with the go type system. there are
pulumi.Output
values, but those are subdivided into
pulumi.StringOutput
, etc. and then if I try to convert a
pulumi.StringOutput
to a
string
by just doing something like
var myString string = myStringOutput
it sounds like that should work, but it doesn't
l
No, that won't ever work. The StringOutput isn't yet known, it's a promise / future. You cannot convert it to a string.
You can get your code to be called later, when the value is known. That's the best you can do.
r
yeah, that's what i meant. like somehow make it block and return a
string
i think this update to use the lookup outputs is way better, so I don't know if I'll ever want that now though 😄
b
just doing something like
var myString string = myStringOutput
it sounds like that should work, but it doesn’t
yeah that unfortunately won’t ever work. You can’t assign an
StringOutput
to a
string
unless you are inside the
ApplyT
. so as an example:
Copy code
// here myOutputValue is always an output
myOutputValueApplyT(func(myOutput string) string {
  // here, we are inside the ApplyT function, so we have resolved the value and now it's a string
  fmt.Println(myOutput)
}