File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed 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