Skip to content

Commit 1a37f84

Browse files
authored
Merge pull request #1 from mhjacks/main
ArgoCD Secret handling
2 parents 92e5ce2 + 2635a7d commit 1a37f84

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,45 @@ NAME=$(shell basename `pwd`)
44
TARGET_REPO=$(shell git remote show origin | grep Push | sed -e 's/.*URL://' -e 's%:%/%' -e 's%git@%https://%')
55
TARGET_BRANCH=$(shell git branch --show-current)
66

7+
# This is to eliminate the need to install and worry about a separate shell script somewhere in the directory structure
8+
# There's a lot of GNU Make magic happening here:
9+
# .ONESHELL passes the whole task into a single shell instance
10+
# $$ is a Makefile idiom to preserve the single $ otherwise make consumes them
11+
# tabs are necessary
12+
# The patch to oc apply uses JSON because it's not as sensitive to indentation and doesn't need heredoc
13+
.ONESHELL:
14+
SHELL = bash
15+
argosecret:
16+
target_ns=$(TARGET_NAMESPACE)
17+
ns=0
18+
gitops=0
19+
20+
# Check for Namespaces and Secrets to be ready (it takes the cluster a while to deploy them)
21+
while [ 1 ]; do
22+
if [ oc get namespace $$target_ns >/dev/null 2>/dev/null ]; then
23+
ns=0
24+
else
25+
ns=1
26+
fi
27+
28+
if [ oc -n openshift-gitops extract secrets/openshift-gitops-cluster --to=- 1>/dev/null 2>/dev/null ]; then
29+
gitops=0
30+
else
31+
gitops=1
32+
fi
33+
34+
if [ "$$gitops" == 1 -a "$$ns" == 1 ]; then
35+
break
36+
fi
37+
done
38+
39+
user=$$(echo admin | base64)
40+
password=$$(oc -n openshift-gitops extract secrets/openshift-gitops-cluster --to=- 2>/dev/null | base64)
41+
42+
echo "{ \"apiVersion\": \"v1\", \"kind\": \"Secret\", \"metadata\": { \"name\": \"argocd-env\", \"namespace\": \"$$target_ns\" }, \"data\": { \"ARGOCD_PASSWORD\": \"$$password\", \"ARGOCD_USERNAME\": \"$$user\" }, \"type\": \"Opaque\" }" | oc apply -f-
43+
44+
# Makefiles in the individual patterns should call these targets explicitly
45+
# e.g. from manufacturing-ai-ml-edge: make -f common/Makefile show
746
show:
847
helm template install/ --name-template $(NAME) -f $(SECRETS) --set main.git.repoURL="$(TARGET_REPO)" --set main.git.revision=$(TARGET_BRANCH) --set main.options.bootstrap=$(BOOTSTRAP)
948

Makefile.toplevel

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This is an example top-level makefile for a new pattern. It delegates the tasks to the common makefile.
2+
BOOTSTRAP=1
3+
ARGO_TARGET_NAMESPACE=replaceme
4+
5+
show:
6+
make -f common/Makefile show
7+
8+
init:
9+
make -f common/Makefile init
10+
11+
deploy:
12+
make -f common/Makefile deploy
13+
ifeq ($(BOOTSTRAP),1)
14+
make -f common/Makefile TARGET_NAMESPACE=$(ARGO_TARGET_NAMESPACE) argosecret
15+
endif
16+
17+
upgrade:
18+
make -f common/Makefile upgrade
19+
ifeq ($(BOOTSTRAP),1)
20+
make -f common/Makefile TARGET_NAMESPACE=$(ARGO_TARGET_NAMESPACE) argosecret
21+
endif
22+
23+
uninstall:
24+
make -f common/Makefile uninstall
25+
26+
.phony: install

0 commit comments

Comments
 (0)