Skip to content

Commit f5b5da9

Browse files
hmilkoviSkaronator
authored andcommitted
fix: support helm v4 beside v3 and remove -c flag for helm version as it does nothing
fix error text migrate tests from Helm V3 to V4 run Helm tests for multiple Helm versions fix lint issues Update Makefile-tools.mk Co-authored-by: Niklas Wagner <[email protected]>
1 parent 77b3446 commit f5b5da9

File tree

5 files changed

+288
-305
lines changed

5 files changed

+288
-305
lines changed

Makefile-tools.mk

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ install-out-of-tree-tools: \
1919
$(MYGOBIN)/goimports \
2020
$(MYGOBIN)/golangci-lint \
2121
$(MYGOBIN)/helmV3 \
22+
$(MYGOBIN)/helmV4 \
2223
$(MYGOBIN)/mdrip \
2324
$(MYGOBIN)/stringer
2425

@@ -27,6 +28,7 @@ uninstall-out-of-tree-tools:
2728
rm -f $(MYGOBIN)/goimports
2829
rm -f $(MYGOBIN)/golangci-lint
2930
rm -f $(MYGOBIN)/helmV3
31+
rm -f $(MYGOBIN)/helmV4
3032
rm -f $(MYGOBIN)/mdrip
3133
rm -f $(MYGOBIN)/stringer
3234

@@ -82,16 +84,30 @@ $(MYGOBIN)/gh:
8284
$(MYGOBIN)/kubeval:
8385
cd $(REPO_ROOT)/hack && go install github.com/instrumenta/kubeval
8486

85-
# Helm V3 differs from helm V2; downloading it to provide coverage for the
86-
# chart inflator plugin under helm v3.
87+
# Helm V3; downloading it to provide coverage for the
88+
# chart inflator plugin under helm v3
8789
.PHONY: $(MYGOBIN)/helmV3
8890
$(MYGOBIN)/helmV3:
8991
( \
9092
set -e; \
9193
d=$(shell mktemp -d); cd $$d; \
92-
tgzFile=helm-v3.10.2-$(GOOS)-$(GOARCH).tar.gz; \
94+
tgzFile=helm-v3.19.2-$(GOOS)-$(GOARCH).tar.gz; \
9395
wget https://get.helm.sh/$$tgzFile; \
9496
tar -xvzf $$tgzFile; \
9597
mv $(GOOS)-$(GOARCH)/helm $(MYGOBIN)/helmV3; \
9698
rm -rf $$d \
9799
)
100+
101+
# Helm V4; downloading it to provide coverage for the
102+
# chart inflator plugin under helm v4.
103+
.PHONY: $(MYGOBIN)/helmV4
104+
$(MYGOBIN)/helmV4:
105+
( \
106+
set -e; \
107+
d=$(shell mktemp -d); cd $$d; \
108+
tgzFile=helm-v4.0.0-$(GOOS)-$(GOARCH).tar.gz; \
109+
wget https://get.helm.sh/$$tgzFile; \
110+
tar -xvzf $$tgzFile; \
111+
mv $(GOOS)-$(GOARCH)/helm $(MYGOBIN)/helmV4; \
112+
rm -rf $$d \
113+
)

api/internal/builtins/HelmChartInflationGenerator.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/types/pluginconfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func EnabledPluginConfig(b BuiltinPluginLoadingOptions) (pc *PluginConfig) {
3030
pc = MakePluginConfig(PluginRestrictionsNone, b)
3131
pc.HelmConfig.Enabled = true
3232
// If this command is not on PATH, tests needing it should skip.
33-
pc.HelmConfig.Command = "helmV3"
33+
pc.HelmConfig.Command = "helmV4"
3434
return
3535
}
3636

plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
// Helm chart inflation generator.
5-
// Uses helm V3 to generate k8s YAML from a helm chart.
5+
// Uses helm V3 or V4 to generate k8s YAML from a helm chart.
66

77
//go:generate pluginator
88
package main
@@ -375,9 +375,9 @@ func (p *plugin) markHelmGeneratedResources(rm resmap.ResMap) error {
375375
return nil
376376
}
377377

378-
// checkHelmVersion will return an error if the helm version is not V3
378+
// checkHelmVersion will return an error if the helm version is not V3 or V4
379379
func (p *plugin) checkHelmVersion() error {
380-
stdout, err := p.runHelmCommand([]string{"version", "-c", "--short"})
380+
stdout, err := p.runHelmCommand([]string{"version", "--short"})
381381
if err != nil {
382382
return err
383383
}
@@ -393,8 +393,8 @@ func (p *plugin) checkHelmVersion() error {
393393
v = v[1:]
394394
}
395395
majorVersion := strings.Split(v, ".")[0]
396-
if majorVersion != "3" {
397-
return fmt.Errorf("this plugin requires helm V3 but got v%s", v)
396+
if majorVersion != "3" && majorVersion != "4" {
397+
return fmt.Errorf("this plugin requires helm V3 or V4 but got v%s", v)
398398
}
399399
return nil
400400
}

0 commit comments

Comments
 (0)