blob: 2978e8aed09b4073fcd065c431eb4d7dfedcf262 [file] [log] [blame]
Lott, Christopher (cl778h)6f157d72019-07-25 06:32:02 -04001#!/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
22OVERRIDEYAML=$1
23
24ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
25TEMP_DIR=/tmp
26CHART_ARRAY=()
27while IFS= read -r -d $'\0'; do
28 CHART_ARRAY+=("$REPLY")
29done < <(find $ROOT_DIR/../ -name Chart.yaml -printf '%h\0')
30
31rm -fr $TEMP_DIR/ric-common*.tgz
32
33helm package -d $TEMP_DIR $ROOT_DIR/../ric-common/Common-Template/helm/ric-common
34echo "***************************************"
35
36
37
38for dir in "${CHART_ARRAY[@]}"
39do
40
wriderfd155482019-08-05 23:57:57 -040041 #rm -rf $dir/charts
42 #rm -rf $dir/tmpcharts
Lott, Christopher (cl778h)6f157d72019-07-25 06:32:02 -040043 mkdir -p $dir/charts
44 cp $TEMP_DIR/ric-common*.tgz $dir/charts/
45
46 echo "Update chart depenedency"
47 helm dep up $dir
48 # Lint clearly marks errors; e.g., [ERROR]
49 if [ -z $OVERRIDEYAML ]; then
50 helm lint $dir > /tmp/output 2>&1
51 else
52 helm lint -f $OVERRIDEYAML $dir> /tmp/output 2>&1
53 fi
54 echo "***************************************************************************************************************"
55 cat /tmp/output
56
57 egrep -q '^Error: [0-9]* chart\(s\) linted, [0-9]* chart\(s\) failed' /tmp/output && exit 1
58 echo "***************************************************************************************************************"
59
60 if [ -z $OVERRIDEYAML ]; then
61 helm template $dir > /tmp/output 2>&1
62 else
63 helm template -f $OVERRIDEYAML $dir > /tmp/output 2>&1
64 fi
65 echo "***************************************************************************************************************"
66 cat /tmp/output
67 sleep 1
68 egrep -n '%!.\(.*=.*\)' /tmp/output && echo "Error: Type mismatch." && exit 1
69 echo "***************************************************************************************************************"
70
71done
72#Error: 1 chart(s) linted, 1 chart(s) failed
73
74
75
76exit 0
77