diff options
author | Luke Kanies <luke@madstop.com> | 2009-03-13 01:22:12 -0500 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-03-20 18:27:07 +1100 |
commit | edf00dba76b65108b443af8d0636073cb3d9d975 (patch) | |
tree | 75951e613a375dca4780d46dde35b1046f64446d /lib/puppet/indirector/request.rb | |
parent | a064ed1a6035c44f123e092b2429895fb45bdbd2 (diff) | |
download | puppet-edf00dba76b65108b443af8d0636073cb3d9d975.tar.gz puppet-edf00dba76b65108b443af8d0636073cb3d9d975.tar.xz puppet-edf00dba76b65108b443af8d0636073cb3d9d975.zip |
Adding environment support to the REST URI
Also adding it to the Indirection Request.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet/indirector/request.rb')
-rw-r--r-- | lib/puppet/indirector/request.rb | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb index 7fe029597..450b43bd2 100644 --- a/lib/puppet/indirector/request.rb +++ b/lib/puppet/indirector/request.rb @@ -5,20 +5,34 @@ require 'puppet/indirector' # Indirection call, and as a a result also handles REST calls. It's somewhat # analogous to an HTTP Request object, except tuned for our Indirector. class Puppet::Indirector::Request - attr_accessor :indirection_name, :key, :method, :options, :instance, :node, :ip, :authenticated, :ignore_cache, :ignore_terminus + attr_accessor :key, :method, :options, :instance, :node, :ip, :authenticated, :ignore_cache, :ignore_terminus attr_accessor :server, :port, :uri, :protocol + attr_reader :environment, :indirection_name + # Is this an authenticated request? def authenticated? # Double negative, so we just get true or false ! ! authenticated end + def environment=(env) + @environment = if env.is_a?(Puppet::Node::Environment) + env + else + Puppet::Node::Environment.new(env) + end + end + def escaped_key URI.escape(key) end + def indirection_name=(name) + @indirection_name = name.to_sym + end + # LAK:NOTE This is a messy interface to the cache, and it's only # used by the Configurer class. I decided it was better to implement # it now and refactor later, when we have a better design, than @@ -36,7 +50,8 @@ class Puppet::Indirector::Request options ||= {} raise ArgumentError, "Request options must be a hash, not %s" % options.class unless options.is_a?(Hash) - @indirection_name, @method = indirection_name, method + self.indirection_name = indirection_name + self.method = method @options = options.inject({}) do |result, ary| param, value = ary |