Add Docker based CI verify job
[ric-plt/ric-dep.git] / bin / verify-ric-charts
1 #!/bin/bash
2 ##############################################################################
3 #
4 #   Copyright (c) 2019 AT&T Intellectual Property.
5 #
6 #   Licensed under the Apache License, Version 2.0 (the "License");
7 #   you may not use this file except in compliance with the License.
8 #   You may obtain a copy of the License at
9 #
10 #       http://www.apache.org/licenses/LICENSE-2.0
11 #
12 #   Unless required by applicable law or agreed to in writing, software
13 #   distributed under the License is distributed on an "AS IS" BASIS,
14 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 #   See the License for the specific language governing permissions and
16 #   limitations under the License.
17 #
18 ##############################################################################
19
20 # Installs well-known RIC charts then verifies specified helm chart
21 # Requires chart tgz archives in /tmp
22 OVERRIDEYAML=$1
23
24 ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
25
26 ./setup-ric-common-template
27
28 # Create array of helm charts
29 CHART_ARRAY=()
30 while IFS= read -r -d $'\0'; do
31     CHART_ARRAY+=("$REPLY")
32 done < <(find $ROOT_DIR/../ -maxdepth 4 -name Chart.yaml -printf '%h\0')
33
34 echo "***************************************"
35
36
37 for dir in "${CHART_ARRAY[@]}"
38 do
39   
40     echo "Update chart depenedency"
41     helm dep up $dir 
42     # Lint clearly marks errors; e.g., [ERROR]
43     if [ -z $OVERRIDEYAML ]; then
44         helm lint $dir > /tmp/output 2>&1
45     else
46         helm lint -f $OVERRIDEYAML $dir> /tmp/output 2>&1
47     fi
48     echo "***************************************************************************************************************"
49     cat /tmp/output 
50     
51     egrep -q '^Error: [0-9]* chart\(s\) linted, [0-9]* chart\(s\) failed' /tmp/output && exit 1
52     echo "***************************************************************************************************************"
53
54     if [ -z $OVERRIDEYAML ]; then
55         helm template $dir > /tmp/output 2>&1
56     else
57         helm template -f $OVERRIDEYAML $dir > /tmp/output 2>&1
58     fi
59     echo "***************************************************************************************************************"
60     cat /tmp/output 
61    sleep 1 
62     egrep -n '%!.\(.*=.*\)' /tmp/output && echo "Error: Type mismatch." && exit 1
63     echo "***************************************************************************************************************"
64
65 done
66 #Error: 1 chart(s) linted, 1 chart(s) failed
67
68
69
70 exit 0
71