goss-org / goss

Quick and Easy server testing/validation
https://goss.rocks
Apache License 2.0
5.55k stars 473 forks source link

Global parameter `-g` yields "flag provided but not defined" #569

Closed AlienAstronaut closed 4 years ago

AlienAstronaut commented 4 years ago

Describe the bug

I'm attempting to install Goss across a large environment (Mostly Redhat 7 machines) as a service using systemd. Debugging this took quite some time because Goss doesn't support distinct exit codes yet, but in my problem solving I found that Goss doesn't find the global parameter -g --gossfile acceptable.

How To Reproduce

Execute Goss v0.3.10 with the commands noted below in "Actual Behavior"

Expected Behavior

Expected Goss to behave according to the documentation, in that the options -g and --gossfile would read in the provided YAML file without issues (excluding YAML formatting or FileNotFound errors).

# ./goss -h
NAME:
   goss - Quick and Easy server validation

USAGE:
   goss [global options] command [command options] [arguments...]

VERSION:
   v0.3.10

GLOBAL OPTIONS:
   --gossfile value, -g value  Goss file to read from / write to (default: "./goss.yaml") [$GOSS_FILE]
   --vars value                json/yaml file containing variables for template [$GOSS_VARS]
   --vars-inline value         json/yaml string containing variables for template (overwrites vars) [$GOSS_VARS_INLINE]
   --package value             Package type to use [rpm, deb, apk, pacman]
   --help, -h                  show help
   --version, -v               print the version

Actual Behavior

Attempted to run base command from /opt/goss/ as working directory, using both the -g and --gossfile parameters, varying the order.

./goss serve -f json --gossfile /opt/goss/goss.yml 2020/04/03 11:57:51 flag provided but not defined: -gossfile

./goss serve -f json -g /opt/goss/goss.yml 2020/04/03 12:01:32 flag provided but not defined: -g

./goss serve --gossfile /opt/goss/goss.yml -f json 2020/04/03 12:02:01 flag provided but not defined: -gossfile

./goss serve -g /opt/goss/goss.yml -f json 2020/04/03 12:05:46 flag provided but not defined: -g

Environment:

Goss Version: v0.3.10 OS Version: Red Hat Enterprise Linux Server release 7.6 (Maipo) Uname Output: Linux ****************** 3.10.0-957.21.2.el7.x86_64 x86_64 x86_64 x86_64 GNU/Linux Ansible Version: v2.8.0

AlienAstronaut commented 4 years ago

I'd like to also note, the service still works because the default action is to look in the working directory for a gossfile, but we'd like to be able to specify it in the future.

aelsabbahy commented 4 years ago

Not on a computer to send exact command at the moment.

Given: goss [global options] command [command options] [arguments...]

Does the following work? goss -g /opt/goss/goss.yml serve [serve options]

AlienAstronaut commented 4 years ago

Wow, RTFM to me. Quarantine is killing my brain cells. Thank you, that's what I was doing wrong.

aelsabbahy commented 4 years ago

Lol, all good. Glad I was able to help/unblock you. :)