Skip to content

Commit

Permalink
Fix #89, where - didn't trigger stdin parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
garethr committed Aug 21, 2018
1 parent fa79615 commit 0ff857e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
6 changes: 6 additions & 0 deletions acceptance.bats
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 0ff857e

Please sign in to comment.