Skip to content

Commit 61f05c3

Browse files
committed
execute helm test via go tool
1 parent 008b7a0 commit 61f05c3

File tree

8 files changed

+690
-223
lines changed

8 files changed

+690
-223
lines changed

Makefile-tools.mk

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ export IS_LOCAL = false
1818
install-out-of-tree-tools: \
1919
$(MYGOBIN)/goimports \
2020
$(MYGOBIN)/golangci-lint \
21-
$(MYGOBIN)/helmV3 \
2221
$(MYGOBIN)/mdrip \
2322
$(MYGOBIN)/stringer
2423

2524
.PHONY: uninstall-out-of-tree-tools
2625
uninstall-out-of-tree-tools:
2726
rm -f $(MYGOBIN)/goimports
2827
rm -f $(MYGOBIN)/golangci-lint
29-
rm -f $(MYGOBIN)/helmV3
3028
rm -f $(MYGOBIN)/mdrip
3129
rm -f $(MYGOBIN)/stringer
3230

@@ -81,17 +79,3 @@ $(MYGOBIN)/gh:
8179
.PHONY: $(MYGOBIN)/kubeval
8280
$(MYGOBIN)/kubeval:
8381
cd $(REPO_ROOT)/hack && go install github.com/instrumenta/kubeval
84-
85-
# Helm V3 differs from helm V2; downloading it to provide coverage for the
86-
# chart inflator plugin under helm v3.
87-
.PHONY: $(MYGOBIN)/helmV3
88-
$(MYGOBIN)/helmV3:
89-
( \
90-
set -e; \
91-
d=$(shell mktemp -d); cd $$d; \
92-
tgzFile=helm-v3.10.2-$(GOOS)-$(GOARCH).tar.gz; \
93-
wget https://get.helm.sh/$$tgzFile; \
94-
tar -xvzf $$tgzFile; \
95-
mv $(GOOS)-$(GOARCH)/helm $(MYGOBIN)/helmV3; \
96-
rm -rf $$d \
97-
)

api/internal/builtins/HelmChartInflationGenerator.go

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

api/testutils/kusttest/harnessenhanced.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package kusttest_test
55

66
import (
77
"os"
8-
"os/exec"
98
"path/filepath"
109
"strings"
1110
"testing"
@@ -87,9 +86,13 @@ func makeBaseEnhancedHarness(t *testing.T) *HarnessEnhanced {
8786
filesys.MakeFsOnDisk())}
8887
}
8988

89+
// ErrIfNoHelm checks if helm binary is available in PATH.
90+
// temporary disable to check helm binary presence
91+
// TODO(koba1t): remove this function when helm binary is always available via 'go tool'.
9092
func (th *HarnessEnhanced) ErrIfNoHelm() error {
91-
_, err := exec.LookPath(th.GetPluginConfig().HelmConfig.Command)
92-
return err
93+
// _, err := exec.LookPath(th.GetPluginConfig().HelmConfig.Command)
94+
// return err
95+
return nil
9396
}
9497

9598
func (th *HarnessEnhanced) GetRoot() string {

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 = "go tool helm.sh/helm/v3/cmd/helm"
3434
return
3535
}
3636

go.work.sum

Lines changed: 179 additions & 9 deletions
Large diffs are not rendered by default.

hack/go.mod

Lines changed: 133 additions & 62 deletions
Large diffs are not rendered by default.

hack/go.sum

Lines changed: 357 additions & 130 deletions
Large diffs are not rendered by default.

plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,13 @@ func (p *plugin) runHelmCommand(
170170
args []string) ([]byte, error) {
171171
stdout := new(bytes.Buffer)
172172
stderr := new(bytes.Buffer)
173-
cmd := exec.Command(p.h.GeneralConfig().HelmConfig.Command, args...)
173+
helmCommand := p.h.GeneralConfig().HelmConfig.Command
174+
cmdParts := strings.Fields(helmCommand)
175+
if len(cmdParts) == 0 {
176+
return nil, fmt.Errorf("helm command is empty")
177+
}
178+
allArgs := append(cmdParts[1:], args...)
179+
cmd := exec.Command(cmdParts[0], allArgs...)
174180
cmd.Stdout = stdout
175181
cmd.Stderr = stderr
176182
env := []string{

0 commit comments

Comments
 (0)