This message was deleted.
# general
s
This message was deleted.
e
Try not to do mutation of variables inside an apply! It is very very unlikely to work how you want. I would expect something like the following to build that array:
Copy code
secretName_list = serviceAccountArray.map(ksa => {
    let resourceId : pulumi.Input<string> = "thx/".concat(ksa.name); //"namespace/shared-keystore-jks-ksa" ;
    let secrets: pulumi.Output<output.core.v1.ObjectReference[]> = k8s.core.v1.ServiceAccount.get("ksa-".concat(ksa.name),resourceId).secrets;
	secrets.apply(v => v[0].name);
 });
b
I ran the below code
Copy code
var secretName_list = args.applicationSecrets.map(ksa => {
    let resourceId : pulumi.Input<string> = "thx/".concat(ksa.name); //"namespace/shared-keystore-jks-ksa" ;
    let secrets: pulumi.Output<output.core.v1.ObjectReference[]> = k8s.core.v1.ServiceAccount.get("ksa-".concat(ksa.name),resourceId).secrets;
    console.log("secrent name");
	secrets.apply(v => v[0].name);
})

console.log ("arraylist ",secretName_list);
It returns the array with undefined items looks like the apply executed later and array get populated with undefined value.
how can we check the operation in apply executed synchronously
e
Oh sorry no I missed a return there. Switching languages all the time it's hard recalling the correct syntax without putting things through an IDE.
Copy code
var secretName_list = args.applicationSecrets.map(ksa => {
    let resourceId : pulumi.Input<string> = "thx/".concat(ksa.name); //"namespace/shared-keystore-jks-ksa" ;
    let secrets: pulumi.Output<output.core.v1.ObjectReference[]> = k8s.core.v1.ServiceAccount.get("ksa-".concat(ksa.name),resourceId).secrets;
    console.log("secrent name");
	return secrets.apply(v => v[0].name);
})
how can we check the operation in apply executed synchronously
You can't because they won't, and there's no way to ask Pulumi to do that. During
preview
we might not even run the code inside an
apply
b
Thanks Fraser but looks like it returns the function Output
Copy code
arraylist  [
   OutputImpl {
     __pulumiOutput: true,
     resources: [Function (anonymous)],
     allResources: [Function (anonymous)],
     isKnown: Promise { <pending> },
     isSecret: Promise { <pending> },
     promise: [Function (anonymous)],
     toString: [Function (anonymous)],
     toJSON: [Function (anonymous)]
   },
   OutputImpl {
     __pulumiOutput: true,
     resources: [Function (anonymous)],
     allResources: [Function (anonymous)],
     isKnown: Promise { <pending> },
     isSecret: Promise { <pending> },
     promise: [Function (anonymous)],
     toString: [Function (anonymous)],
     toJSON: [Function (anonymous)]
   }
 ]
how would i get the value from it
e
You can't. There is no way to go from Output<T> to T, the only valid thing you can do with Outputs is pass them in as inputs to resources or export them as stack values.
b
Thanks Fraser, your solution work for me
134 Views