2 ##############################################################################
4 # Copyright (c) 2019 AT&T Intellectual Property.
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 ##############################################################################
19 # Verifies RIC helm charts
20 # Requires Linux with wget and tar.
21 # This script should be executed inside the ric-plt/ric-dep bin directory only.
23 echo "--> verify-ric-charts"
26 # (Optional) provide HELMVERSION as first parameter. It selects the helm client version
27 # (Optional) provide OVERRIDEYAML as the second parameter. It allows us to specify an override file to replace values used to render the helm charts
28 if [[ "${1:-nope}" != "nope" ]]; then
33 if [[ "${2:-nope}" != "nope" ]]; then
40 if ! $($HELM_COMMAND > /dev/null);then
41 echo "Download and install Helm"
42 if [ ! -e helm-v${HELMVERSION}-linux-amd64.tar.gz ]; then
43 wget -nv https://storage.googleapis.com/kubernetes-helm/helm-v${HELMVERSION}-linux-amd64.tar.gz
45 tar -xvf ./helm-v${HELMVERSION}-linux-amd64.tar.gz
46 mv linux-amd64/helm ./
50 # Set up ric common template
51 # Download it/dep common template charts
52 git clone --single-branch --branch master "https://gerrit.o-ran-sc.org/r/it/dep" ./dep
54 # Start Helm local repo if there isn't one
55 if [ ! -z $(pgrep "$HELM_COMMAND") ]; then
56 echo "Stopping existing local Helm server."
57 kill -9 "$(pgrep "$HELM_COMMAND")"
59 if [ ! -d ./charts ]; then
62 echo "Starting local Helm server"
63 nohup $HELM_COMMAND serve --repo-path charts >& /dev/null &
64 # Package ric-common and serve it using Helm local repo
65 $HELM_COMMAND package --save=false -d ./charts "$ROOT_DIR/dep/ric-common/Common-Template/helm/ric-common"
66 $HELM_COMMAND package --save=false -d ./charts "$ROOT_DIR/dep/ric-common/Common-Template/helm/aux-common"
67 $HELM_COMMAND repo index ./charts
68 # Make sure that helm local repo is added
69 $HELM_COMMAND repo remove local
70 $HELM_COMMAND repo add local http://127.0.0.1:8879/charts
71 # Remove it/dep charts
74 # Create array of helm charts
75 echo "Finding all Helm charts"
77 while IFS= read -r -d $'\0'; do
78 CHART_ARRAY+=("$REPLY")
79 done < <(find "$ROOT_DIR/../" -maxdepth 4 -name Chart.yaml -printf '%h\0')
81 echo "***************************************"
82 for dir in "${CHART_ARRAY[@]}"
84 echo "Running helm lint and verification on chart $dir"
85 echo "Update chart dependency"
86 $HELM_COMMAND dep up "$dir"
87 # Lint clearly marks errors; e.g., [ERROR]
88 echo "Performing Helm lint"
89 if [[ "${OVERRIDEYAML:-nope}" != "nope" ]]; then
90 $HELM_COMMAND lint -f "$OVERRIDEYAML" "$dir"
92 $HELM_COMMAND lint "$dir"
94 echo "***************************************************************************************************************"
95 echo "Rendering Helm charts locally"
96 if [[ "${OVERRIDEYAML:-nope}" != "nope" ]]; then
97 $HELM_COMMAND template -f "$OVERRIDEYAML" "$dir"
99 $HELM_COMMAND template "$dir"
101 echo "***************************************************************************************************************"
103 echo "--> verify-ric-charts ends"