CiscoCloud / distributive

Unit testing for the cloud
Apache License 2.0
147 stars 20 forks source link

Make args more intuitive #67

Closed soellman closed 8 years ago

soellman commented 9 years ago

The behavior of -f and -d flags is weird. Maybe let's have a set of reasonable defaults?

I'd propose: if no flags - run all checks in /etc/distributive.d (default dir)

if dir specified - run all checks inside dir

if file specified

if both dir and file specified - do same as if just file was specified if stdin OR url specified - use them if more than one of (file and/or dir), stdin, and url is specified, complain and exit

Something like that. Thanks!

langston-barrett commented 9 years ago

Some of this is already the case. From the README:

The default behavior is to run all checks in /etc/distributive.d/ (the default directory give to the -d option), in addition to any specified via the -f -u, or -s options.

So, current behavior matches:

if no flags - run all checks in /etc/distributive.d (default dir)

  • fail if dir doesn't exist if dir specified - run all checks inside dir
  • fail if dir doesn't exist if file specified
  • absolute file exists - use it
  • relative file exists - use it
  • relative file exists in dir, use it
  • otherwise fail

Unimplemented and why:

if both dir and file specified - do same as if just file was specified if stdin OR url specified - use them if more than one of (file and/or dir), stdin, and url is specified, complain and exit

I like the flexibility of being able to specify each and every option you want independently of the others. I don't necessarily see why we would want to fail if, say, stdin AND url are specified. If I'm using this and I specify both, that probably means I want to use both.

Perhaps a halfway solution would be to add the flag --multiple=false, which would specify whether or not to use multiple sources at once, defaulting to false?

What are your thoughts @soellman?

soellman commented 9 years ago

Huh. Interesting. I guess I was assuming that if you wanted more than one way of doing things, you'd just call the binary more than once. Shame on me for not reading the readme more closely.. :)

I do see the benefit of having multiple methods at once although it doesn't fit my use case.

The dir handling feels odd though: what happens if you only want to run a single file, and you have an /etc/distributive.d? There's no way not to run the whole dir unless you specify -d '' ? That seems weird to me. And if you don't have an /etc/distributive.d, you need to specify a -d? That also seems weird. Maybe just don't default a dir, or only default if no flags are provided? -o

langston-barrett commented 9 years ago

@soellman I really like the idea of only defauting the dir if no other flags are provided. I agree that it is currently a pretty awkward setup, I've been thinking about changing it for a while, and I think we just found the solution :)

w/r/t having multiple sources: When using something like Consul or Kubernetes, the binary gets called once every so often on an interval. Having more configuration on each call might make more sense than setting up two intervals, if the two checklists are logically related. Does that sound about right?

soellman commented 9 years ago

Nice. yea I think only defaulting the dir if no flags are specified works pretty well.

And the way I'm using it with consul is having it defined as a check for each service, so it gets called once per service on an interval. I guess it all depends how granularly you specify your services. e.g. "network setup" vs "flanneld / autossh / whatever". I'm coming down on the side of more granular even if it takes slightly longer to execute.

langston-barrett commented 8 years ago

Closed in 396697e