diff options
author | Luke Kanies <luke@madstop.com> | 2008-06-14 13:53:56 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-06-14 13:53:56 -0500 |
commit | 6a61198f9293674a4bf0aa75bfbca10e20f64d20 (patch) | |
tree | 0b1b6c4ffe6e69c3c9d3e9650620e3afbd486f18 /lib/puppet/indirector/request.rb | |
parent | eaa6eabc680cb6264594e30fd6a56e3e36765269 (diff) | |
parent | 7b2c310e18b214424ae082e6ed2354a07b708c6f (diff) | |
download | puppet-6a61198f9293674a4bf0aa75bfbca10e20f64d20.tar.gz puppet-6a61198f9293674a4bf0aa75bfbca10e20f64d20.tar.xz puppet-6a61198f9293674a4bf0aa75bfbca10e20f64d20.zip |
Merge branch '0.24.x'
Also added the fixes to make the certhandler tests pass
even when certs exist; I'll deal with the conflict later.
Conflicts:
CHANGELOG
bin/puppetd
lib/puppet/network/http/handler.rb
lib/puppet/network/http/mongrel/rest.rb
spec/integration/indirector/rest.rb
spec/integration/network/server/mongrel.rb
spec/integration/network/server/webrick.rb
spec/unit/network/http/webrick.rb
Diffstat (limited to 'lib/puppet/indirector/request.rb')
-rw-r--r-- | lib/puppet/indirector/request.rb | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb index 68b7ee160..98fa38885 100644 --- a/lib/puppet/indirector/request.rb +++ b/lib/puppet/indirector/request.rb @@ -3,10 +3,29 @@ require 'puppet/indirector' # Provide any attributes or functionality needed for indirected # instances. class Puppet::Indirector::Request - attr_accessor :indirection_name, :key, :method, :options, :instance + attr_accessor :indirection_name, :key, :method, :options, :instance, :node, :ip, :authenticated + + # Is this an authenticated request? + def authenticated? + # Double negative, so we just get true or false + ! ! authenticated + end def initialize(indirection_name, method, key, options = {}) - @indirection_name, @method, @options = indirection_name, method, (options || {}) + options ||= {} + raise ArgumentError, "Request options must be a hash, not %s" % options.class unless options.is_a?(Hash) + + @indirection_name, @method = indirection_name, method + + @options = options.inject({}) do |result, ary| + param, value = ary + if respond_to?(param.to_s + "=") + send(param.to_s + "=", value) + else + result[param] = value + end + result + end if key.is_a?(String) or key.is_a?(Symbol) @key = key @@ -14,8 +33,6 @@ class Puppet::Indirector::Request @instance = key @key = @instance.name end - - raise ArgumentError, "Request options must be a hash, not %s" % @options.class unless @options.is_a?(Hash) end # Look up the indirection based on the name provided. |