add kubespray to the XTesting as it provides newer version of kubenetes and can be...
[it/test.git] / XTesting / kubespray / scripts / gen_tags.sh
diff --git a/XTesting/kubespray/scripts/gen_tags.sh b/XTesting/kubespray/scripts/gen_tags.sh
new file mode 100755 (executable)
index 0000000..1bc94c8
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+set -eo pipefail
+
+#Generate MD formatted tags from roles and cluster yaml files
+printf "|%25s |%9s\n" "Tag name" "Used for"
+echo "|--------------------------|---------"
+tags=$(grep -r tags: . | perl -ne '/tags:\s\[?(([\w\-_]+,?\s?)+)/ && printf "%s ", "$1"'|\
+  perl -ne 'print join "\n", split /\s|,/' | sort -u)
+for tag in $tags; do
+  match=$(cat docs/ansible.md | perl -ne "/^\|\s+${tag}\s\|\s+((\S+\s?)+)/ && printf \$1")
+  printf "|%25s |%s\n" "${tag}" " ${match}"
+done