summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-07-21 16:34:20 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-07-22 13:29:29 -0700
commit2cd3bc47993fbd32a77ca9dfdd51353f2dfbcb58 (patch)
treec38b1533e7221ee62325ea68d3cd10848dc8d9f2 /lib/puppet
parent1e0655e6bdbc872014abdffa5deacb334616e826 (diff)
downloadpuppet-2cd3bc47993fbd32a77ca9dfdd51353f2dfbcb58.tar.gz
puppet-2cd3bc47993fbd32a77ca9dfdd51353f2dfbcb58.tar.xz
puppet-2cd3bc47993fbd32a77ca9dfdd51353f2dfbcb58.zip
(#7184) Find actions bound to other versions of Faces.
When we first touch a Face, we load all the available Actions from disk. Given they define themselves against a specific version of a Face, they are automatically available tied to the correct version; this makes it trivially possible to locate those on demand and return them. Now, we have the ability to find and, consequently, invoke Actions on older versions of Faces. We don't load enough context, though: the older face will only have external Actions defined, not anything core. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/interface/face_collection.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/puppet/interface/face_collection.rb b/lib/puppet/interface/face_collection.rb
index ddc66f583..868997b67 100644
--- a/lib/puppet/interface/face_collection.rb
+++ b/lib/puppet/interface/face_collection.rb
@@ -20,12 +20,19 @@ 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)
+ def self.get_action_for_face(name, action_name, version)
+ name = underscorize(name)
+
# 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]
+ return nil unless face = self[name, version]
unless action = face.get_action(action_name)
- # ...we need to search for it bound to an o{lder,ther} version.
+ # ...we need to search for it bound to an o{lder,ther} version. Since
+ # we load all actions when the face is first references, this will be in
+ # memory in the known set of versions of the face.
+ (@faces[name].keys - [ :current ]).sort.reverse.each do |version|
+ break if action = @faces[name][version].get_action(action_name)
+ end
end
return action