HomePhorge

(#7122) Enforce call arity on actions in the CLI wrapper.
69e4b1c5c024Unpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

(#7122) Enforce call arity on actions in the CLI wrapper.

We had a problem, previously, in the generic translation of command line
arguments to Ruby method calls: we could mistake the options, added by the CLI
wrapper, for a positional argument to the action method.

This was caused by a combination of factors, but primarily that the wrapper
methods for actions are designed to present a friendly, helpful Ruby API for
internal use. Consequently, they have a default value if you don't wish to
pass options.

Unfortunately, this meant that the options that the CLI *always* passed could
be treated as a positional argument instead, and the default set of options
added to the back of the call.

To resolve this we now check the number of positional arguments in the CLI
wrapper, and raise an exception if they are mismatched. This makes the
generic CLI handling do the right thing in adapting the command line
arguments to the Ruby API.

(As an aside, we would have had a similar-but-different failure mode if we
type-checked positional arguments: these calls would have failed with an
invalid argument validation error.)

Reviewed-By: Max Martin <max@puppetlabs.com>

Details

Provenance
Daniel Pittman <daniel@puppetlabs.com>Authored on
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPU351b6fc5327b: maint: add a 'print' matcher to rspec, to inspect std{out,err}
Branches
Unknown
Tags
Unknown

Event Timeline

Daniel Pittman <daniel@puppetlabs.com> committed rPU69e4b1c5c024: (#7122) Enforce call arity on actions in the CLI wrapper. (authored by Daniel Pittman <daniel@puppetlabs.com>).Apr 28 2011, 11:50 PM