diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-07-22 16:26:10 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-07-22 16:27:23 -0700 |
| commit | ae360034c07f9b16467f5ae245ac6d037789ee13 (patch) | |
| tree | ccc4cc8212e4948022c8e7738858eb8ee0add25a /lib | |
| parent | 88e9cd2138e9f23e056bd3331498a6d4723a8b0c (diff) | |
| download | puppet-ae360034c07f9b16467f5ae245ac6d037789ee13.tar.gz puppet-ae360034c07f9b16467f5ae245ac6d037789ee13.tar.xz puppet-ae360034c07f9b16467f5ae245ac6d037789ee13.zip | |
(#7290) Update indirected Faces to avoid unknown options.
Now that we enforce that options must be declared, the model we exposed in the
Ruby API (but not the CLI facade) was that you could pass additional arguments
to the indirection method by passing them as unknown options doesn't work.
Instead, explicitly declare an option, `extra`, that accepts the final
argument to be passed direct to the indirection. This makes things work
smoothly, as well as making it possible (once you can input a hash on the
command line) to invoke extra arguments from the facade too...
Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/indirector/face.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/puppet/indirector/face.rb b/lib/puppet/indirector/face.rb index b4cac5c51..adb6b688b 100644 --- a/lib/puppet/indirector/face.rb +++ b/lib/puppet/indirector/face.rb @@ -48,16 +48,26 @@ class Puppet::Indirector::Face < Puppet::Face return result end + option "--extra HASH" do + summary "Extra arguments to pass to the indirection request" + description <<-end + A terminus can take additional arguments to refine the operation, which + are passed as an arbitrary hash to the back-end. Anything passed as + the extra value is just send direct to the back-end. + end + default_to do Hash.new end + end + action :destroy do summary "Delete an object." arguments "<key>" - when_invoked { |key, options| call_indirection_method(:destroy, key, options) } + when_invoked {|key, options| call_indirection_method :destroy, key, options[:extra] } end action :find do summary "Retrieve an object by name." arguments "<key>" - when_invoked { |key, options| call_indirection_method(:find, key, options) } + when_invoked {|key, options| call_indirection_method :find, key, options[:extra] } end action :save do @@ -68,13 +78,13 @@ class Puppet::Indirector::Face < Puppet::Face currently accept data from STDIN, save actions cannot currently be invoked from the command line. EOT - when_invoked { |key, options| call_indirection_method(:save, key, options) } + when_invoked {|key, options| call_indirection_method :save, key, options[:extra] } end action :search do summary "Search for an object or retrieve multiple objects." arguments "<query>" - when_invoked { |key, options| call_indirection_method(:search, key, options) } + when_invoked {|key, options| call_indirection_method :search, key, options[:extra] } end # Print the configuration for the current terminus class |
