77# Set this to true if you want to skip any origin validation
88DISABLE_VALIDATE_ORIGIN ?= false
99ifeq ($(DISABLE_VALIDATE_ORIGIN ) ,true)
10- VALIDATE_ORIGIN :=
10+ VALIDATE_ORIGIN :=
1111else
1212 VALIDATE_ORIGIN := validate-origin
1313endif
@@ -31,9 +31,8 @@ TARGET_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
3131# default to the branch remote
3232TARGET_ORIGIN ?= $(shell git config branch.$(TARGET_BRANCH ) .remote)
3333
34- # This is to ensure that whether we start with a git@ or https:// URL, we end up with an https:// URL
35- # This is because we expect to use tokens for repo authentication as opposed to SSH keys
36- 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://% ')
34+ # The URL for the configured origin (could be HTTP/HTTPS/SSH)
35+ TARGET_REPO_RAW := $(shell git ls-remote --get-url --symref $(TARGET_ORIGIN ) )
3736
3837UUID_FILE ?= ~/.config/validated-patterns/pattern-uuid
3938UUID_HELM_OPTS ?=
@@ -50,13 +49,22 @@ TOKEN_SECRET ?=
5049TOKEN_NAMESPACE ?=
5150
5251ifeq ($(TOKEN_SECRET ) ,)
53- HELM_OPTS =-f values-global.yaml --set main.git.repoURL="$(TARGET_REPO ) " --set main.git.revision=$(TARGET_BRANCH ) $(TARGET_SITE_OPT ) $(UUID_HELM_OPTS ) $(EXTRA_HELM_OPTS )
52+ # SSH agents are not created for public repos (repos with no secret token) by the patterns operator so we convert to HTTPS
53+ TARGET_REPO := $(shell echo "$(TARGET_REPO_RAW ) " | sed 's/^git@\(.* \) :\(.*\)/https:\/\/\1\/\2/')
54+ SECRET_OPTS :=
5455else
55- # When we are working with a private repository we do not escape the git URL as it might be using an ssh secret which does not use https://
56- TARGET_CLEAN_REPO =$(shell git ls-remote --get-url --symref $(TARGET_ORIGIN ) )
57- HELM_OPTS =-f values-global.yaml --set main.tokenSecret=$(TOKEN_SECRET ) --set main.tokenSecretNamespace=$(TOKEN_NAMESPACE ) --set main.git.repoURL="$(TARGET_CLEAN_REPO ) " --set main.git.revision=$(TARGET_BRANCH ) $(TARGET_SITE_OPT ) $(UUID_HELM_OPTS ) $(EXTRA_HELM_OPTS )
56+ TARGET_REPO := $(TARGET_REPO_RAW )
57+ SECRET_OPTS := --set main.tokenSecret=$(TOKEN_SECRET ) --set main.tokenSecretNamespace=$(TOKEN_NAMESPACE )
5858endif
5959
60+ HELM_OPTS := -f values-global.yaml \
61+ --set main.git.repoURL="$(TARGET_REPO ) " \
62+ --set main.git.revision=$(TARGET_BRANCH ) \
63+ $(SECRET_OPTS ) \
64+ $(TARGET_SITE_OPT ) \
65+ $(UUID_HELM_OPTS ) \
66+ $(EXTRA_HELM_OPTS )
67+
6068# Helm does the right thing and fetches all the tags and detects the newest one
6169PATTERN_INSTALL_CHART ?= oci://quay.io/hybridcloudpatterns/pattern-install
6270
@@ -138,8 +146,6 @@ token-kubeconfig: ## Create a local ~/.kube/config with password (not usually ne
138146
139147# #@ Validation Tasks
140148
141- # We only check the remote ssh git branch's existance if we're not running inside a container
142- # as getting ssh auth working inside a container seems a bit brittle
143149# If the main repoUpstreamURL field is set, then we need to check against
144150# that and not target_repo
145151.PHONY : validate-origin
0 commit comments