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
9 changes: 6 additions & 3 deletions common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ EXTRA_PLAYBOOK_OPTS ?=
# INDEX_IMAGES=registry-proxy.engineering.redhat.com/rh-osbs/iib:394248,registry-proxy.engineering.redhat.com/rh-osbs/iib:394249
INDEX_IMAGES ?=

TARGET_ORIGIN ?= origin
# git branch --show-current is also available as of git 2.22, but we will use this for compatibility
TARGET_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)

#default to the branch remote
TARGET_ORIGIN ?= $(shell git config branch.$(TARGET_BRANCH).remote)

# This is to ensure that whether we start with a git@ or https:// URL, we end up with an https:// URL
# This is because we expect to use tokens for repo authentication as opposed to SSH keys
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://%')
# git branch --show-current is also available as of git 2.22, but we will use this for compatibility
TARGET_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)

UUID_FILE ?= ~/.config/validated-patterns/pattern-uuid
UUID_HELM_OPTS ?=
Expand Down
34 changes: 34 additions & 0 deletions common/scripts/argocd-login.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

## Login to validated patterns argocd instances

# Detect Argo CD namespaces
ARGOCD_NAMESPACES=$(oc get argoCD -A -o jsonpath='{.items[*].metadata.namespace}')
if [ -z "$ARGOCD_NAMESPACES" ]; then
echo "Error: No Argo CD instances found in the cluster."
exit 1
fi

# Split the namespaces into an array
NAMESPACES=($ARGOCD_NAMESPACES)

# Check if there are at least two Argo CD instances
if [ ${#NAMESPACES[@]} -lt 2 ]; then
echo "Error: Less than two Argo CD instances found. Found instances in namespaces: $ARGOCD_NAMESPACES"
exit 1
fi


for NAMESPACE in ${NAMESPACES[@]}; do
# get the instance name
ARGOCD_INSTANCE=$(oc get argocd -n "$NAMESPACE" -o jsonpath='{.items[0].metadata.name}') # assume only one per NS
SERVER_URL=$(oc get route "$ARGOCD_INSTANCE"-server -n "$NAMESPACE" -o jsonpath='{.status.ingress[0].host}')
PASSWORD=$(oc get secret "$ARGOCD_INSTANCE"-cluster -n "$NAMESPACE" -o jsonpath='{.data.admin\.password}' | base64 -d)
echo $PASSWORD
argocd login --skip-test-tls --insecure --grpc-web "$SERVER_URL" --username "admin" --password "$PASSWORD"
if [ "$?" -ne 0 ]; then
echo "Login to Argo CD ${SERVER_URL} failed. Exiting."
exit 1
fi

done