I experienced unexpected behavior when accessing t...
# typescript
s
I experienced unexpected behavior when accessing the name of a k8s.core.v1.Secret resource. I created a k8s.core.v1.Secret resource and wanted to read the name output: First try:
Copy code
secret.metdata.name.apply(applyFunc)
-> In this case the applyFunc is executed in preview phase and 'undefined' is passed as value Second try:
Copy code
secret.metdata.apply(applyFunc)
-> In this case the applyFunc is not executed in preview phase Does anyone know if the different behavior is intended?
g
The first one is known at preview phase, it gives you the name you have set, it might not be the same value as during deployment time, but there is a value there. The second one is not, you need all the metadata to have it passed to the apply function, so it is only available during deployment. This seems correct to me
s
Thanks, I didn't know that. To be clear, the first one will be called during preview with the value which is set on resource instantiation and if it isn't set, as in my case, it will still be called in preview but with 'undefined'?
g
Yeah, during preview if the resource is new the values that have a matching input may be called with the input value, which may be undefined
That is my interpretation. I have not looked into the code for the kubernetes plugin to check if this what it actually does. I know that gcp plugin does that for some similar cases
s
Ok, thank you.