diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-07-21 15:34:52 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-07-22 13:29:25 -0700 |
| commit | 1e0655e6bdbc872014abdffa5deacb334616e826 (patch) | |
| tree | e855a5823898d78668a860abae681dc88cd1282e /lib/puppet/interface | |
| parent | 039661156116cb6d3c5c8e372ed4d81af221453b (diff) | |
| download | puppet-1e0655e6bdbc872014abdffa5deacb334616e826.tar.gz puppet-1e0655e6bdbc872014abdffa5deacb334616e826.tar.xz puppet-1e0655e6bdbc872014abdffa5deacb334616e826.zip | |
(#7184) Centralize "find action for face" into Puppet::Face
As part of moving to load actions first, and their associated face, when
invoked from the command line, it makes sense to push the logic for finding
the action and face down into the Puppet::Face implementation.
This means that we can change the logic there without needing to update the
public part of the CLI implementation, and that any further facades can use
the same, correct, logic to locate the action for the face.
Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
Diffstat (limited to 'lib/puppet/interface')
| -rw-r--r-- | lib/puppet/interface/action.rb | 1 | ||||
| -rw-r--r-- | lib/puppet/interface/face_collection.rb | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb index fc1121eb6..ce9c60b49 100644 --- a/lib/puppet/interface/action.rb +++ b/lib/puppet/interface/action.rb @@ -38,6 +38,7 @@ class Puppet::Interface::Action def to_s() "#{@face}##{@name}" end attr_reader :name + attr_reader :face attr_accessor :default def default? !!@default diff --git a/lib/puppet/interface/face_collection.rb b/lib/puppet/interface/face_collection.rb index 4522824fd..ddc66f583 100644 --- a/lib/puppet/interface/face_collection.rb +++ b/lib/puppet/interface/face_collection.rb @@ -20,6 +20,17 @@ module Puppet::Interface::FaceCollection get_face(name, version) or load_face(name, version) end + def self.get_action_for_face(face_name, action_name, version) + # If the version they request specifically doesn't exist, don't search + # elsewhere. Usually this will start from :current and all... + return nil unless face = self[face_name, version] + unless action = face.get_action(action_name) + # ...we need to search for it bound to an o{lder,ther} version. + end + + return action + end + # get face from memory, without loading. def self.get_face(name, pattern) return nil unless @faces.has_key? name |
