Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions Makefile-tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ install-out-of-tree-tools: \
$(MYGOBIN)/goimports \
$(MYGOBIN)/golangci-lint \
$(MYGOBIN)/helmV3 \
$(MYGOBIN)/helmV4 \
$(MYGOBIN)/mdrip \
$(MYGOBIN)/stringer

Expand All @@ -27,6 +28,7 @@ uninstall-out-of-tree-tools:
rm -f $(MYGOBIN)/goimports
rm -f $(MYGOBIN)/golangci-lint
rm -f $(MYGOBIN)/helmV3
rm -f $(MYGOBIN)/helmV4
rm -f $(MYGOBIN)/mdrip
rm -f $(MYGOBIN)/stringer

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

# Helm V3 differs from helm V2; downloading it to provide coverage for the
# chart inflator plugin under helm v3.
# Helm V3; downloading it to provide coverage for the
# chart inflator plugin under helm v3
.PHONY: $(MYGOBIN)/helmV3
$(MYGOBIN)/helmV3:
( \
set -e; \
d=$(shell mktemp -d); cd $$d; \
tgzFile=helm-v3.10.2-$(GOOS)-$(GOARCH).tar.gz; \
tgzFile=helm-v3.19.2-$(GOOS)-$(GOARCH).tar.gz; \
wget https://get.helm.sh/$$tgzFile; \
tar -xvzf $$tgzFile; \
mv $(GOOS)-$(GOARCH)/helm $(MYGOBIN)/helmV3; \
rm -rf $$d \
)

# Helm V4; downloading it to provide coverage for the
# chart inflator plugin under helm v4.
.PHONY: $(MYGOBIN)/helmV4
$(MYGOBIN)/helmV4:
( \
set -e; \
d=$(shell mktemp -d); cd $$d; \
tgzFile=helm-v4.0.0-$(GOOS)-$(GOARCH).tar.gz; \
wget https://get.helm.sh/$$tgzFile; \
tar -xvzf $$tgzFile; \
mv $(GOOS)-$(GOARCH)/helm $(MYGOBIN)/helmV4; \
rm -rf $$d \
)
8 changes: 4 additions & 4 deletions api/internal/builtins/HelmChartInflationGenerator.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/types/pluginconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func EnabledPluginConfig(b BuiltinPluginLoadingOptions) (pc *PluginConfig) {
pc = MakePluginConfig(PluginRestrictionsNone, b)
pc.HelmConfig.Enabled = true
// If this command is not on PATH, tests needing it should skip.
pc.HelmConfig.Command = "helmV3"
pc.HelmConfig.Command = "helmV4"
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

// Helm chart inflation generator.
// Uses helm V3 to generate k8s YAML from a helm chart.
// Uses helm V3 or V4 to generate k8s YAML from a helm chart.

//go:generate pluginator
package main
Expand Down Expand Up @@ -375,9 +375,9 @@ func (p *plugin) markHelmGeneratedResources(rm resmap.ResMap) error {
return nil
}

// checkHelmVersion will return an error if the helm version is not V3
// checkHelmVersion will return an error if the helm version is not V3 or V4
func (p *plugin) checkHelmVersion() error {
stdout, err := p.runHelmCommand([]string{"version", "-c", "--short"})
stdout, err := p.runHelmCommand([]string{"version", "--short"})
if err != nil {
return err
}
Expand All @@ -393,8 +393,8 @@ func (p *plugin) checkHelmVersion() error {
v = v[1:]
}
majorVersion := strings.Split(v, ".")[0]
if majorVersion != "3" {
return fmt.Errorf("this plugin requires helm V3 but got v%s", v)
if majorVersion != "3" && majorVersion != "4" {
return fmt.Errorf("this plugin requires helm V3 or V4 but got v%s", v)
}
return nil
}
Loading
Loading