[PDF] [SPEC] Add 'version: 1.0'
[pharos.git] / config / utils / check-schema.sh
1 #!/bin/bash -e
2 ##############################################################################
3 # Copyright (c) 2018 Enea AB and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 export PATH=$PATH:/usr/local/bin/
11
12 VALIDATE_SCHEMA='./config/utils/validate_schema.py'
13 PDF_SCHEMA='./config/pdf/pod1.schema.yaml'
14 RC=0
15
16 while IFS= read -r lab_config; do
17     pdf_cmd="${VALIDATE_SCHEMA} -s ${PDF_SCHEMA} -y ${lab_config}"
18     echo "###################### ${lab_config} ######################"
19     pdf_out=$(${pdf_cmd} |& sed 's|ENC\[PKCS.*\][\\n]*|opnfv|g')
20     if [ -z "${pdf_out}" ]; then
21         SUMMARY+=";${lab_config#labs/};OK;\n"
22         echo "[PDF] [OK] ${pdf_cmd}"
23     else
24         SUMMARY+=";${lab_config#labs/};ERROR;\n"
25         RC=1
26         echo "${pdf_out}"
27         echo "[PDF] [ERROR] ${pdf_cmd}"
28     fi
29     echo ''
30 done < <(find 'labs' -name 'pod*.yaml')
31
32 cat <<EOF
33 ###################### Schema Validation Matrix ######################
34
35 $(echo -e "${SUMMARY}" | sed -e 's/;/;| /g' | column -t -s ';')
36 EOF
37 exit "${RC}"