Skip to content

Commit

Permalink
Update template
Browse files Browse the repository at this point in the history
  • Loading branch information
wkmor1 committed Jul 9, 2024
1 parent bf663eb commit fbe2f73
Show file tree
Hide file tree
Showing 2 changed files with 179 additions and 121 deletions.
76 changes: 45 additions & 31 deletions oc-process.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/bin/bash

i="all"
f="template.yml"
e=".env"

while getopts ":f:e:i::" flag; do
case $flag in
f) f=${OPTARG} ;;
e) e=${OPTARG} ;;
i) i=${OPTARG} ;;
esac
case $flag in
f) f=${OPTARG} ;;
e) e=${OPTARG} ;;
i) i=${OPTARG} ;;
esac
done

set -a
Expand All @@ -21,64 +23,76 @@ BRANCH=$(git symbolic-ref --short -q HEAD)
# If not in main, assume dev
if [ "$BRANCH" != "main" ]; then

HOST=$HOST_DEV
MYSQL_PASSWORD=$MYSQL_PASSWORD_DEV
ITSYSTEM=$ITSYSTEM_DEV
HOST=$HOST_DEV
MYSQL_PASSWORD=$MYSQL_PASSWORD_DEV
ITSYSTEM=$ITSYSTEM_DEV

fi

if [ $i = "volume" ]; then

ITEM=".items[0]"
ITEM=".items[0]"

elif [ $i = "image" ]; then
elif [ $i = "config" ]; then

ITEM=".items[1]"
ITEM=".items[1]"

elif [ $i = "build" ]; then
elif [ $i = "secrets" ]; then

ITEM=".items[2]"
ITEM=".items[2]"

elif [ $i = "deploy-app" ]; then

ITEM=".items[3]"
ITEM=".items[3]"

elif [ $i = "deploy-db" ]; then

ITEM=".items[4]"
ITEM=".items[4]"

elif [ $i = "service-app" ]; then

ITEM=".items[5]"
ITEM=".items[5]"

elif [ $i = "service-db" ]; then

ITEM=".items[6]"
ITEM=".items[6]"

elif [ $i = "route" ]; then

ITEM=".items[7]"
ITEM=".items[7]"

elif [ $i = "job" ]; then

ITEM=".items[8]"
ITEM=".items[8]"

else
elif [ $i = "all" ]; then

ITEM=""

else

echo "Object not found"
exit 1

fi

FINBIF_API_TOKEN=$(echo -n $FINBIF_API_TOKEN | base64)
MYSQL_PASSWORD=$(echo -n $MYSQL_PASSWORD | base64)
FLASK_SECRET_KEY=$(echo -n $FLASK_SECRET_KEY | base64)
RCLONE_ACCESS_KEY_ID=$(echo -n $RCLONE_ACCESS_KEY_ID | base64)
RCLONE_SECRET_ACCESS_KEY=$(echo -n $RCLONE_SECRET_ACCESS_KEY | base64)

echo "# $(oc project species-challenge)"

oc process -f $f \
-p BRANCH=$BRANCH \
-p HOST=$HOST \
-p MYSQL_PASSWORD=$MYSQL_PASSWORD \
-p MYSQL_USER=$MYSQL_USER \
-p MYSQL_DATABASE=$MYSQL_DATABASE \
-p FINBIF_API_TOKEN=$FINBIF_API_TOKEN \
-p FLASK_SECRET_KEY=$FLASK_SECRET_KEY \
-p ITSYSTEM=$ITSYSTEM \
-p RCLONE_ACCESS_KEY_ID=$RCLONE_ACCESS_KEY_ID \
-p RCLONE_SECRET_ACCESS_KEY=$RCLONE_SECRET_ACCESS_KEY \
-p BRANCH="$BRANCH" \
-p HOST="$HOST" \
-p MYSQL_PASSWORD="$MYSQL_PASSWORD" \
-p MYSQL_USER="$MYSQL_USER" \
-p MYSQL_DATABASE="$MYSQL_DATABASE" \
-p FINBIF_API_TOKEN="$FINBIF_API_TOKEN" \
-p FLASK_SECRET_KEY="$FLASK_SECRET_KEY" \
-p ITSYSTEM="$ITSYSTEM" \
-p RCLONE_ACCESS_KEY_ID="$RCLONE_ACCESS_KEY_ID" \
-p RCLONE_SECRET_ACCESS_KEY="$RCLONE_SECRET_ACCESS_KEY" \
| jq $ITEM

Loading

0 comments on commit fbe2f73

Please sign in to comment.