Merge pull request #7240 from Blokje5/fix/incorrect-error-message-in-helm-install

fix(helm): Validate number of arguments in install client
This commit is contained in:
Matthew Fisher
2019-12-16 09:26:50 -08:00
committed by GitHub
2 changed files with 12 additions and 0 deletions

View File

@@ -555,6 +555,10 @@ func (i *Install) NameAndChart(args []string) (string, string, error) {
return nil
}
if len(args) > 2 {
return args[0], args[1], errors.Errorf("expected at most two arguments, unexpected arguments: %v", strings.Join(args[2:], ", "))
}
if len(args) == 2 {
return args[0], args[1], flagsNotSet()
}

View File

@@ -505,6 +505,14 @@ func TestNameAndChart(t *testing.T) {
t.Fatal("expected an error")
}
is.Equal("must either provide a name or specify --generate-name", err.Error())
instAction.NameTemplate = ""
instAction.ReleaseName = ""
_, _, err = instAction.NameAndChart([]string{"foo", chartName, "bar"})
if err == nil {
t.Fatal("expected an error")
}
is.Equal("expected at most two arguments, unexpected arguments: bar", err.Error())
}
func TestNameAndChartGenerateName(t *testing.T) {