Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for kv engine 1 #715

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions incubating/vault/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ REQUIRED_VARS=(
VAULT_PATH
VAULT_PATH_DELIMITER
VAULT_FIELD_NAME
VAULT_VARIABLE_EXPORT_PREFIX
VAULT_VARIABLE_EXPORT_PREFIX
VAULT_CLIENT_CERT_BASE64
VAULT_CLIENT_KEY_BASE64
)
Expand Down Expand Up @@ -77,19 +77,31 @@ else
IFS=$VAULT_PATH_DELIMITER read -ra SPLIT_VAULT_PATHS <<< "$VAULT_PATH"
for i in "${SPLIT_VAULT_PATHS[@]}"; do
msg "Exporting variables from path $i"
# checking if info available by path .data.data
dataPath='.data.data'
kvdata=$(vault kv get $i | jq -c $dataPath)
if [[ -z "$kvdata" ]] || [ $kvdata='null' ]; then
dataPath='.data'
fi
# Grab the json values from this path and add any prefix specified
for s in $(vault kv get $i | jq -c '.data.data' | jq -r "to_entries|map(\"$VAULT_VARIABLE_EXPORT_PREFIX\(.key)=\(.value|tostring)\")|.[]" ); do
for s in $(vault kv get $i | jq -c $dataPath | jq -r "to_entries|map(\"$VAULT_VARIABLE_EXPORT_PREFIX\(.key)=\(.value|tostring)\")|.[]" ); do
echo $s >> /meta/env_vars_to_export
done
done
# Export values from a single path
else
msg "Exporting variables from path $VAULT_PATH"
# checking if info available by path .data.data
dataPath='.data.data'
kvdata=$(vault kv get $i | jq -c $dataPath)
if [[ -z "$kvdata" ]] || [ $kvdata='null' ]; then
dataPath='.data'
fi
# Grab the json values from this path and add any prefix specified
for s in $(vault kv get $VAULT_PATH | jq -c '.data.data' | jq -r "to_entries|map(\"$VAULT_VARIABLE_EXPORT_PREFIX\(.key)=\(.value|tostring)\")|.[]" ); do
for s in $(vault kv get $VAULT_PATH | jq -c $dataPath | jq -r "to_entries|map(\"$VAULT_VARIABLE_EXPORT_PREFIX\(.key)=\(.value|tostring)\")|.[]" ); do
echo $s >> /meta/env_vars_to_export
done
fi
fi
fi


2 changes: 1 addition & 1 deletion incubating/vault/step.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ kind: step-type
version: '1.0'
metadata:
name: vault
version: 0.0.7
version: 0.0.8
title: Fetch secrets from Hashicorp Vault
isPublic: true
description: >-
Expand Down
Loading