Skip to content

Commit

Permalink
fix(cli): Show lint errors of all files (argoproj#2552)
Browse files Browse the repository at this point in the history
Co-authored-by: Simon Behar <[email protected]>
  • Loading branch information
Niklas Hansson and simster7 committed Apr 3, 2020
1 parent c3535ba commit 0801a42
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions cmd/argo/commands/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"os"
"path/filepath"

"github.com/argoproj/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/argoproj/argo/cmd/argo/commands/client"
workflowpkg "github.com/argoproj/argo/pkg/apiclient/workflow"
"github.com/argoproj/argo/workflow/validate"
"github.com/argoproj/pkg/errors"
)

func NewLintCommand() *cobra.Command {
Expand Down Expand Up @@ -40,24 +41,36 @@ func NewLintCommand() *cobra.Command {
return nil
}

var invalidWfErr error
for _, file := range args {
stat, err := os.Stat(file)
errors.CheckError(err)
if stat.IsDir() {
err := filepath.Walk(file, func(path string, info os.FileInfo, err error) error {
_ = filepath.Walk(file, func(path string, info os.FileInfo, err error) error {
fileExt := filepath.Ext(info.Name())
switch fileExt {
case ".yaml", ".yml", ".json":
default:
return nil
}
return lint(path)
err = lint(path)
if err != nil {
invalidWfErr = fmt.Errorf("Invalid workflow/workflows found")
log.Warn(err)
}
return nil
})
errors.CheckError(err)
} else {
err := lint(file)
errors.CheckError(err)
if err != nil {
invalidWfErr = fmt.Errorf("Invalid workflow/workflows found")
log.Warn(err)
}
}
err = nil
}
if invalidWfErr != nil {
errors.CheckError(invalidWfErr)
}
fmt.Printf("Workflow manifests validated\n")
},
Expand Down

0 comments on commit 0801a42

Please sign in to comment.