yq/test.sh
2021-11-30 13:04:32 +11:00

20 lines
617 B
Bash
Executable File

#!/bin/bash
# load array into a bash array
# need to output each entry as a single line
# readarray identityMappings < <(./yq e -o=j -I=0 '.identitymappings[]' test.yml )
# for identityMapping in "${identityMappings[@]}"; do
# # identity mapping is a yaml snippet representing a single entry
# roleArn=$(echo "$identityMapping" | yq e '.arn' -)
# echo "roleArn: $roleArn"
# done
while IFS=$'\t' read -r roleArn group user _; do
echo "Role: $roleArn"
echo "Group: $group"
echo "User: $user"
done < <(yq -j read test.yaml \
| jq -r '.identitymappings[] | [.arn, .group, .user] | @tsv')