#!/usr/bin/bash
#do this manually
#INPUT_LIST=A B C
APPTYPE="app"

if [[ $INPUT_LIST ]]; then
  echo "use input list"
  DEPLOY_LIST=($INPUT_LIST)
else
  echo "update all with pods num >0"
  DEPLOY_LIST=`kubectl -n epmapp get deploy -l epm-type=$APPTYPE | tail -n+2 | awk '{if($4>0) print $1}'`
fi

echo ${DEPLOY_LIST[@]}

for deploy in ${DEPLOY_LIST[@]}
do

  echo "regenerate fact view for $deploy"
  echo "excuting kubectl -n epmapp exec deploy/$deploy -- node regenFactCube.js"
  #kubectl -n epmapp exec deploy/beginner100 -- node regenFactCube.js
  kubectl -n epmapp exec deploy/$deploy -- node regenFactCube.js
done