Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

goss blows up if command exit-status is misnamed #71

Closed
shalomb opened this issue Apr 8, 2016 · 2 comments
Closed

goss blows up if command exit-status is misnamed #71

shalomb opened this issue Apr 8, 2016 · 2 comments

Comments

@shalomb
Copy link

shalomb commented Apr 8, 2016

Took me quite a while to figure out what was wrong here

$ cat bad.yaml

---
service:
  sshd:
    enabled: true
    running: true
command:
  uname -a:
    exit-code: 0
$ goss -g bad.yaml v
panic: Unexpected matcher type: <nil>

goroutine 6 [running]:
github.com/aelsabbahy/goss/resource.matcherToGomegaMatcher(0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/travis/gopath/src/github.com/aelsabbahy/goss/resource/gomega.go:28 +0x333
github.com/aelsabbahy/goss/resource.ValidateValue(0x7f8bcf45dab8, 0xc82004ec40, 0x7d5bf0, 0xb, 0x0, 0x0, 0x6dcc80, 0xc82000f700, 0x0, 0x0, ...)
        /home/travis/gopath/src/github.com/aelsabbahy/goss/resource/validate.go:66 +0x3f9
github.com/aelsabbahy/goss/resource.(*Command).Validate(0xc82004ec40, 0xc820078640, 0x0, 0x0, 0x0)
        /home/travis/gopath/src/github.com/aelsabbahy/goss/resource/command.go:38 +0x350
github.com/aelsabbahy/goss.Validate.func2(0xc820013e00, 0xc82000b320, 0xc82000b2c0, 0xc820078640)
        /home/travis/gopath/src/github.com/aelsabbahy/goss/validate.go:69 +0xb3
created by github.com/aelsabbahy/goss.Validate
        /home/travis/gopath/src/github.com/aelsabbahy/goss/validate.go:72 +0x471

... output truncated

I then generated a yaml file using autoadd to diff this file .. turns out I wanted to use exit-status not exit-code

diff -Naur bad.yaml good.yaml                 
--- bad.yaml    2016-04-08 16:06:38.210776099 +0200
+++ good.yaml   2016-04-08 16:14:38.606694865 +0200
@@ -1,8 +1,11 @@
 ---
+
 service:
   sshd:
     enabled: true
     running: true
+
 command:
   uname -a:
-    exit-code: 0
+    exit-status: 0
+

So a clear PEBKAC error :) but please can we make goss handle invalid input a bit better and give the user a clearer error message? This took me a good 45 minutes to figure out.

@aelsabbahy
Copy link
Member

Sorry for the inconvenience, this is definitely not desired and looks like it was introduced sometime during the gomega changes.

Thanks for filing this.

@aelsabbahy
Copy link
Member

Fixed in v0.1.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants