Skip to content

Commit

Permalink
Make empty goss.yaml error. Drop implicit STDIN (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
aelsabbahy authored Aug 4, 2016
1 parent a76b9a7 commit d4926ce
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ func getGossConfig(c *cli.Context) GossConfig {
// handle stdin
var fh *os.File
var err error
var path string
if !c.GlobalIsSet("gossfile") && hasStdin() {
var path, source string
specFile := c.GlobalString("gossfile")
if specFile == "-" {
source = "STDIN"
fh = os.Stdin
} else {
specFile := c.GlobalString("gossfile")
source = specFile
path = filepath.Dir(specFile)
fh, err = os.Open(specFile)
if err != nil {
Expand All @@ -38,6 +40,10 @@ func getGossConfig(c *cli.Context) GossConfig {
os.Exit(1)
}
gossConfig := mergeJSONData(ReadJSONData(data), 0, path)
if len(gossConfig.Resources()) == 0 {
fmt.Printf("Error: found 0 tests, source: %v\n", source)
os.Exit(1)
}
return gossConfig
}

Expand Down Expand Up @@ -114,13 +120,3 @@ func validate(sys *system.System, gossConfig GossConfig) <-chan []resource.TestR

return out
}

func hasStdin() bool {
if fi, err := os.Stdin.Stat(); err == nil {
mode := fi.Mode()
if (mode&os.ModeNamedPipe != 0) || mode.IsRegular() {
return true
}
}
return false
}

0 comments on commit d4926ce

Please sign in to comment.