Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,45 @@ NAME=$(shell basename `pwd`)
TARGET_REPO=$(shell git remote show origin | grep Push | sed -e 's/.*URL://' -e 's%:%/%' -e 's%git@%https://%')
TARGET_BRANCH=$(shell git branch --show-current)

# This is to eliminate the need to install and worry about a separate shell script somewhere in the directory structure
# There's a lot of GNU Make magic happening here:
# .ONESHELL passes the whole task into a single shell instance
# $$ is a Makefile idiom to preserve the single $ otherwise make consumes them
# tabs are necessary
# The patch to oc apply uses JSON because it's not as sensitive to indentation and doesn't need heredoc
.ONESHELL:
SHELL = bash
argosecret:
target_ns=$(TARGET_NAMESPACE)
ns=0
gitops=0

# Check for Namespaces and Secrets to be ready (it takes the cluster a while to deploy them)
while [ 1 ]; do
if [ oc get namespace $$target_ns >/dev/null 2>/dev/null ]; then
ns=0
else
ns=1
fi

if [ oc -n openshift-gitops extract secrets/openshift-gitops-cluster --to=- 1>/dev/null 2>/dev/null ]; then
gitops=0
else
gitops=1
fi

if [ "$$gitops" == 1 -a "$$ns" == 1 ]; then
break
fi
done

user=$$(echo admin | base64)
password=$$(oc -n openshift-gitops extract secrets/openshift-gitops-cluster --to=- 2>/dev/null | base64)

echo "{ \"apiVersion\": \"v1\", \"kind\": \"Secret\", \"metadata\": { \"name\": \"argocd-env\", \"namespace\": \"$$target_ns\" }, \"data\": { \"ARGOCD_PASSWORD\": \"$$password\", \"ARGOCD_USERNAME\": \"$$user\" }, \"type\": \"Opaque\" }" | oc apply -f-

# Makefiles in the individual patterns should call these targets explicitly
# e.g. from manufacturing-ai-ml-edge: make -f common/Makefile show
show:
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)

Expand Down
26 changes: 26 additions & 0 deletions Makefile.toplevel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This is an example top-level makefile for a new pattern. It delegates the tasks to the common makefile.
BOOTSTRAP=1
ARGO_TARGET_NAMESPACE=replaceme

show:
make -f common/Makefile show

init:
make -f common/Makefile init

deploy:
make -f common/Makefile deploy
ifeq ($(BOOTSTRAP),1)
make -f common/Makefile TARGET_NAMESPACE=$(ARGO_TARGET_NAMESPACE) argosecret
endif

upgrade:
make -f common/Makefile upgrade
ifeq ($(BOOTSTRAP),1)
make -f common/Makefile TARGET_NAMESPACE=$(ARGO_TARGET_NAMESPACE) argosecret
endif

uninstall:
make -f common/Makefile uninstall

.phony: install
14 changes: 14 additions & 0 deletions site/templates/operatorgroup.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{{- range .Values.site.namespaces }}

{{- if empty $.Values.site.operatorgroupExcludes }}
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
Expand All @@ -8,4 +10,16 @@ spec:
targetNamespaces:
- {{ . }}
---
{{- else if not (has . $.Values.site.operatorgroupExcludes) }}
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: {{ . }}-operator-group
namespace: {{ . }}
spec:
targetNamespaces:
- {{ . }}
---
{{- end }}

{{- end }}