Skip to content

Commit

Permalink
use the name from the chart as default if none is specified
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Richter <[email protected]>
  • Loading branch information
Christian authored and dragonchaser committed Mar 11, 2021
1 parent aa80681 commit 8116441
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
7 changes: 3 additions & 4 deletions cmd/hypper/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ func TestInstallCmd(t *testing.T) {
},
// Install, no name or annotations specified
{
name: "install, with no name or annot specified",
cmd: "install testdata/testcharts/vanilla-helm",
golden: "output/install-no-name-or-annot.txt",
wantError: true,
name: "install, with no name or annot specified",
cmd: "install testdata/testcharts/vanilla-helm",
golden: "output/install-no-name-or-annot.txt",
},
}
runTestActionCmd(t, tests)
Expand Down
3 changes: 2 additions & 1 deletion cmd/hypper/testdata/output/install-no-name-or-annot.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Error: must either provide a name, set the correct chart annotations, or specify --generate-name
Installing chart "empty" in namespace "default"…
Done! 👏
2 changes: 1 addition & 1 deletion pkg/action/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (i *Install) Name(chart *chart.Chart, args []string) (string, error) {
}

if !i.GenerateName {
return "", errors.New("must either provide a name, set the correct chart annotations, or specify --generate-name")
return chart.Name(), nil
}

base := filepath.Base(args[0])
Expand Down
6 changes: 3 additions & 3 deletions pkg/action/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ func TestName(t *testing.T) {
instAction.ReleaseName = ""
chart = buildChart()
_, err = instAction.Name(chart, []string{"chart-uri"})
if err == nil {
t.Fatal("expected an error")
if err != nil {
t.Fatal(err)
}
is.Equal("must either provide a name, set the correct chart annotations, or specify --generate-name", err.Error())
is.Equal("fleet", name)
}

func TestNameGenerateName(t *testing.T) {
Expand Down

0 comments on commit 8116441

Please sign in to comment.