From 01e90ec2e575e4545037cb9c2953fd5347bfb875 Mon Sep 17 00:00:00 2001 From: Ryan Hallisey Date: Tue, 26 May 2015 21:44:56 -0400 Subject: Auto generate minimal environment variables doc This script will generate the minimal-environment-variables doc based on the what each services has in the check_required_var field. Anytime that field is changed run this script and commit the changes. Since Neutron is a thick container, the script will get a few duplicates in the neutron-agents field. When Neutron is thinned out, this script will function normally. Closes-bug: #1459347 Co-Authored-By: Lon Hohberger Change-Id: I1ba6bd5148af12cacfd872591b3c7b84a8dccba2 --- tools/min-env.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 tools/min-env.sh (limited to 'tools') diff --git a/tools/min-env.sh b/tools/min-env.sh new file mode 100755 index 000000000..403a43c34 --- /dev/null +++ b/tools/min-env.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +# +# This script generates the minimal environment variable doc + +# Move to top level directory +REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')") +cd "$(dirname "$REAL_PATH")/.." + +DOC=docs/minimal-environment-vars.md +DOCKERDIR="docker" +# BASE and TYPE can be hard coded to centos and rdo since the required vars will always be the same +BASE="centos" +TYPE="rdo" + +function write_header { + local header=$1 + header=${header^} + header=$(echo ${header} | sed -e 's/-app//') + echo -e "\n# $header\n" >> "$DOC" +} + +function write_env_var { + local env_var=$1 + if [ -z "$env_var" ]; then + echo "" >> "$DOC" + else + env_var=${env_var%=*} + echo " $env_var" >> "$DOC" + fi +} + +function find_vars { + local img_location=$1 + local empty=true + scripts=$(find ${img_location} -name *.sh | sort -t / -k 4) + + for script in $scripts; do + local vars=$(awk '/^\s*check_required_vars/,/([^\\]\s*$)/' $script) + vars=$(echo "$vars" | sed 's/check_required_vars//' | sed 's/\\//g') + + if [ ! -z "$vars" ]; then + empty=false + for v in $vars; do + write_env_var $v + done + fi + done + + if $empty; then + echo " None" >> "$DOC" + fi +} + +cat > $DOC <