I need to interpolate curl body with variables into a shell script:
This is the script snippet:
curl -k \
-X PUT \
-d @- \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
"$SERVER_URL/api/v1/namespaces/$NAMESPACE/secrets/$SECRET_ID" <<-'EOF'
{
"kind": "Secret",
"apiVersion": "v1",
"metadata": {
"name": "$SECRET_ID"
},
"stringData": {
"$key": "$value"
}
}
EOF
However, neither $SECRET_ID nor $key nor $value aure "resolved".
EDIT
I've tried that:
curl -k \
-X PUT \
-d @- \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
"$SERVER_URL/api/v1/namespaces/$NAMESPACE/secrets/$SECRET_ID" <<-"EOF"
{
"kind": "Secret",
"apiVersion": "v1",
"metadata": {
"name": "$SECRET_ID"
},
"stringData": {
"$key": "$value"
}
}
EOF
But it doesn't works.