Created
April 24, 2019 06:08
-
-
Save AntonTyutin/13299d25619cc2bc1b6574392851cf7b to your computer and use it in GitHub Desktop.
Converts JSON to YAML with query capabilities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if ! docker images -q yq | grep '' 1>/dev/null | |
then | |
docker build --pull -t yq - <<EOF | |
FROM alpine | |
RUN apk add --no-cache py2-pip jq && pip install -q yq | |
ENTRYPOINT ["yq"] | |
EOF | |
fi | |
PROXY_ENV="" | |
for VAR in `env | grep -vE '^(USER|HOME|UID)='` | |
do | |
PROXY_ENV="$PROXY_ENV -e $VAR" | |
done | |
docker run --rm -i $([ -t 0 ] && echo '-t') \ | |
-u $(id -u) \ | |
-w /src \ | |
-v $PWD:/src \ | |
$PROXY_ENV \ | |
$RUN_ARGS \ | |
yq -y "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment