summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-04-15 15:18:13 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-04-15 15:25:10 -0700
commitab541fa0976bdce395a072bf0c391146b99d4219 (patch)
tree245995c3980fcb059b1ddba5c8c84ace3af53bf2 /lib
parentf770325884ebef493cb8ca6060a65355211125b9 (diff)
downloadpuppet-ab541fa0976bdce395a072bf0c391146b99d4219.tar.gz
puppet-ab541fa0976bdce395a072bf0c391146b99d4219.tar.xz
puppet-ab541fa0976bdce395a072bf0c391146b99d4219.zip
(#7059) Use option hooks for the indirector terminus option.
We used to open-code terminus setting, which had a bunch of duplicate code. Now, instead, we use the option hooks, resulting in the same behaviour with much less code. Paired-With: Max Martin <max@puppetlabs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/face/indirector.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/puppet/face/indirector.rb b/lib/puppet/face/indirector.rb
index f48611e4b..6c7708b51 100644
--- a/lib/puppet/face/indirector.rb
+++ b/lib/puppet/face/indirector.rb
@@ -5,6 +5,14 @@ class Puppet::Face::Indirector < Puppet::Face
option "--terminus TERMINUS" do
desc "REVISIT: You can select a terminus, which has some bigger effect
that we should describe in this file somehow."
+
+ before_action do |action, args, options|
+ set_terminus(options[:terminus])
+ end
+
+ after_action do |action, args, options|
+ indirection.reset_terminus_class
+ end
end
def self.indirections
@@ -17,7 +25,6 @@ that we should describe in this file somehow."
def call_indirection_method(method, *args)
options = args.last
- options.has_key?(:terminus) and set_terminus(options[:terminus])
begin
result = indirection.__send__(method, *args)
@@ -26,7 +33,6 @@ that we should describe in this file somehow."
raise "Could not call '#{method}' on '#{indirection_name}': #{detail}"
end
- indirection.reset_terminus_class
return result
end
@@ -49,16 +55,11 @@ that we should describe in this file somehow."
# Print the configuration for the current terminus class
action :info do
when_invoked do |*args|
- options = args.pop
- options.has_key?(:terminus) and set_terminus(options[:terminus])
-
if t = indirection.terminus_class
puts "Run mode '#{Puppet.run_mode.name}': #{t}"
else
$stderr.puts "No default terminus class for run mode '#{Puppet.run_mode.name}'"
end
-
- indirection.reset_terminus_class
end
end