diff options
author | Luke Kanies <luke@madstop.com> | 2007-09-20 17:31:03 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-09-20 17:31:03 -0500 |
commit | 4e8b6712b688b23d6cb33f5829d3b15fe9d6833c (patch) | |
tree | 8774cb607df0bad41c08ce03affa0f6148192e41 /lib/puppet | |
parent | 8212f88ce3ad2ddbc7e1e713111d9478171c42b8 (diff) | |
download | puppet-4e8b6712b688b23d6cb33f5829d3b15fe9d6833c.tar.gz puppet-4e8b6712b688b23d6cb33f5829d3b15fe9d6833c.tar.xz puppet-4e8b6712b688b23d6cb33f5829d3b15fe9d6833c.zip |
The unit tests for the newly-resurrected indirection class
now work; all we need do is fix the indirector module tests.
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/indirector/indirection.rb | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb index 67b8a9d48..7128346ac 100644 --- a/lib/puppet/indirector/indirection.rb +++ b/lib/puppet/indirector/indirection.rb @@ -8,7 +8,6 @@ class Puppet::Indirector::Indirection end attr_accessor :name, :termini - attr_reader :to # Clear our cached list of termini. # This is only used for testing. @@ -31,34 +30,44 @@ class Puppet::Indirector::Indirection end end @termini = {} + raise(ArgumentError, "Indirection %s is already defined" % @name) if @@indirections.find { |i| i.name == @name } @@indirections << self end # Return the singleton terminus for this indirection. - def terminus(name = nil) + def terminus(terminus_name = nil) # Get the name of the terminus. - unless name - unless param_name = self.to - raise ArgumentError, "You must specify an indirection terminus for indirection %s" % self.name + unless terminus_name + param_name = "%s_terminus" % self.name + if Puppet.config.valid?(param_name) + terminus_name = Puppet.config[param_name] + else + terminus_name = Puppet[:default_terminus] end - name = Puppet[param_name] - name = name.intern if name.is_a?(String) + unless terminus_name and terminus_name.to_s != "" + raise ArgumentError, "Invalid terminus name %s" % terminus_name.inspect + end + terminus_name = terminus_name.intern if terminus_name.is_a?(String) end - unless @termini[name] - @termini[name] = make_terminus(name) - end - @termini[name] + return @termini[terminus_name] ||= make_terminus(terminus_name) end - # Validate the parameter. This requires that indirecting - # classes require 'puppet/defaults', because of ordering issues, - # but it makes problems much easier to debug. - def to=(param_name) - unless Puppet.config.valid?(param_name) - raise ArgumentError, "Configuration parameter '%s' for indirection '%s' does not exist'" % [param_name, self.name] - end - @to = param_name + def find(*args) + terminus.find(*args) + end + + def destroy(*args) + terminus.destroy(*args) + end + + def search(*args) + terminus.search(*args) + end + + # these become instance methods + def save(*args) + terminus.save(*args) end private |