From 8a0bd39d7145c1ad1e61946622a318a0ecad341f Mon Sep 17 00:00:00 2001 From: Christoffer Nissen Date: Wed, 9 Oct 2024 22:26:50 +0200 Subject: [PATCH] resolve kubectl image version with special case --- pkg/helm/chartOption.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/helm/chartOption.go b/pkg/helm/chartOption.go index 8b319d9..6b15474 100644 --- a/pkg/helm/chartOption.go +++ b/pkg/helm/chartOption.go @@ -80,7 +80,7 @@ type ChartOption struct { UseCustomValues bool } -func determineTag(ctx context.Context, k8sv string, img *registry.Image, plainHTTP bool) bool { +func determineTag(ctx context.Context, img *registry.Image, plainHTTP bool) bool { reg, repo, name := img.Elements() ref := fmt.Sprintf("%s/%s/%s", reg, repo, name) @@ -101,12 +101,6 @@ func determineTag(ctx context.Context, k8sv string, img *registry.Image, plainHT return true } - available, _ = registry.Exist(ctx, ref, k8sv, plainHTTP) - if available { - img.Tag = k8sv - return true - } - return false } @@ -317,10 +311,6 @@ func (co ChartOption) Run(ctx context.Context, setters ...Option) (ChartData, er eg, egCtx := errgroup.WithContext(egCtx) for i, helmValuePaths := range imageMap { - if i.Tag == "" { - // If tag is empty in values.yaml, use App Version by convention - i.Tag = chart.Metadata.AppVersion - } func(i *registry.Image, helmValuePaths []string) { eg.Go(func() error { @@ -330,9 +320,19 @@ func (co ChartOption) Run(ctx context.Context, setters ...Option) (ChartData, er i.Registry = reg i.Repository = fmt.Sprintf("%s/%s", repo, name) + if i.Tag == "" { + switch name { + case "kubectl": + i.Tag = args.K8SVersion + default: + // If tag is empty in values.yaml, use App Version by convention + i.Tag = chart.Metadata.AppVersion + } + } + plainHTTP := strings.Contains(i.Registry, "localhost") || strings.Contains(i.Registry, "0.0.0.0") - available := determineTag(egCtx, args.K8SVersion, i, plainHTTP) + available := determineTag(egCtx, i, plainHTTP) // send availability response channel <- &imageInfo{available, c, i, &helmValuePaths}