Merge "Issue-ID: RICAPP-169 - Inclusion of InfluxDB helm chart for KPIMON, AD, TS...
[it/dep.git] / nonrtric / bin / install
index 56376fa..8b14da0 100755 (executable)
 #   limitations under the License.                                             #
 ################################################################################
 
-
+IS_HELM3=$(helm version -c --short|grep -e "^v3")
 while [ -n "$1" ]; do # while loop starts
 
     case "$1" in
 
     -f) OVERRIDEYAML=$2
         shift
-        ;;
-    -c) LIST_OF_COMPONENTS=$2
-        shift
-        ;;
+        ;; 
     *) echo "Option $1 not recognized" ;; # In case you typed a different option other than a,b,c
 
     esac
@@ -51,10 +48,8 @@ COMMON_BLOCK=$(cat $OVERRIDEYAML | awk '/^common:/{getline; while ($0 ~ /^ +.*|^
 NAMESPACE_BLOCK=$(cat $OVERRIDEYAML | awk '/^  namespace:/{getline; while ($0 ~ /^    .*|^ *$/) {print $0; if (getline == 0) {break}}}')
 NONRTRIC_NAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *nonrtric:/{print $2}')
 RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}')
-SIMULATOR_BLOCK=$(cat $OVERRIDEYAML | awk '/^  simulatorinstance:/{getline; while ($0 ~ /^ +.*|^ *$/) {print $0; if (getline == 0) {break}}}')
-SIMULATOR_COUNT=$(echo "$SIMULATOR_BLOCK" | awk '/^ *count:/{print $2}')
-COMPONENTS=${LIST_OF_COMPONENTS:-"a1simulator policymanagementservice"}
-echo "SIMULATOR_COUNT [$SIMULATOR_COUNT]"
+PARENT_CHART=$(cat $OVERRIDEYAML | awk '/^ *component:/{print $2}')
+echo "Chart name- $PARENT_CHART"
 
 if ! kubectl get ns ${NONRTRIC_NAMESPACE:-nonrtric}> /dev/null 2>&1; then
     kubectl create ns ${NONRTRIC_NAMESPACE:-nonrtric}
@@ -65,20 +60,13 @@ fi
 
 kubectl create configmap -n ${NONRTRIC_NAMESPACE:-nonrtric} nonrtric-recipe --from-file=recipe=$OVERRIDEYAML
 
-echo "Deploying NONRTRIC components [$COMPONENTS]"
+echo "Deploying NONRTRIC [$PARENT_CHART]"
 
-for component in $COMPONENTS; do
-    helm dep up $DIR/../helm/$component
-    case "$component" in
-            a1simulator)
-               for((i=1;i<=$SIMULATOR_COUNT;i++)) ; do
-                    echo "CREATING SIMUALATOR INSTANCE $i"
-                   helm install -f $OVERRIDEYAML --namespace "${NONRTRIC_NAMESPACE:-nonrtric}" --name "${RELEASE_PREFIX}-$component-$i" --set a1simulator.instanceName=a1-sim-$i $DIR/../helm/$component
-                done
-           ;;
-            *)
-                helm install -f $OVERRIDEYAML --namespace "${NONRTRIC_NAMESPACE:-nonrtric}" --name "${RELEASE_PREFIX}-$component" $DIR/../helm/$component
+HELM_NAME_OPT=""
+if [ -z $IS_HELM3 ];then
+   HELM_NAME_OPT="--name"
+fi
 
-    esac
+echo "helm install -f $OVERRIDEYAML --namespace ${NONRTRIC_NAMESPACE:-nonrtric} ${HELM_NAME_OPT} ${RELEASE_PREFIX} $DIR/../helm/${PARENT_CHART}"
+helm install -f $OVERRIDEYAML --namespace "${NONRTRIC_NAMESPACE:-nonrtric}" ${HELM_NAME_OPT} "${RELEASE_PREFIX}" $DIR/../helm/"${PARENT_CHART}"
 
-done