Repository: helm/helm
Pull request #8759 (2020-09-17 18:47:31)

fix(cmd/helm): add build tags for architecture


Patch:
diff --git a/cmd/helm/root_unix.go b/cmd/helm/root_unix.go
index 210842b35..4eb0b442b 100644
--- a/cmd/helm/root_unix.go
+++ b/cmd/helm/root_unix.go
@@ -1,3 +1,5 @@
+// +build !windows
+
 /*
 Copyright The Helm Authors.
 
diff --git a/pkg/plugin/plugin.go b/pkg/plugin/plugin.go
index 93b5527a1..9bac2244c 100644
--- a/pkg/plugin/plugin.go
+++ b/pkg/plugin/plugin.go
@@ -96,12 +96,6 @@ type Metadata struct {
 	// Downloaders field is used if the plugin supply downloader mechanism
 	// for special protocols.
 	Downloaders []Downloaders `json:"downloaders"`
-
-	// UseTunnelDeprecated indicates that this command needs a tunnel.
-	// Setting this will cause a number of side effects, such as the
-	// automatic setting of HELM_HOST.
-	// DEPRECATED and unused, but retained for backwards compatibility with Helm 2 plugins. Remove in Helm 4
-	UseTunnelDeprecated bool `json:"useTunnel,omitempty"`
 }
 
 // Plugin represents a plugin.
@@ -206,7 +200,7 @@ func LoadDir(dirname string) (*Plugin, error) {
 	}
 
 	plug := &Plugin{Dir: dirname}
-	if err := yaml.UnmarshalStrict(data, &plug.Metadata); err != nil {
+	if err := yaml.Unmarshal(data, &plug.Metadata); err != nil {
 		return nil, errors.Wrapf(err, "failed to load plugin at %q", pluginfile)
 	}
 	return plug, validatePluginData(plug, pluginfile)


Test patch:
diff --git a/cmd/helm/root_unix_test.go b/cmd/helm/root_unix_test.go
index 73f18ec28..b1fcfbc66 100644
--- a/cmd/helm/root_unix_test.go
+++ b/cmd/helm/root_unix_test.go
@@ -1,3 +1,5 @@
+// +build !windows
+
 /*
 Copyright The Helm Authors.
 
diff --git a/pkg/plugin/installer/local_installer_test.go b/pkg/plugin/installer/local_installer_test.go
index 96958ab09..3d9607331 100644
--- a/pkg/plugin/installer/local_installer_test.go
+++ b/pkg/plugin/installer/local_installer_test.go
@@ -37,7 +37,7 @@ func TestLocalInstaller(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	source := "../testdata/plugdir/good/echo"
+	source := "../testdata/plugdir/echo"
 	i, err := NewForSource(source, "")
 	if err != nil {
 		t.Fatalf("unexpected error: %s", err)
diff --git a/pkg/plugin/installer/vcs_installer_test.go b/pkg/plugin/installer/vcs_installer_test.go
index 6785264b3..b8dc6b1e2 100644
--- a/pkg/plugin/installer/vcs_installer_test.go
+++ b/pkg/plugin/installer/vcs_installer_test.go
@@ -56,7 +56,7 @@ func TestVCSInstaller(t *testing.T) {
 	}
 
 	source := "https://github.com/adamreese/helm-env"
-	testRepoPath, _ := filepath.Abs("../testdata/plugdir/good/echo")
+	testRepoPath, _ := filepath.Abs("../testdata/plugdir/echo")
 	repo := &testRepo{
 		local: testRepoPath,
 		tags:  []string{"0.1.0", "0.1.1"},
diff --git a/pkg/plugin/plugin_test.go b/pkg/plugin/plugin_test.go
index 2c4478953..88add037d 100644
--- a/pkg/plugin/plugin_test.go
+++ b/pkg/plugin/plugin_test.go
@@ -178,7 +178,7 @@ func TestNoMatchPrepareCommand(t *testing.T) {
 }
 
 func TestLoadDir(t *testing.T) {
-	dirname := "testdata/plugdir/good/hello"
+	dirname := "testdata/plugdir/hello"
 	plug, err := LoadDir(dirname)
 	if err != nil {
 		t.Fatalf("error loading Hello plugin: %s", err)
@@ -205,15 +205,8 @@ func TestLoadDir(t *testing.T) {
 	}
 }
 
-func TestLoadDirDuplicateEntries(t *testing.T) {
-	dirname := "testdata/plugdir/bad/duplicate-entries"
-	if _, err := LoadDir(dirname); err == nil {
-		t.Errorf("successfully loaded plugin with duplicate entries when it should've failed")
-	}
-}
-
 func TestDownloader(t *testing.T) {
-	dirname := "testdata/plugdir/good/downloader"
+	dirname := "testdata/plugdir/downloader"
 	plug, err := LoadDir(dirname)
 	if err != nil {
 		t.Fatalf("error loading Hello plugin: %s", err)
@@ -251,7 +244,7 @@ func TestLoadAll(t *testing.T) {
 		t.Fatalf("expected empty dir to have 0 plugins")
 	}
 
-	basedir := "testdata/plugdir/good"
+	basedir := "testdata/plugdir"
 	plugs, err := LoadAll(basedir)
 	if err != nil {
 		t.Fatalf("Could not load %q: %s", basedir, err)
@@ -295,7 +288,7 @@ func TestFindPlugins(t *testing.T) {
 		},
 		{
 			name:     "normal",
-			plugdirs: "./testdata/plugdir/good",
+			plugdirs: "./testdata/plugdir",
 			expected: 3,
 		},
 	}
diff --git a/pkg/plugin/testdata/plugdir/bad/duplicate-entries/plugin.yaml b/pkg/plugin/testdata/plugdir/bad/duplicate-entries/plugin.yaml
deleted file mode 100644
index 66498be96..000000000
--- a/pkg/plugin/testdata/plugdir/bad/duplicate-entries/plugin.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
-name: "duplicate-entries"
-version: "0.1.0"
-usage: "usage"
-description: |-
-  description
-command: "echo hello"
-ignoreFlags: true
-hooks:
-  install: "echo installing..."
-hooks:
-  install: "echo installing something different"
diff --git a/pkg/plugin/testdata/plugdir/good/downloader/plugin.yaml b/pkg/plugin/testdata/plugdir/downloader/plugin.yaml
similarity index 100%
rename from pkg/plugin/testdata/plugdir/good/downloader/plugin.yaml
rename to pkg/plugin/testdata/plugdir/downloader/plugin.yaml
diff --git a/pkg/plugin/testdata/plugdir/good/echo/plugin.yaml b/pkg/plugin/testdata/plugdir/echo/plugin.yaml
similarity index 100%
rename from pkg/plugin/testdata/plugdir/good/echo/plugin.yaml
rename to pkg/plugin/testdata/plugdir/echo/plugin.yaml
diff --git a/pkg/plugin/testdata/plugdir/good/hello/hello.sh b/pkg/plugin/testdata/plugdir/hello/hello.sh
similarity index 100%
rename from pkg/plugin/testdata/plugdir/good/hello/hello.sh
rename to pkg/plugin/testdata/plugdir/hello/hello.sh
diff --git a/pkg/plugin/testdata/plugdir/good/hello/plugin.yaml b/pkg/plugin/testdata/plugdir/hello/plugin.yaml
similarity index 85%
rename from pkg/plugin/testdata/plugdir/good/hello/plugin.yaml
rename to pkg/plugin/testdata/plugdir/hello/plugin.yaml
index 2b972da59..6a78756d3 100644
--- a/pkg/plugin/testdata/plugdir/good/hello/plugin.yaml
+++ b/pkg/plugin/testdata/plugdir/hello/plugin.yaml
@@ -5,5 +5,6 @@ description: |-
   description
 command: "$HELM_PLUGIN_SELF/hello.sh"
 ignoreFlags: true
+install: "echo installing..."
 hooks:
   install: "echo installing..."