File tree Expand file tree Collapse file tree 2 files changed +40
-3
lines changed Expand file tree Collapse file tree 2 files changed +40
-3
lines changed Original file line number Diff line number Diff 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
2626INDEX_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
3136TARGET_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
3538UUID_FILE ?= ~/.config/validated-patterns/pattern-uuid
3639UUID_HELM_OPTS ?=
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments