orange-airport-64592
10/11/2022, 1:16 PMOutPut.unsecret
, I found some test case in sdk/python/lib/test/test_next_serialize.py
.
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.unsecret
?echoing-dinner-19531
10/11/2022, 2:26 PMapply
able-ability-11203
10/11/2022, 5:10 PMapply(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?)orange-airport-64592
10/12/2022, 2:44 AMunsecret
apply to . And what is the difference between them.echoing-dinner-19531
10/12/2022, 8:50 AMThe 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 doseapply tounsecret
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.