Skip to content

Commit e9f00b1

Browse files
committed
Improve validate-origin
If we set the main.git.upstreamRepoURL then we need to check that one for the presence of the branch and not whatever is configured as the origin remote. Tested as follows: - Working upstreamRepoURL: ❯ yq -r '.main.git.repoUpstreamURL // (.main.git.repoUpstreamURL = "")' values-global.yaml https://github.com/mbaldessari/industrial-edge ❯ make validate-origin make -f common/Makefile validate-origin make[1]: Entering directory '/home/michele/Engineering/cloud-patterns/industrial-edge' Checking repository: Upstream URL set to: https://github.com/mbaldessari/industrial-edge https://github.com/mbaldessari/industrial-edge - branch 'for-max-s3-kafka-fix': OK make[1]: Leaving directory '/home/michele/Engineering/cloud-patterns/industrial-edge' - upstreamRepoURL without the branch: ❯ yq -r '.main.git.repoUpstreamURL // (.main.git.repoUpstreamURL = "")' values-global.yaml https://github.com/mamurak/industrial-edge ❯ make validate-origin make -f common/Makefile validate-origin make[1]: Entering directory '/home/michele/Engineering/cloud-patterns/industrial-edge' Checking repository: Upstream URL set to: https://github.com/mamurak/industrial-edge https://github.com/mamurak/industrial-edge - branch 'for-max-s3-kafka-fix': NOT FOUND make[1]: *** [common/Makefile:138: validate-origin] Error 1 make[1]: Leaving directory '/home/michele/Engineering/cloud-patterns/industrial-edge' make: *** [Makefile:24: validate-origin] Error 2 - No repoUpstreamURL set: ❯ yq -r '.main.git.repoUpstreamURL // (.main.git.repoUpstreamURL = "")' values-global.yaml ❯ ❯ make validate-origin make -f common/Makefile validate-origin make[1]: Entering directory '/home/michele/Engineering/cloud-patterns/industrial-edge' Checking repository: https://github.com/mbaldessari/industrial-edge.git - branch 'for-max-s3-kafka-fix': OK make[1]: Leaving directory '/home/michele/Engineering/cloud-patterns/industrial-edge'
1 parent 87776c6 commit e9f00b1

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,22 @@ token-kubeconfig: ## Create a local ~/.kube/config with password (not usually ne
129129

130130
# We only check the remote ssh git branch's existance if we're not running inside a container
131131
# as getting ssh auth working inside a container seems a bit brittle
132+
# If the main repoUpstreamURL field is set, then we need to check against
133+
# that and not target_repo
132134
.PHONY: validate-origin
133135
validate-origin: ## verify the git origin is available
134136
@echo "Checking repository:"
135-
@echo -n " $(TARGET_REPO) - branch '$(TARGET_BRANCH)': "
136-
@git ls-remote --exit-code --heads $(TARGET_REPO) $(TARGET_BRANCH) >/dev/null &&\
137-
echo "OK" || (echo "NOT FOUND"; exit 1)
137+
$(eval UPSTREAMURL := $(shell yq -r '.main.git.repoUpstreamURL // (.main.git.repoUpstreamURL = "")' values-global.yaml))
138+
@if [ -z "$(UPSTREAMURL)" ]; then\
139+
echo -n " $(TARGET_REPO) - branch '$(TARGET_BRANCH)': ";\
140+
git ls-remote --exit-code --heads $(TARGET_REPO) $(TARGET_BRANCH) >/dev/null &&\
141+
echo "OK" || (echo "NOT FOUND"; exit 1);\
142+
else\
143+
echo "Upstream URL set to: $(UPSTREAMURL)";\
144+
echo -n " $(UPSTREAMURL) - branch '$(TARGET_BRANCH)': ";\
145+
git ls-remote --exit-code --heads $(UPSTREAMURL) $(TARGET_BRANCH) >/dev/null &&\
146+
echo "OK" || (echo "NOT FOUND"; exit 1);\
147+
fi
138148

139149
.PHONY: validate-cluster
140150
validate-cluster: ## Do some cluster validations before installing

0 commit comments

Comments
 (0)