big-psychiatrist-43588
03/09/2022, 4:33 PMlet resourceId : pulumi.Input<string> = "thx/".concat(sharedSecret.name); //"namespace/shared-keystore-jks-ksa" ;
let secrets: pulumi.Output<output.core.v1.ObjectReference[]> = k8s.core.v1.ServiceAccount.get("ksa-".concat(sharedSecret.name),resourceId).secrets;
Post retrieving the secret, i am trying to find the secret name and use the name to supply for further use
//works asynchronously
secrets.apply(v => {
console.log("Secret Name ", v[0].name);
secretName_list.push(v[0].name);
});
console.log(secretName);//print secret name
Complete program
1. var serviceAccountArray = [];
2. var secretName_list=[];
3.
4. serviceAccountArray.forEach(ksa => {
5. let resourceId : pulumi.Input<string> = "thx/".concat(ksa.name); //"namespace/shared-keystore-jks-ksa" ;
6. let secrets: pulumi.Output<output.core.v1.ObjectReference[]> = k8s.core.v1.ServiceAccount.get("ksa-".concat(ksa.name),resourceId).secrets;
7. //running asynchronously
8. secrets.apply(v => {
9. console.log("Secret Name ", v[0].name);
10. secretName_list.push(v[0].name);
11. });
12. console.log(secretName_list); //print secret name empty because of apply
13. });
Line no. 10 get executed after line no. 12 at the end of the program while i wanted to wait for the execution to get it complete.
Any idea how this can be sort out. Thanks!echoing-dinner-19531
03/09/2022, 4:58 PMsecretName_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);
});
big-psychiatrist-43588
03/09/2022, 5:24 PMvar 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.echoing-dinner-19531
03/09/2022, 5:29 PMvar 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 synchronouslyYou 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
big-psychiatrist-43588
03/09/2022, 5:44 PMarraylist [
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 itechoing-dinner-19531
03/09/2022, 5:48 PMbig-psychiatrist-43588
03/10/2022, 10:10 AM