check-jinja2: Fix unsupported '-e' arg for columns
[securedlab.git] / check-jinja2.sh
1 #!/bin/bash
2 set +x
3 set +o errexit
4
5 git submodule update --init --remote 2>/dev/null
6 GEN_CFG='./pharos/config/utils/generate_config.py'
7 INSTALLER_ADAPTERS='./pharos/config/installers/*'
8 RC=0
9
10 # Build a table header, using ';' as column sep
11 SUMMARY='PDF/Installer;'
12 for adapter in ${INSTALLER_ADAPTERS}; do
13     SUMMARY+="$(basename "${adapter}");"
14 done
15
16 # Iterate all PDFs, check with each installer adapter, log results
17 while IFS= read -r lab_config; do
18     SUMMARY+="\n${lab_config#labs/};"
19     for adapter in ${INSTALLER_ADAPTERS}; do
20         pdf_inst=0
21         pdf_inst_pass=0
22         while IFS= read -r jinja_template; do
23             echo -e "\n\n${GEN_CFG} -y ${lab_config} -j ${jinja_template}"
24             if "${GEN_CFG}" -y "${lab_config}" -j "${jinja_template}"; then
25                 ((pdf_inst_pass+=1))
26             else
27                 RC=1
28             fi
29             ((pdf_inst+=1))
30         done < <(find "${adapter}" -name '*.j2')
31         SUMMARY+="${pdf_inst_pass}/${pdf_inst};"
32     done
33 done < <(find 'pharos/config' 'labs' -name 'pod*.yaml')
34
35 echo -e '\n'
36 echo -e "${SUMMARY}" | sed -e 's/^/;/g' -e 's/;/;| /g' | column -t -s ';'
37 exit "${RC}"