Skip to content

Commit

Permalink
Merge pull request #90 from garethr/fix-slash-stdin-parsing
Browse files Browse the repository at this point in the history
Fix #89, where - didn't trigger stdin parsing
  • Loading branch information
garethr committed Aug 21, 2018
2 parents fa79615 + 0ff857e commit c44f519
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
6 changes: 6 additions & 0 deletions acceptance.bats
Expand Up @@ -12,6 +12,12 @@
[ "$output" = "The document stdin contains a valid ReplicationController" ]
}

@test "Pass when parsing a valid Kubernetes config YAML file explicitly on stdin" {
run bash -c "cat fixtures/valid.yaml | kubeval -"
[ "$status" -eq 0 ]
[ "$output" = "The document stdin contains a valid ReplicationController" ]
}

@test "Pass when parsing a valid Kubernetes config JSON file" {
run kubeval fixtures/valid.json
[ "$status" -eq 0 ]
Expand Down
3 changes: 2 additions & 1 deletion cmd/root.go
Expand Up @@ -40,7 +40,8 @@ var RootCmd = &cobra.Command{
}
}
// We detect whether we have anything on stdin to process if we have no arguments
if len(args) < 1 && !windowsStdinIssue && ((stat.Mode() & os.ModeCharDevice) == 0) {
// or if the argument is a -
if (len(args) < 1 || args[0] == "-") && !windowsStdinIssue && ((stat.Mode() & os.ModeCharDevice) == 0) {
var buffer bytes.Buffer
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
Expand Down
47 changes: 24 additions & 23 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c44f519

Please sign in to comment.