diff options
Diffstat (limited to 'lib/puppet/indirector')
-rw-r--r-- | lib/puppet/indirector/catalog/compiler.rb | 4 | ||||
-rw-r--r-- | lib/puppet/indirector/exec.rb | 8 | ||||
-rw-r--r-- | lib/puppet/indirector/file_bucket_file/file.rb | 4 | ||||
-rw-r--r-- | lib/puppet/indirector/indirection.rb | 20 | ||||
-rw-r--r-- | lib/puppet/indirector/ldap.rb | 4 | ||||
-rw-r--r-- | lib/puppet/indirector/node/exec.rb | 4 | ||||
-rw-r--r-- | lib/puppet/indirector/node/ldap.rb | 8 | ||||
-rw-r--r-- | lib/puppet/indirector/report/processor.rb | 4 | ||||
-rw-r--r-- | lib/puppet/indirector/request.rb | 4 | ||||
-rw-r--r-- | lib/puppet/indirector/rest.rb | 4 | ||||
-rw-r--r-- | lib/puppet/indirector/terminus.rb | 8 | ||||
-rw-r--r-- | lib/puppet/indirector/yaml.rb | 4 |
12 files changed, 19 insertions, 57 deletions
diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb index a689eff2d..c990456e3 100644 --- a/lib/puppet/indirector/catalog/compiler.rb +++ b/lib/puppet/indirector/catalog/compiler.rb @@ -67,9 +67,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code # Compile the actual catalog. def compile(node) str = "Compiled catalog for #{node.name}" - if node.environment - str += " in environment #{node.environment}" - end + str += " in environment #{node.environment}" if node.environment config = nil loglevel = networked? ? :notice : :none diff --git a/lib/puppet/indirector/exec.rb b/lib/puppet/indirector/exec.rb index f8d863562..cf09ed379 100644 --- a/lib/puppet/indirector/exec.rb +++ b/lib/puppet/indirector/exec.rb @@ -25,14 +25,10 @@ class Puppet::Indirector::Exec < Puppet::Indirector::Terminus external_command = command # Make sure it's an arry - unless external_command.is_a?(Array) - raise Puppet::DevError, "Exec commands must be an array" - end + raise Puppet::DevError, "Exec commands must be an array" unless external_command.is_a?(Array) # Make sure it's fully qualified. - unless external_command[0][0] == File::SEPARATOR[0] - raise ArgumentError, "You must set the exec parameter to a fully qualified command" - end + raise ArgumentError, "You must set the exec parameter to a fully qualified command" unless external_command[0][0] == File::SEPARATOR[0] # Add our name to it. external_command << name diff --git a/lib/puppet/indirector/file_bucket_file/file.rb b/lib/puppet/indirector/file_bucket_file/file.rb index 1667c1d7e..0cd3cda65 100644 --- a/lib/puppet/indirector/file_bucket_file/file.rb +++ b/lib/puppet/indirector/file_bucket_file/file.rb @@ -36,9 +36,7 @@ module Puppet::FileBucketFile bucket_file.bucket_path = options[:bucket_path] filename = contents_path_for( bucket_file ) - if ! ::File.exist? filename - return nil - end + return nil if ! ::File.exist? filename begin contents = ::File.read filename diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb index 95a022e38..b7a6b8f1d 100644 --- a/lib/puppet/indirector/indirection.rb +++ b/lib/puppet/indirector/indirection.rb @@ -64,9 +64,7 @@ class Puppet::Indirector::Indirection # Default to the runinterval for the ttl. def ttl - unless defined?(@ttl) - @ttl = Puppet[:runinterval].to_i - end + @ttl = Puppet[:runinterval].to_i unless defined?(@ttl) @ttl end @@ -79,9 +77,7 @@ class Puppet::Indirector::Indirection def doc text = "" - if defined?(@doc) and @doc - text += scrub(@doc) + "\n\n" - end + text += scrub(@doc) + "\n\n" if defined?(@doc) and @doc if s = terminus_setting() text += "* **Terminus Setting**: #{terminus_setting}" @@ -123,9 +119,7 @@ class Puppet::Indirector::Indirection # Return the singleton terminus for this indirection. def terminus(terminus_name = nil) # Get the name of the terminus. - unless terminus_name ||= terminus_class - raise Puppet::DevError, "No terminus specified for #{self.name}; cannot redirect" - end + raise Puppet::DevError, "No terminus specified for #{self.name}; cannot redirect" unless terminus_name ||= terminus_class return termini[terminus_name] ||= make_terminus(terminus_name) end @@ -157,9 +151,7 @@ class Puppet::Indirector::Indirection # This is used by terminus_class= and cache=. def validate_terminus_class(terminus_class) - unless terminus_class and terminus_class.to_s != "" - raise ArgumentError, "Invalid terminus name #{terminus_class.inspect}" - end + raise ArgumentError, "Invalid terminus name #{terminus_class.inspect}" unless terminus_class and terminus_class.to_s != "" unless Puppet::Indirector::Terminus.terminus_class(self.name, terminus_class) raise ArgumentError, "Could not find terminus #{terminus_class} for indirection #{self.name}" end @@ -281,9 +273,7 @@ class Puppet::Indirector::Indirection unless terminus.authorized?(request) msg = "Not authorized to call #{request.method} on #{request}" - unless request.options.empty? - msg += " with #{request.options.inspect}" - end + msg += " with #{request.options.inspect}" unless request.options.empty? raise ArgumentError, msg end end diff --git a/lib/puppet/indirector/ldap.rb b/lib/puppet/indirector/ldap.rb index 5888418ee..795aafa67 100644 --- a/lib/puppet/indirector/ldap.rb +++ b/lib/puppet/indirector/ldap.rb @@ -62,9 +62,7 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus # Create an ldap connection. def connection unless defined?(@connection) and @connection - unless Puppet.features.ldap? - raise Puppet::Error, "Could not set up LDAP Connection: Missing ruby/ldap libraries" - end + raise Puppet::Error, "Could not set up LDAP Connection: Missing ruby/ldap libraries" unless Puppet.features.ldap? begin conn = Puppet::Util::Ldap::Connection.instance conn.start diff --git a/lib/puppet/indirector/node/exec.rb b/lib/puppet/indirector/node/exec.rb index 445059d14..cac515f59 100644 --- a/lib/puppet/indirector/node/exec.rb +++ b/lib/puppet/indirector/node/exec.rb @@ -8,9 +8,7 @@ class Puppet::Node::Exec < Puppet::Indirector::Exec def command command = Puppet[:external_nodes] - unless command != "none" - raise ArgumentError, "You must set the 'external_nodes' parameter to use the external node terminus" - end + raise ArgumentError, "You must set the 'external_nodes' parameter to use the external node terminus" unless command != "none" command.split end diff --git a/lib/puppet/indirector/node/ldap.rb b/lib/puppet/indirector/node/ldap.rb index 4cbc97573..71bca586d 100644 --- a/lib/puppet/indirector/node/ldap.rb +++ b/lib/puppet/indirector/node/ldap.rb @@ -49,9 +49,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap # Look for our node in ldap. def find(request) names = [request.key] - if request.key.include?(".") # we assume it's an fqdn - names << request.key.sub(/\..+/, '') - end + names << request.key.sub(/\..+/, '') if request.key.include?(".") # we assume it's an fqdn names << "default" node = nil @@ -248,9 +246,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap # Preload the parent array with the node name. parents = [info[:name]] while parent - if parents.include?(parent) - raise ArgumentError, "Found loop in LDAP node parents; #{parent} appears twice" - end + raise ArgumentError, "Found loop in LDAP node parents; #{parent} appears twice" if parents.include?(parent) parents << parent parent = find_and_merge_parent(parent, info) end diff --git a/lib/puppet/indirector/report/processor.rb b/lib/puppet/indirector/report/processor.rb index 1b4c5ef8d..80570d9c3 100644 --- a/lib/puppet/indirector/report/processor.rb +++ b/lib/puppet/indirector/report/processor.rb @@ -31,9 +31,7 @@ class Puppet::Transaction::Report::Processor < Puppet::Indirector::Code newrep.extend(mod) newrep.process rescue => detail - if Puppet[:trace] - puts detail.backtrace - end + puts detail.backtrace if Puppet[:trace] Puppet.err "Report #{name} failed: #{detail}" end else diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb index 6d19e59d7..373d4a27d 100644 --- a/lib/puppet/indirector/request.rb +++ b/lib/puppet/indirector/request.rb @@ -21,9 +21,7 @@ class Puppet::Indirector::Request end def environment - unless defined?(@environment) and @environment - @environment = Puppet::Node::Environment.new() - end + @environment = Puppet::Node::Environment.new() unless defined?(@environment) and @environment @environment end diff --git a/lib/puppet/indirector/rest.rb b/lib/puppet/indirector/rest.rb index f38d1f927..6061b533d 100644 --- a/lib/puppet/indirector/rest.rb +++ b/lib/puppet/indirector/rest.rb @@ -39,9 +39,7 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus when "404" return nil when /^2/ - unless response['content-type'] - raise "No content type in http response; cannot parse" - end + raise "No content type in http response; cannot parse" unless response['content-type'] content_type = response['content-type'].gsub(/\s*;.*$/,'') # strip any appended charset diff --git a/lib/puppet/indirector/terminus.rb b/lib/puppet/indirector/terminus.rb index 60f8ec1f2..546f83524 100644 --- a/lib/puppet/indirector/terminus.rb +++ b/lib/puppet/indirector/terminus.rb @@ -122,9 +122,7 @@ class Puppet::Indirector::Terminus private def setup_instance_loading(type) - unless instance_loading?(type) - instance_load type, "puppet/indirector/#{type}" - end + instance_load type, "puppet/indirector/#{type}" unless instance_loading?(type) end end @@ -133,9 +131,7 @@ class Puppet::Indirector::Terminus end def initialize - if self.class.abstract_terminus? - raise Puppet::DevError, "Cannot create instances of abstract terminus types" - end + raise Puppet::DevError, "Cannot create instances of abstract terminus types" if self.class.abstract_terminus? end def model diff --git a/lib/puppet/indirector/yaml.rb b/lib/puppet/indirector/yaml.rb index d82cbfa1d..826a8ae9d 100644 --- a/lib/puppet/indirector/yaml.rb +++ b/lib/puppet/indirector/yaml.rb @@ -32,9 +32,7 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus basedir = File.dirname(file) # This is quite likely a bad idea, since we're not managing ownership or modes. - unless FileTest.exist?(basedir) - Dir.mkdir(basedir) - end + Dir.mkdir(basedir) unless FileTest.exist?(basedir) begin writelock(file, 0660) { |f| f.print to_yaml(request.instance) } |