Skip to content

Commit 4f69e8b

Browse files
authored
Merge pull request validatedpatterns#441 from mbaldessari/common-automatic-update
common automatic update
2 parents d43295d + 5facc31 commit 4f69e8b

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

common/Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ EXTRA_PLAYBOOK_OPTS ?=
2525
# INDEX_IMAGES=registry-proxy.engineering.redhat.com/rh-osbs/iib:394248,registry-proxy.engineering.redhat.com/rh-osbs/iib:394249
2626
INDEX_IMAGES ?=
2727

28-
TARGET_ORIGIN ?= origin
28+
# git branch --show-current is also available as of git 2.22, but we will use this for compatibility
29+
TARGET_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
30+
31+
#default to the branch remote
32+
TARGET_ORIGIN ?= $(shell git config branch.$(TARGET_BRANCH).remote)
33+
2934
# This is to ensure that whether we start with a git@ or https:// URL, we end up with an https:// URL
3035
# This is because we expect to use tokens for repo authentication as opposed to SSH keys
3136
TARGET_REPO=$(shell git ls-remote --get-url --symref $(TARGET_ORIGIN) | sed -e 's/.*URL:[[:space:]]*//' -e 's%^git@%%' -e 's%^https://%%' -e 's%:%/%' -e 's%^%https://%')
32-
# git branch --show-current is also available as of git 2.22, but we will use this for compatibility
33-
TARGET_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
3437

3538
UUID_FILE ?= ~/.config/validated-patterns/pattern-uuid
3639
UUID_HELM_OPTS ?=

common/scripts/argocd-login.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
## Login to validated patterns argocd instances
4+
5+
# Detect Argo CD namespaces
6+
ARGOCD_NAMESPACES=$(oc get argoCD -A -o jsonpath='{.items[*].metadata.namespace}')
7+
if [ -z "$ARGOCD_NAMESPACES" ]; then
8+
echo "Error: No Argo CD instances found in the cluster."
9+
exit 1
10+
fi
11+
12+
# Split the namespaces into an array
13+
NAMESPACES=($ARGOCD_NAMESPACES)
14+
15+
# Check if there are at least two Argo CD instances
16+
if [ ${#NAMESPACES[@]} -lt 2 ]; then
17+
echo "Error: Less than two Argo CD instances found. Found instances in namespaces: $ARGOCD_NAMESPACES"
18+
exit 1
19+
fi
20+
21+
22+
for NAMESPACE in ${NAMESPACES[@]}; do
23+
# get the instance name
24+
ARGOCD_INSTANCE=$(oc get argocd -n "$NAMESPACE" -o jsonpath='{.items[0].metadata.name}') # assume only one per NS
25+
SERVER_URL=$(oc get route "$ARGOCD_INSTANCE"-server -n "$NAMESPACE" -o jsonpath='{.status.ingress[0].host}')
26+
PASSWORD=$(oc get secret "$ARGOCD_INSTANCE"-cluster -n "$NAMESPACE" -o jsonpath='{.data.admin\.password}' | base64 -d)
27+
echo $PASSWORD
28+
argocd login --skip-test-tls --insecure --grpc-web "$SERVER_URL" --username "admin" --password "$PASSWORD"
29+
if [ "$?" -ne 0 ]; then
30+
echo "Login to Argo CD ${SERVER_URL} failed. Exiting."
31+
exit 1
32+
fi
33+
34+
done

0 commit comments

Comments
 (0)