Repository: helm/helm
Pull request #8055 (2020-05-05 10:00:44)

refactor: alter constant `pluginFileName` to `PluginFileName`
Alter constant `pluginFileName` to `PluginFileName` in order to reuse the "plugin.yaml" value in installer package and avoid magic value in installer.go

Signed-off-by: Liu Ming <hit_oak_tree@126.com>



Patch:
diff --git a/internal/version/version.go b/internal/version/version.go
index baa65a028..fd0616920 100644
--- a/internal/version/version.go
+++ b/internal/version/version.go
@@ -30,7 +30,7 @@ var (
 	// Increment major number for new feature additions and behavioral changes.
 	// Increment minor number for bug fixes and performance enhancements.
 	// Increment patch number for critical fixes to existing releases.
-	version = "v3.2"
+	version = "v3.1"
 
 	// metadata is extra build time data
 	metadata = ""
diff --git a/pkg/lint/rules/template.go b/pkg/lint/rules/template.go
index 787c5b26a..b76e4260a 100644
--- a/pkg/lint/rules/template.go
+++ b/pkg/lint/rules/template.go
@@ -81,6 +81,7 @@ func Templates(linter *support.Linter, values map[string]interface{}, namespace
 		return
 	}
 	var e engine.Engine
+	e.Strict = strict
 	e.LintMode = true
 	renderedContentMap, err := e.Render(chart, valuesToRender)
 
diff --git a/pkg/plugin/installer/installer.go b/pkg/plugin/installer/installer.go
index 65c61cd7d..61b49ab3b 100644
--- a/pkg/plugin/installer/installer.go
+++ b/pkg/plugin/installer/installer.go
@@ -23,6 +23,8 @@ import (
 	"strings"
 
 	"github.com/pkg/errors"
+
+	"helm.sh/helm/v3/pkg/plugin"
 )
 
 // ErrMissingMetadata indicates that plugin.yaml is missing.
@@ -100,7 +102,7 @@ func isRemoteHTTPArchive(source string) bool {
 
 // isPlugin checks if the directory contains a plugin.yaml file.
 func isPlugin(dirname string) bool {
-	_, err := os.Stat(filepath.Join(dirname, "plugin.yaml"))
+	_, err := os.Stat(filepath.Join(dirname, plugin.PluginFileName))
 	return err == nil
 }
 
diff --git a/pkg/plugin/plugin.go b/pkg/plugin/plugin.go
index 2eb354fca..caa34fbd3 100644
--- a/pkg/plugin/plugin.go
+++ b/pkg/plugin/plugin.go
@@ -28,7 +28,7 @@ import (
 	"helm.sh/helm/v3/pkg/cli"
 )
 
-const pluginFileName = "plugin.yaml"
+const PluginFileName = "plugin.yaml"
 
 // Downloaders represents the plugins capability if it can retrieve
 // charts from special sources
@@ -159,7 +159,7 @@ func (p *Plugin) PrepareCommand(extraArgs []string) (string, []string, error) {
 
 // LoadDir loads a plugin from the given directory.
 func LoadDir(dirname string) (*Plugin, error) {
-	data, err := ioutil.ReadFile(filepath.Join(dirname, pluginFileName))
+	data, err := ioutil.ReadFile(filepath.Join(dirname, PluginFileName))
 	if err != nil {
 		return nil, err
 	}
@@ -177,7 +177,7 @@ func LoadDir(dirname string) (*Plugin, error) {
 func LoadAll(basedir string) ([]*Plugin, error) {
 	plugins := []*Plugin{}
 	// We want basedir/*/plugin.yaml
-	scanpath := filepath.Join(basedir, "*", pluginFileName)
+	scanpath := filepath.Join(basedir, "*", PluginFileName)
 	matches, err := filepath.Glob(scanpath)
 	if err != nil {
 		return plugins, err


Test patch:
diff --git a/cmd/helm/testdata/output/version-client-shorthand.txt b/cmd/helm/testdata/output/version-client-shorthand.txt
index d613309fe..8f9ed6136 100644
--- a/cmd/helm/testdata/output/version-client-shorthand.txt
+++ b/cmd/helm/testdata/output/version-client-shorthand.txt
@@ -1,1 +1,1 @@
-version.BuildInfo{Version:"v3.2", GitCommit:"", GitTreeState:"", GoVersion:""}
+version.BuildInfo{Version:"v3.1", GitCommit:"", GitTreeState:"", GoVersion:""}
diff --git a/cmd/helm/testdata/output/version-client.txt b/cmd/helm/testdata/output/version-client.txt
index d613309fe..8f9ed6136 100644
--- a/cmd/helm/testdata/output/version-client.txt
+++ b/cmd/helm/testdata/output/version-client.txt
@@ -1,1 +1,1 @@
-version.BuildInfo{Version:"v3.2", GitCommit:"", GitTreeState:"", GoVersion:""}
+version.BuildInfo{Version:"v3.1", GitCommit:"", GitTreeState:"", GoVersion:""}
diff --git a/cmd/helm/testdata/output/version-short.txt b/cmd/helm/testdata/output/version-short.txt
index 4d5034cea..861668947 100644
--- a/cmd/helm/testdata/output/version-short.txt
+++ b/cmd/helm/testdata/output/version-short.txt
@@ -1,1 +1,1 @@
-v3.2
+v3.1
diff --git a/cmd/helm/testdata/output/version-template.txt b/cmd/helm/testdata/output/version-template.txt
index 7c09e8d57..e5a779bbf 100644
--- a/cmd/helm/testdata/output/version-template.txt
+++ b/cmd/helm/testdata/output/version-template.txt
@@ -1,1 +1,1 @@
-Version: v3.2
\ No newline at end of file
+Version: v3.1
\ No newline at end of file
diff --git a/cmd/helm/testdata/output/version.txt b/cmd/helm/testdata/output/version.txt
index d613309fe..8f9ed6136 100644
--- a/cmd/helm/testdata/output/version.txt
+++ b/cmd/helm/testdata/output/version.txt
@@ -1,1 +1,1 @@
-version.BuildInfo{Version:"v3.2", GitCommit:"", GitTreeState:"", GoVersion:""}
+version.BuildInfo{Version:"v3.1", GitCommit:"", GitTreeState:"", GoVersion:""}
diff --git a/pkg/lint/rules/template_test.go b/pkg/lint/rules/template_test.go
index 991c6c2f6..1a047edf2 100644
--- a/pkg/lint/rules/template_test.go
+++ b/pkg/lint/rules/template_test.go
@@ -174,55 +174,3 @@ func TestDeprecatedAPIFails(t *testing.T) {
 		t.Errorf("Surprised to learn that %q is deprecated", err.Deprecated)
 	}
 }
-
-const manifest = `apiVersion: v1
-kind: ConfigMap
-metadata:
-  name: foo
-data:
-  myval1: {{default "val" .Values.mymap.key1 }}
-  myval2: {{default "val" .Values.mymap.key2 }}
-`
-
-// TestSTrictTemplatePrasingMapError is a regression test.
-//
-// The template engine should not produce an error when a map in values.yaml does
-// not contain all possible keys.
-//
-// See https://github.com/helm/helm/issues/7483
-func TestStrictTemplateParsingMapError(t *testing.T) {
-
-	ch := chart.Chart{
-		Metadata: &chart.Metadata{
-			Name:       "regression7483",
-			APIVersion: "v2",
-			Version:    "0.1.0",
-		},
-		Values: map[string]interface{}{
-			"mymap": map[string]string{
-				"key1": "val1",
-			},
-		},
-		Templates: []*chart.File{
-			{
-				Name: "templates/configmap.yaml",
-				Data: []byte(manifest),
-			},
-		},
-	}
-	dir := ensure.TempDir(t)
-	defer os.RemoveAll(dir)
-	if err := chartutil.SaveDir(&ch, dir); err != nil {
-		t.Fatal(err)
-	}
-	linter := &support.Linter{
-		ChartDir: filepath.Join(dir, ch.Metadata.Name),
-	}
-	Templates(linter, ch.Values, namespace, strict)
-	if len(linter.Messages) != 0 {
-		t.Errorf("expected zero messages, got %d", len(linter.Messages))
-		for i, msg := range linter.Messages {
-			t.Logf("Message %d: %q", i, msg)
-		}
-	}
-}