From d5b6f68cee87dd494546e364c40cea6aad477042 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Wed, 15 Nov 2023 09:45:18 +0100 Subject: [PATCH] Set `KUBE_CROSS_VERSION` to latest if required Signed-off-by: Sascha Grunert --- pkg/gcp/gcb/gcb.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/gcp/gcb/gcb.go b/pkg/gcp/gcb/gcb.go index 4e957e481a3..9e3f9d3700b 100644 --- a/pkg/gcp/gcb/gcb.go +++ b/pkg/gcp/gcb/gcb.go @@ -377,6 +377,18 @@ func (g *GCB) SetGCBSubstitutions(toolOrg, toolRepo, toolRef, gcsBucket string) logrus.Infof("KubeCross version not set for %s, falling back to latest", g.options.Branch) } + if g.options.Branch != git.DefaultBranch { + kcVersionLatest, err := kc.Latest() + if err != nil { + return gcbSubs, fmt.Errorf("retrieve latest kube-cross version: %w", err) + } + + // if kcVersionBranch is empty, the branch does not exist yet, we use + // the latest kubecross version + if kcVersionBranch == "" { + kcVersionBranch = kcVersionLatest + } + } gcbSubs["KUBE_CROSS_VERSION"] = kcVersionBranch switch {