dot notation error in extracting variable value with jq
by sysmicuser from LinuxQuestions.org on (#5K6CB)
I am using the below az cli command to extra values from a variable group
Code snippet as below:
Code:values=(auth0.client_id auth0.domain auth0.redirect_uri auth0.saml_client_id bff.bffApiAddressSearchUrl bff.bffApiUrl bff.bffOcpApimSubsriptionKey cartUrl)
az pipelines variable-group list --group-name "${compare_spa_env}"
for ptr in "${values[@]}"
do
result=$(az pipelines variable-group list --group-name "${compare_spa_env}" | jq '.[0].variables.'${ptr}'.value')
printf "%s\t%s\t%d\n" "$ptr" "$result" $?
doneMy payload consist like below, key value pairs:
Code: "auth0.client_id": {
"isSecret": null,
"value": "NyFf0Zp2ajrhgwub4PQmbYXB2lf5aeuT"
},
"auth0.domain": {
"isSecret": null,
"value": "secure-sitenv.digital.temp.com.au"
},
"auth0.redirect_uri": {
"isSecret": null,
"value": "https://tempdstsitenv.digital.temp.com.au/apps/confirm/#/"
},
"auth0.saml_client_id": {
"isSecret": null,
"value": "S1D9AEtUvIgwYwHgwHIZWq8udS9Xec1D"
},
"bff.bffApiAddressSearchUrl": {
"isSecret": null,
"value": "https://sitenv-api.platform.temp.com.au/shared"
},
"bff.bffApiUrl": {
"isSecret": null,
"value": "https://sitenv-api.platform.temp.com.au/sales/funnel/bff"
},
"bff.bffOcpApimSubscriptionKey": {
"isSecret": null,
"value": "5a500097d0c14eb6acdc2e39219249ee"
},
"cartUrl": {
"isSecret": null,
"value": "/cart"
}However, I am getting as null when it comes to extracting the values to most if not all:
Code:+ result=null
I did try and change from [0] to [1] in jq command but still no luck :(
Code snippet as below:
Code:values=(auth0.client_id auth0.domain auth0.redirect_uri auth0.saml_client_id bff.bffApiAddressSearchUrl bff.bffApiUrl bff.bffOcpApimSubsriptionKey cartUrl)
az pipelines variable-group list --group-name "${compare_spa_env}"
for ptr in "${values[@]}"
do
result=$(az pipelines variable-group list --group-name "${compare_spa_env}" | jq '.[0].variables.'${ptr}'.value')
printf "%s\t%s\t%d\n" "$ptr" "$result" $?
doneMy payload consist like below, key value pairs:
Code: "auth0.client_id": {
"isSecret": null,
"value": "NyFf0Zp2ajrhgwub4PQmbYXB2lf5aeuT"
},
"auth0.domain": {
"isSecret": null,
"value": "secure-sitenv.digital.temp.com.au"
},
"auth0.redirect_uri": {
"isSecret": null,
"value": "https://tempdstsitenv.digital.temp.com.au/apps/confirm/#/"
},
"auth0.saml_client_id": {
"isSecret": null,
"value": "S1D9AEtUvIgwYwHgwHIZWq8udS9Xec1D"
},
"bff.bffApiAddressSearchUrl": {
"isSecret": null,
"value": "https://sitenv-api.platform.temp.com.au/shared"
},
"bff.bffApiUrl": {
"isSecret": null,
"value": "https://sitenv-api.platform.temp.com.au/sales/funnel/bff"
},
"bff.bffOcpApimSubscriptionKey": {
"isSecret": null,
"value": "5a500097d0c14eb6acdc2e39219249ee"
},
"cartUrl": {
"isSecret": null,
"value": "/cart"
}However, I am getting as null when it comes to extracting the values to most if not all:
Code:+ result=null
I did try and change from [0] to [1] in jq command but still no luck :(