Skip to content

Commit

Permalink
remote fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wr0ngway committed Nov 24, 2021
1 parent 867d64f commit 0161886
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions install/setup.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

# fail fast
set -e
typeset -i remote=0

if [[ "$0" == "sh" ]]; then
remote=1
baseurl="https://raw.githubusercontent.com/cloudtruth/argocd-cloudtruth-plugin/main/install"
baseurl=${baseurl:-https://raw.githubusercontent.com/cloudtruth/argocd-cloudtruth-plugin/main/install}
baseurl_params=${baseurl_params:-}
basedir="."
else
basedir=$(cd $(dirname $0) && pwd)
fi

function echoFile {
if ((remote)); then
curl -s ${baseurl}/${1}
curl -s ${baseurl}/${1}${baseurl_params}
else
cat ${basedir}/${1}
fi
Expand All @@ -29,32 +30,32 @@ echo "ApiKey is required, and they can all be overriden for each argocd project"
echo

printf "Input Cloudtruth Api Key (required): "
read CLOUDTRUTH_API_KEY
read CLOUDTRUTH_API_KEY < /dev/tty
if [[ -z ${CLOUDTRUTH_API_KEY} ]]; then echo "Api Key is required"; exit 1; fi

printf "Input Cloudtruth Environment [default]: "
read CLOUDTRUTH_ENVIRONMENT
read CLOUDTRUTH_ENVIRONMENT < /dev/tty
if [[ -z ${CLOUDTRUTH_ENVIRONMENT} ]]; then echo "Using 'default' for environment"; CLOUDTRUTH_ENVIRONMENT=default; fi

printf "Input Cloudtruth Project [MyFirstProject]: "
read CLOUDTRUTH_PROJECT
read CLOUDTRUTH_PROJECT < /dev/tty
if [[ -z ${CLOUDTRUTH_PROJECT} ]]; then echo "Using 'MyFirstProject' for project"; CLOUDTRUTH_PROJECT=MyFirstProject; fi

printf "Input Cloudtruth Tag []: "
read CLOUDTRUTH_TAG
read CLOUDTRUTH_TAG < /dev/tty

secret_yaml=$(cat <<EOF
$(echoFile argocd-cloudtruth-plugin-secret.yaml)
CLOUDTRUTH_API_KEY: $(echo -n ${CLOUDTRUTH_API_KEY} | base64)
CLOUDTRUTH_ENVIRONMENT: $(echo -n ${CLOUDTRUTH_ENVIRONMENT} | base64)
CLOUDTRUTH_PROJECT: $(echo -n ${CLOUDTRUTH_PROJECT} | base64)
CLOUDTRUTH_API_KEY: $(printf ${CLOUDTRUTH_API_KEY} | base64)
CLOUDTRUTH_ENVIRONMENT: $(printf ${CLOUDTRUTH_ENVIRONMENT} | base64)
CLOUDTRUTH_PROJECT: $(printf ${CLOUDTRUTH_PROJECT} | base64)
EOF
)

if [[ -n ${CLOUDTRUTH_TAG} ]]; then
secret_yaml=$(cat <<EOF
${secret_yaml}
CLOUDTRUTH_TAG: $(echo -n "${CLOUDTRUTH_TAG}" | base64)
CLOUDTRUTH_TAG: $(printf "${CLOUDTRUTH_TAG}" | base64)
EOF
)
fi
Expand Down

0 comments on commit 0161886

Please sign in to comment.