1bc94c80bba9c315ab81d89fc584038e60a9432a
[it/test.git] / XTesting / kubespray / scripts / gen_tags.sh
1 #!/bin/sh
2 set -eo pipefail
3
4 #Generate MD formatted tags from roles and cluster yaml files
5 printf "|%25s |%9s\n" "Tag name" "Used for"
6 echo "|--------------------------|---------"
7 tags=$(grep -r tags: . | perl -ne '/tags:\s\[?(([\w\-_]+,?\s?)+)/ && printf "%s ", "$1"'|\
8   perl -ne 'print join "\n", split /\s|,/' | sort -u)
9 for tag in $tags; do
10   match=$(cat docs/ansible.md | perl -ne "/^\|\s+${tag}\s\|\s+((\S+\s?)+)/ && printf \$1")
11   printf "|%25s |%s\n" "${tag}" " ${match}"
12 done