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

bitter-dentist-28132

08/19/2019, 4:22 PM
if i make a kubernetes namespace, and then want to use that namespace later on resources, is there a way to make it show up in the diff on the resources? it just appears as
output<string>
, even though the namespace resource shows the actual string
b

best-xylophone-83824

08/19/2019, 4:23 PM
it needs to know name upfront, instead of using namespace resource name, use same input for both namespace and resources in that namespace and use ` {dependsOn: []} option for resources to enforce order
so instead of (pseudocode):
Copy code
const name = "x";
const ns = new k8s.Namespace(name)
const cfg = new k8s.Configmap("abc", { namespace: ns.name })
do
Copy code
const name = "x";
const ns = new k8s.Namespace(name)
const cfg = new k8s.Configmap("abc", { namespace: name }, {dependsOn: [ns]})
b

bitter-dentist-28132

08/19/2019, 4:40 PM
unfortunately, can't do that because of pulumi's name mangling
i.e. the namespace isn't actually
name
, it's e.g.
name-tld6bkwm
b

best-xylophone-83824

08/19/2019, 4:41 PM
try
new k8s.Namespace(name, { name: name })
usually it forces name of a resource you want
b

bitter-dentist-28132

08/19/2019, 4:43 PM
do you mean as the second or third argument?
g

gorgeous-egg-16927

08/19/2019, 4:43 PM
@bitter-dentist-28132 You should be able to reference the ns
.metadata.name
b

bitter-dentist-28132

08/19/2019, 4:44 PM
@gorgeous-egg-16927 that's what i'm doing, but it appears as
output<string>
in the preview/diff
b

best-xylophone-83824

08/19/2019, 4:44 PM
@bitter-dentist-28132, second
g

gorgeous-egg-16927

08/19/2019, 4:46 PM
Would you mind opening an issue about that? We’ve been working on some changes to diff behavior lately, and that could be a regression.
b

bitter-dentist-28132

08/19/2019, 4:47 PM
@best-xylophone-83824 i guess you mean to use
{metadata: {name: name}}
since that's what's accepted by the type. which, interestingly, does then show the actual output in the diff, even when using
namespaceResource.metadata.name
filed the ticket.
🙏 1