vault-fetch: fix multiline secret values being truncated
The read-based loop split multiline values on newlines, causing only the first line to be written. Use jq -j to write each key's value directly to files, preserving multiline content. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -137,9 +137,9 @@ fetch_from_vault() {
|
|||||||
|
|
||||||
# Write each secret key to a separate file
|
# Write each secret key to a separate file
|
||||||
log "Writing secrets to $OUTPUT_DIR"
|
log "Writing secrets to $OUTPUT_DIR"
|
||||||
echo "$SECRET_DATA" | jq -r 'to_entries[] | "\(.key)\n\(.value)"' | while read -r key; read -r value; do
|
for key in $(echo "$SECRET_DATA" | jq -r 'keys[]'); do
|
||||||
echo -n "$value" > "$OUTPUT_DIR/$key"
|
echo "$SECRET_DATA" | jq -j --arg k "$key" '.[$k]' > "$OUTPUT_DIR/$key"
|
||||||
echo -n "$value" > "$CACHE_DIR/$key"
|
echo "$SECRET_DATA" | jq -j --arg k "$key" '.[$k]' > "$CACHE_DIR/$key"
|
||||||
chmod 600 "$OUTPUT_DIR/$key"
|
chmod 600 "$OUTPUT_DIR/$key"
|
||||||
chmod 600 "$CACHE_DIR/$key"
|
chmod 600 "$CACHE_DIR/$key"
|
||||||
log " - Wrote secret key: $key"
|
log " - Wrote secret key: $key"
|
||||||
|
|||||||
Reference in New Issue
Block a user