-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit 0161886 Author: Matt Conway <[email protected]> Date: Wed Nov 24 12:45:07 2021 -0500 remote fix commit 867d64f Author: Matt Conway <[email protected]> Date: Wed Nov 24 11:47:38 2021 -0500 enable env for file pattern commit 1bcb9f6 Author: Matt Conway <[email protected]> Date: Wed Nov 24 10:49:53 2021 -0500 fix newline in secrets, allow remote setup script
- Loading branch information
Showing
6 changed files
with
87 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,5 @@ kind: Secret | |
apiVersion: v1 | ||
metadata: | ||
name: argocd-cloudtruth-plugin | ||
namespace: argocd | ||
type: Opaque | ||
data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ data: | |
- name: argocd-cloudtruth-plugin | ||
generate: | ||
command: ["argocd-cloudtruth-plugin"] | ||
args: ["*.y*ml"] | ||
args: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,69 @@ | ||
#!/usr/bin/env bash | ||
#!/usr/bin/env sh | ||
|
||
# fail fast | ||
set -e | ||
typeset -i remote=0 | ||
|
||
if [[ "$0" == "sh" ]]; then | ||
remote=1 | ||
baseurl=${baseurl:-https://raw.githubusercontent.com/cloudtruth/argocd-cloudtruth-plugin/main/install} | ||
baseurl_params=${baseurl_params:-} | ||
basedir="." | ||
else | ||
basedir=$(cd $(dirname $0) && pwd) | ||
fi | ||
|
||
printf "Input Cloudtruth Api Key: " | ||
read CLOUDTRUTH_API_KEY | ||
printf "Input Cloudtruth Environment (Default and can be overridden for each Argo project): " | ||
read CLOUDTRUTH_ENVIRONMENT | ||
printf "Input Cloudtruth Project (Default and can be overridden for each Argo project): " | ||
read CLOUDTRUTH_PROJECT | ||
function echoFile { | ||
if ((remote)); then | ||
curl -s ${baseurl}/${1}${baseurl_params} | ||
else | ||
cat ${basedir}/${1} | ||
fi | ||
} | ||
export -f echoFile | ||
|
||
cat <<EOF | kubectl apply -n argocd -f - | ||
$(cat argocd-cloudtruth-plugin-secret.yaml) | ||
CLOUDTRUTH_API_KEY: $(echo ${CLOUDTRUTH_API_KEY} | base64) | ||
CLOUDTRUTH_ENVIRONMENT: $(echo ${CLOUDTRUTH_ENVIRONMENT} | base64) | ||
CLOUDTRUTH_PROJECT: $(echo ${CLOUDTRUTH_PROJECT} | base64) | ||
ARGO_NAMESPACE=${ARGO_NAMESPACE:-argocd} | ||
echo "Installing to namespace '${ARGO_NAMESPACE}', override with: ARGO_NAMESPACE=xyz setup.sh" | ||
echo | ||
echo "The requested environment variables control the plugin" | ||
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 < /dev/tty | ||
if [[ -z ${CLOUDTRUTH_API_KEY} ]]; then echo "Api Key is required"; exit 1; fi | ||
|
||
printf "Input Cloudtruth Environment [default]: " | ||
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 < /dev/tty | ||
if [[ -z ${CLOUDTRUTH_PROJECT} ]]; then echo "Using 'MyFirstProject' for project"; CLOUDTRUTH_PROJECT=MyFirstProject; fi | ||
|
||
printf "Input Cloudtruth Tag []: " | ||
read CLOUDTRUTH_TAG < /dev/tty | ||
|
||
secret_yaml=$(cat <<EOF | ||
$(echoFile argocd-cloudtruth-plugin-secret.yaml) | ||
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: $(printf "${CLOUDTRUTH_TAG}" | base64) | ||
EOF | ||
) | ||
fi | ||
|
||
echo "${secret_yaml}" | kubectl apply -n ${ARGO_NAMESPACE} -f - | ||
|
||
kubectl get -n argocd configmap/argocd-cm -o yaml > argocd-cm..original.$(date +%s).yaml | ||
kubectl patch -n argocd configmap/argocd-cm --patch "$(cat argocd-cm.patch.yaml)" | ||
kubectl get -n ${ARGO_NAMESPACE} configmap/argocd-cm -o yaml > ${basedir}/argocd-cm..original.$(date +%s).yaml | ||
kubectl patch -n ${ARGO_NAMESPACE} configmap/argocd-cm --patch "$(echoFile argocd-cm.patch.yaml)" | ||
|
||
kubectl get -n argocd deployment/argocd-repo-server -o yaml > argocd-repo-server.original.$(date +%s).yaml | ||
kubectl patch -n argocd deployment/argocd-repo-server --patch "$(cat argocd-repo-server.patch.yaml)" | ||
kubectl get -n ${ARGO_NAMESPACE} deployment/argocd-repo-server -o yaml > ${basedir}/argocd-repo-server.original.$(date +%s).yaml | ||
kubectl patch -n ${ARGO_NAMESPACE} deployment/argocd-repo-server --patch "$(echoFile argocd-repo-server.patch.yaml)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters