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

fix(helm): Validate number of arguments in install client
pull/6842/head
Matthew Fisher 5 years ago committed by GitHub
commit f4f5b2e46f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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()
}

@ -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) {

Loading…
Cancel
Save