Skip to content

Commit

Permalink
fix(cli): Fix panic on argo template lint without argument (argoproj#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sarabala1979 committed Oct 20, 2020
1 parent 640998e commit aa4a435
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/argo/commands/template/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ func NewLintCommand() *cobra.Command {
Use: "lint (DIRECTORY | FILE1 FILE2 FILE3...)",
Short: "validate a file or directory of workflow template manifests",
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
cmd.HelpFunc()(cmd, args)
os.Exit(1)
}
err := ServerSideLint(args, strict)
if err != nil {
log.Fatal(err)
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,14 @@ func (s *CLIWithServerSuite) TestWorkflowWatch() {
}

func (s *CLISuite) TestTemplate() {
s.Run("LintWithoutArgs", func() {
s.Given().RunCli([]string{"template", "lint"}, func(t *testing.T, output string, err error) {
if assert.Error(t, err) {
assert.Contains(t, output, "Usage:")
}
})
})

s.Run("Lint", func() {
s.Given().RunCli([]string{"template", "lint", "smoke/workflow-template-whalesay-template.yaml"}, func(t *testing.T, output string, err error) {
if assert.NoError(t, err) {
Expand Down

0 comments on commit aa4a435

Please sign in to comment.