Hello , everyone , I would like to know how to use...
# general
o
Hello , everyone , I would like to know how to use
OutPut.unsecret
, I found some test case in
sdk/python/lib/test/test_next_serialize.py
.
Copy code
class OutputSecretTests(unittest.TestCase):
    @pulumi_test
    async def test_secret(self):
        x = Output.secret("foo")
        is_secret = await x.is_secret()
        self.assertTrue(is_secret)

    @pulumi_test
    async def test_unsecret(self):
        x = Output.secret("foo")
        x_is_secret = await x.is_secret()
        self.assertTrue(x_is_secret)

        y = Output.unsecret(x)
        y_val = await y.future()
        y_is_secret = await y.is_secret()
        self.assertEqual(y_val, "foo")
        self.assertFalse(y_is_secret)
but there are not async function in my pulumi script , I’m not using asynchronous, I don’t know how to use this.
And I find the link https://stackoverflow.com/questions/72660797/get-value-of-pulumi-secret How about this method compare to
unsecret
?
e
Generally if you need to get the value of an Output you should be using
apply
a
Hey everyone, a side question here. I've once in Python stumbled upon
apply(lambda _: _)
not working on an (eventually) string output (blaming me for using
__str__
on Outputs, that kind of message) but
Output.concat
working well with this output. In the first case I've tried to interpolate
f"{output}"
, and got error message instead of value. The issue is thus solved for me, but I've just wondered, how that's possible?)
o
@echoing-dinner-19531 oh I see . By the way , I would like to know which scenario dose
unsecret
apply to . And what is the difference between them.
e
The issue is thus solved for me, but I've just wondered, how that's possible?) (edited)
It's not possible. Once a value is an output it has to stay an output.
Output.concat
always returns an
Output[string]
. Not that in the next version of the python SDK we'll have
Output.format
which is the same as the built in
format
method but with support for outputs. I'd like to see if we could get
Output.f
to get f strings with output support but Python doesn't really support extensions to the f string machinery so this would probably be a bit hacky (e.g. there's a suggestion of looking up stack frames here https://stackoverflow.com/questions/61185448/custom-string-interpolation-in-python)
I would like to know which scenario dose
unsecret
apply to
unsecret
is for when you've ended up with a value tagged as a secret and you don't want it be. Normally this is because you've got one large output structure which has a secret part and non-secret part but the whole thing has come in as secret, you can pull off the non-secret part call
unsecret
on it and then see it in plain text in display output and state and the like.