summaryrefslogtreecommitdiffstats
path: root/lib/puppet/indirector
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:05:55 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:05:55 -0700
commite8cf06336b64491a2dd7538a06651e0caaf6a48d (patch)
tree9f5d4c83d03fefa54c385462f60875056a58a82c /lib/puppet/indirector
parenteefccf252527dc5b69af5959b0b0e2ddb5c91b74 (diff)
downloadpuppet-e8cf06336b64491a2dd7538a06651e0caaf6a48d.tar.gz
puppet-e8cf06336b64491a2dd7538a06651e0caaf6a48d.tar.xz
puppet-e8cf06336b64491a2dd7538a06651e0caaf6a48d.zip
Code smell: Use string interpolation
* Replaced 83 occurances of (.*)" *[+] *([$@]?[\w_0-9.:]+?)(.to_s\b)?(?! *[*(%\w_0-9.:{\[]) with \1#{\2}" 3 Examples: The code: puts "PUPPET " + status + ": " + process + ", " + state becomes: puts "PUPPET " + status + ": " + process + ", #{state}" The code: puts "PUPPET " + status + ": #{process}" + ", #{state}" becomes: puts "PUPPET #{status}" + ": #{process}" + ", #{state}" The code: }.compact.join( "\n" ) + "\n" + t + "]\n" becomes: }.compact.join( "\n" ) + "\n#{t}" + "]\n" * Replaced 21 occurances of (.*)" *[+] *" with \1 3 Examples: The code: puts "PUPPET #{status}" + ": #{process}" + ", #{state}" becomes: puts "PUPPET #{status}" + ": #{process}, #{state}" The code: puts "PUPPET #{status}" + ": #{process}, #{state}" becomes: puts "PUPPET #{status}: #{process}, #{state}" The code: res = self.class.name + ": #{@name}" + "\n" becomes: res = self.class.name + ": #{@name}\n" * Don't use string concatenation to split lines unless they would be very long. Replaced 11 occurances of (.*)(['"]) *[+] *(['"])(.*) with 3 Examples: The code: o.define_head "The check_puppet Nagios plug-in checks that specified " + "Puppet process is running and the state file is no " + becomes: o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no " + The code: o.separator "Mandatory arguments to long options are mandatory for " + "short options too." becomes: o.separator "Mandatory arguments to long options are mandatory for short options too." The code: o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no " + "older than specified interval." becomes: o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no older than specified interval." * Replaced no occurances of do (.*?) end with {\1} * Replaced 1488 occurances of "([^"\n]*%s[^"\n]*)" *% *(.+?)(?=$| *\b(do|if|while|until|unless|#)\b) with 20 Examples: The code: args[0].split(/\./).map do |s| "dc=%s"%[s] end.join(",") becomes: args[0].split(/\./).map do |s| "dc=#{s}" end.join(",") The code: puts "%s" % Puppet.version becomes: puts "#{Puppet.version}" The code: raise "Could not find information for %s" % node becomes: raise "Could not find information for #{node}" The code: raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)] becomes: raise Puppet::Error, "Cannot create #{dir}: basedir #{File.join(path)} is a file" The code: Puppet.err "Could not run %s: %s" % [client_class, detail] becomes: Puppet.err "Could not run #{client_class}: #{detail}" The code: raise "Could not find handler for %s" % arg becomes: raise "Could not find handler for #{arg}" The code: Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig] becomes: Puppet.err "Will not start without authorization file #{Puppet[:authconfig]}" The code: raise Puppet::Error, "Could not deserialize catalog from pson: %s" % detail becomes: raise Puppet::Error, "Could not deserialize catalog from pson: #{detail}" The code: raise "Could not find facts for %s" % Puppet[:certname] becomes: raise "Could not find facts for #{Puppet[:certname]}" The code: raise ArgumentError, "%s is not readable" % path becomes: raise ArgumentError, "#{path} is not readable" The code: raise ArgumentError, "Invalid handler %s" % name becomes: raise ArgumentError, "Invalid handler #{name}" The code: debug "Executing '%s' in zone %s with '%s'" % [command, @resource[:name], str] becomes: debug "Executing '#{command}' in zone #{@resource[:name]} with '#{str}'" The code: raise Puppet::Error, "unknown cert type '%s'" % hash[:type] becomes: raise Puppet::Error, "unknown cert type '#{hash[:type]}'" The code: Puppet.info "Creating a new certificate request for %s" % Puppet[:certname] becomes: Puppet.info "Creating a new certificate request for #{Puppet[:certname]}" The code: "Cannot create alias %s: object already exists" % [name] becomes: "Cannot create alias #{name}: object already exists" The code: return "replacing from source %s with contents %s" % [metadata.source, metadata.checksum] becomes: return "replacing from source #{metadata.source} with contents #{metadata.checksum}" The code: it "should have a %s parameter" % param do becomes: it "should have a #{param} parameter" do The code: describe "when registring '%s' messages" % log do becomes: describe "when registring '#{log}' messages" do The code: paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration%stest" % l } becomes: paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration#{l}test" } The code: assert_raise(Puppet::Error, "Check '%s' did not fail on false" % check) do becomes: assert_raise(Puppet::Error, "Check '#{check}' did not fail on false") do
Diffstat (limited to 'lib/puppet/indirector')
-rw-r--r--lib/puppet/indirector/catalog/compiler.rb14
-rw-r--r--lib/puppet/indirector/certificate_request/ca.rb2
-rw-r--r--lib/puppet/indirector/exec.rb4
-rw-r--r--lib/puppet/indirector/facts/facter.rb6
-rw-r--r--lib/puppet/indirector/file.rb2
-rw-r--r--lib/puppet/indirector/file_server.rb2
-rw-r--r--lib/puppet/indirector/indirection.rb34
-rw-r--r--lib/puppet/indirector/key/file.rb4
-rw-r--r--lib/puppet/indirector/ldap.rb6
-rw-r--r--lib/puppet/indirector/memory.rb2
-rw-r--r--lib/puppet/indirector/node/exec.rb2
-rw-r--r--lib/puppet/indirector/node/ldap.rb8
-rw-r--r--lib/puppet/indirector/queue.rb8
-rw-r--r--lib/puppet/indirector/report/processor.rb4
-rw-r--r--lib/puppet/indirector/request.rb10
-rw-r--r--lib/puppet/indirector/rest.rb2
-rw-r--r--lib/puppet/indirector/ssl_file.rb14
-rw-r--r--lib/puppet/indirector/terminus.rb12
-rw-r--r--lib/puppet/indirector/yaml.rb6
19 files changed, 71 insertions, 71 deletions
diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb
index b1c9df7c4..a689eff2d 100644
--- a/lib/puppet/indirector/catalog/compiler.rb
+++ b/lib/puppet/indirector/catalog/compiler.rb
@@ -13,7 +13,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
def extract_facts_from_request(request)
return unless text_facts = request.options[:facts]
- raise ArgumentError, "Facts but no fact format provided for %s" % request.name unless format = request.options[:facts_format]
+ raise ArgumentError, "Facts but no fact format provided for #{request.name}" unless format = request.options[:facts_format]
# If the facts were encoded as yaml, then the param reconstitution system
# in Network::HTTP::Handler will automagically deserialize the value.
@@ -66,15 +66,15 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
# Compile the actual catalog.
def compile(node)
- str = "Compiled catalog for %s" % node.name
+ str = "Compiled catalog for #{node.name}"
if node.environment
- str += " in environment %s" % node.environment
+ str += " in environment #{node.environment}"
end
config = nil
loglevel = networked? ? :notice : :none
- benchmark(loglevel, "Compiled catalog for %s" % node.name) do
+ benchmark(loglevel, "Compiled catalog for #{node.name}") do
begin
return Puppet::Parser::Compiler.compile(node)
rescue Puppet::Error => detail
@@ -92,7 +92,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
return nil unless node = Puppet::Node.find(name)
rescue => detail
puts detail.backtrace if Puppet[:trace]
- raise Puppet::Error, "Failed when searching for node %s: %s" % [name, detail]
+ raise Puppet::Error, "Failed when searching for node #{name}: #{detail}"
end
@@ -117,7 +117,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
return node
end
- raise ArgumentError, "Could not find node '%s'; cannot compile" % name
+ raise ArgumentError, "Could not find node '#{name}'; cannot compile"
end
# Initialize our server fact hash; we add these to each client, and they
@@ -135,7 +135,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
if value = Facter.value(fact)
@server_facts[var] = value
else
- Puppet.warning "Could not retrieve fact %s" % fact
+ Puppet.warning "Could not retrieve fact #{fact}"
end
end
diff --git a/lib/puppet/indirector/certificate_request/ca.rb b/lib/puppet/indirector/certificate_request/ca.rb
index e90f43a03..25680fb9b 100644
--- a/lib/puppet/indirector/certificate_request/ca.rb
+++ b/lib/puppet/indirector/certificate_request/ca.rb
@@ -8,7 +8,7 @@ class Puppet::SSL::CertificateRequest::Ca < Puppet::Indirector::SslFile
def save(request)
result = super
- Puppet.notice "%s has a waiting certificate request" % request.key
+ Puppet.notice "#{request.key} has a waiting certificate request"
result
end
end
diff --git a/lib/puppet/indirector/exec.rb b/lib/puppet/indirector/exec.rb
index 022ec5324..f8d863562 100644
--- a/lib/puppet/indirector/exec.rb
+++ b/lib/puppet/indirector/exec.rb
@@ -39,12 +39,12 @@ class Puppet::Indirector::Exec < Puppet::Indirector::Terminus
begin
output = execute(external_command)
rescue Puppet::ExecutionFailure => detail
- Puppet.err "Failed to find %s via exec: %s" % [name, detail]
+ Puppet.err "Failed to find #{name} via exec: #{detail}"
return nil
end
if output =~ /\A\s*\Z/ # all whitespace
- Puppet.debug "Empty response for %s from exec %s terminus" % [name, self.name]
+ Puppet.debug "Empty response for #{name} from exec #{self.name} terminus"
return nil
else
return output
diff --git a/lib/puppet/indirector/facts/facter.rb b/lib/puppet/indirector/facts/facter.rb
index 9d181706c..e1d910247 100644
--- a/lib/puppet/indirector/facts/facter.rb
+++ b/lib/puppet/indirector/facts/facter.rb
@@ -11,7 +11,7 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code
# Add any per-module fact directories to the factpath
module_fact_dirs = Puppet[:modulepath].split(":").collect do |d|
["lib", "plugins"].map do |subdirectory|
- Dir.glob("%s/*/#{subdirectory}/facter" % d)
+ Dir.glob("#{d}/*/#{subdirectory}/facter")
end
end.flatten
dirs = module_fact_dirs + Puppet[:factpath].split(":")
@@ -27,14 +27,14 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code
Dir.glob("*.rb").each do |file|
fqfile = ::File.join(dir, file)
begin
- Puppet.info "Loading facts in %s" % [::File.basename(file.sub(".rb",''))]
+ Puppet.info "Loading facts in #{::File.basename(file.sub(".rb",''))}"
Timeout::timeout(self.timeout) do
load file
end
rescue SystemExit,NoMemoryError
raise
rescue Exception => detail
- Puppet.warning "Could not load fact file %s: %s" % [fqfile, detail]
+ Puppet.warning "Could not load fact file #{fqfile}: #{detail}"
end
end
end
diff --git a/lib/puppet/indirector/file.rb b/lib/puppet/indirector/file.rb
index a035f0dac..dab8fc720 100644
--- a/lib/puppet/indirector/file.rb
+++ b/lib/puppet/indirector/file.rb
@@ -14,7 +14,7 @@ class Puppet::Indirector::File < Puppet::Indirector::Terminus
end
def file_path(request)
- File.join(data_directory, request.key + "." + serialization_format)
+ File.join(data_directory, request.key + ".#{serialization_format}")
end
def latest_path(request)
diff --git a/lib/puppet/indirector/file_server.rb b/lib/puppet/indirector/file_server.rb
index 18ac20824..bf101d490 100644
--- a/lib/puppet/indirector/file_server.rb
+++ b/lib/puppet/indirector/file_server.rb
@@ -43,7 +43,7 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus
mount, relative_path = configuration.split_path(request)
unless mount and paths = mount.search(relative_path, request)
- Puppet.info "Could not find filesystem info for file '%s' in environment %s" % [request.key, request.environment]
+ Puppet.info "Could not find filesystem info for file '#{request.key}' in environment #{request.environment}"
return nil
end
diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb
index 85890f24c..95a022e38 100644
--- a/lib/puppet/indirector/indirection.rb
+++ b/lib/puppet/indirector/indirection.rb
@@ -84,7 +84,7 @@ class Puppet::Indirector::Indirection
end
if s = terminus_setting()
- text += "* **Terminus Setting**: %s" % terminus_setting
+ text += "* **Terminus Setting**: #{terminus_setting}"
end
text
@@ -97,7 +97,7 @@ class Puppet::Indirector::Indirection
@cache_class = nil
@terminus_class = nil
- raise(ArgumentError, "Indirection %s is already defined" % @name) if @@indirections.find { |i| i.name == @name }
+ raise(ArgumentError, "Indirection #{@name} is already defined") if @@indirections.find { |i| i.name == @name }
@@indirections << self
if mod = options[:extend]
@@ -110,7 +110,7 @@ class Puppet::Indirector::Indirection
begin
send(name.to_s + "=", value)
rescue NoMethodError
- raise ArgumentError, "%s is not a valid Indirection parameter" % name
+ raise ArgumentError, "#{name} is not a valid Indirection parameter"
end
end
end
@@ -124,7 +124,7 @@ class Puppet::Indirector::Indirection
def terminus(terminus_name = nil)
# Get the name of the terminus.
unless terminus_name ||= terminus_class
- raise Puppet::DevError, "No terminus specified for %s; cannot redirect" % self.name
+ raise Puppet::DevError, "No terminus specified for #{self.name}; cannot redirect"
end
return termini[terminus_name] ||= make_terminus(terminus_name)
@@ -139,7 +139,7 @@ class Puppet::Indirector::Indirection
if setting = self.terminus_setting
self.terminus_class = Puppet.settings[setting].to_sym
else
- raise Puppet::DevError, "No terminus class nor terminus setting was provided for indirection %s" % self.name
+ raise Puppet::DevError, "No terminus class nor terminus setting was provided for indirection #{self.name}"
end
end
@terminus_class
@@ -158,10 +158,10 @@ 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 %s" % terminus_class.inspect
+ raise ArgumentError, "Invalid terminus name #{terminus_class.inspect}"
end
unless Puppet::Indirector::Terminus.terminus_class(self.name, terminus_class)
- raise ArgumentError, "Could not find terminus %s for indirection %s" % [terminus_class, self.name]
+ raise ArgumentError, "Could not find terminus #{terminus_class} for indirection #{self.name}"
end
end
@@ -175,7 +175,7 @@ class Puppet::Indirector::Indirection
return nil unless instance = cache.find(request(:find, key, *args))
- Puppet.info "Expiring the %s cache of %s" % [self.name, instance.name]
+ Puppet.info "Expiring the #{self.name} cache of #{instance.name}"
# Set an expiration date in the past
instance.expiration = Time.now - 60
@@ -195,14 +195,14 @@ class Puppet::Indirector::Indirection
end
rescue => detail
puts detail.backtrace if Puppet[:trace]
- Puppet.err "Cached %s for %s failed: %s" % [self.name, request.key, detail]
+ Puppet.err "Cached #{self.name} for #{request.key} failed: #{detail}"
end
# Otherwise, return the result from the terminus, caching if appropriate.
if ! request.ignore_terminus? and result = terminus.find(request)
result.expiration ||= self.expiration
if cache? and request.use_cache?
- Puppet.info "Caching %s for %s" % [self.name, request.key]
+ Puppet.info "Caching #{self.name} for #{request.key}"
cache.save request(:save, result, *args)
end
@@ -216,11 +216,11 @@ class Puppet::Indirector::Indirection
# See if our instance is in the cache and up to date.
return nil unless cache? and ! request.ignore_cache? and cached = cache.find(request)
if cached.expired?
- Puppet.info "Not using expired %s for %s from cache; expired at %s" % [self.name, request.key, cached.expiration]
+ Puppet.info "Not using expired #{self.name} for #{request.key} from cache; expired at #{cached.expiration}"
return nil
end
- Puppet.debug "Using cached %s for %s" % [self.name, request.key]
+ Puppet.debug "Using cached #{self.name} for #{request.key}"
return cached
end
@@ -245,7 +245,7 @@ class Puppet::Indirector::Indirection
terminus = prepare(request)
if result = terminus.search(request)
- raise Puppet::DevError, "Search results from terminus %s are not an array" % terminus.name unless result.is_a?(Array)
+ raise Puppet::DevError, "Search results from terminus #{terminus.name} are not an array" unless result.is_a?(Array)
result.each do |instance|
instance.expiration ||= self.expiration
end
@@ -280,9 +280,9 @@ class Puppet::Indirector::Indirection
return unless terminus.respond_to?(:authorized?)
unless terminus.authorized?(request)
- msg = "Not authorized to call %s on %s" % [request.method, request.to_s]
+ msg = "Not authorized to call #{request.method} on #{request}"
unless request.options.empty?
- msg += " with %s" % request.options.inspect
+ msg += " with #{request.options.inspect}"
end
raise ArgumentError, msg
end
@@ -293,7 +293,7 @@ class Puppet::Indirector::Indirection
# Pick our terminus.
if respond_to?(:select_terminus)
unless terminus_name = select_terminus(request)
- raise ArgumentError, "Could not determine appropriate terminus for %s" % request
+ raise ArgumentError, "Could not determine appropriate terminus for #{request}"
end
else
terminus_name = terminus_class
@@ -309,7 +309,7 @@ class Puppet::Indirector::Indirection
def make_terminus(terminus_class)
# Load our terminus class.
unless klass = Puppet::Indirector::Terminus.terminus_class(self.name, terminus_class)
- raise ArgumentError, "Could not find terminus %s for indirection %s" % [terminus_class, self.name]
+ raise ArgumentError, "Could not find terminus #{terminus_class} for indirection #{self.name}"
end
return klass.new
end
diff --git a/lib/puppet/indirector/key/file.rb b/lib/puppet/indirector/key/file.rb
index a413ccf63..51b5cfd3d 100644
--- a/lib/puppet/indirector/key/file.rb
+++ b/lib/puppet/indirector/key/file.rb
@@ -25,7 +25,7 @@ class Puppet::SSL::Key::File < Puppet::Indirector::SslFile
begin
File.unlink(public_key_path(request.key))
rescue => detail
- raise Puppet::Error, "Could not remove %s public key: %s" % [request.key, detail]
+ raise Puppet::Error, "Could not remove #{request.key} public key: #{detail}"
end
end
@@ -36,7 +36,7 @@ class Puppet::SSL::Key::File < Puppet::Indirector::SslFile
begin
Puppet.settings.writesub(:publickeydir, public_key_path(request.key)) { |f| f.print request.instance.content.public_key.to_pem }
rescue => detail
- raise Puppet::Error, "Could not write %s: %s" % [request.key, detail]
+ raise Puppet::Error, "Could not write #{request.key}: #{detail}"
end
end
end
diff --git a/lib/puppet/indirector/ldap.rb b/lib/puppet/indirector/ldap.rb
index 390fe6793..5888418ee 100644
--- a/lib/puppet/indirector/ldap.rb
+++ b/lib/puppet/indirector/ldap.rb
@@ -10,7 +10,7 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus
# Process the found entry. We assume that we don't just want the
# ldap object.
def process(entry)
- raise Puppet::DevError, "The 'process' method has not been overridden for the LDAP terminus for %s" % self.name
+ raise Puppet::DevError, "The 'process' method has not been overridden for the LDAP terminus for #{self.name}"
end
# Default to all attributes.
@@ -24,7 +24,7 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus
# The ldap search filter to use.
def search_filter(name)
- raise Puppet::DevError, "No search string set for LDAP terminus for %s" % self.name
+ raise Puppet::DevError, "No search string set for LDAP terminus for #{self.name}"
end
# Find the ldap node, return the class list and parent node specially,
@@ -71,7 +71,7 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus
@connection = conn.connection
rescue => detail
puts detail.backtrace if Puppet[:trace]
- raise Puppet::Error, "Could not connect to LDAP: %s" % detail
+ raise Puppet::Error, "Could not connect to LDAP: #{detail}"
end
end
diff --git a/lib/puppet/indirector/memory.rb b/lib/puppet/indirector/memory.rb
index 19acc14e2..332e95bcb 100644
--- a/lib/puppet/indirector/memory.rb
+++ b/lib/puppet/indirector/memory.rb
@@ -7,7 +7,7 @@ class Puppet::Indirector::Memory < Puppet::Indirector::Terminus
end
def destroy(request)
- raise ArgumentError.new("Could not find %s to destroy" % request.key) unless @instances.include?(request.key)
+ raise ArgumentError.new("Could not find #{request.key} to destroy") unless @instances.include?(request.key)
@instances.delete(request.key)
end
diff --git a/lib/puppet/indirector/node/exec.rb b/lib/puppet/indirector/node/exec.rb
index 52cbc370c..445059d14 100644
--- a/lib/puppet/indirector/node/exec.rb
+++ b/lib/puppet/indirector/node/exec.rb
@@ -46,7 +46,7 @@ class Puppet::Node::Exec < Puppet::Indirector::Exec
begin
YAML.load(output).inject({}) { |hash, data| hash[symbolize(data[0])] = data[1]; hash }
rescue => detail
- raise Puppet::Error, "Could not load external node results for %s: %s" % [name, detail]
+ raise Puppet::Error, "Could not load external node results for #{name}: #{detail}"
end
end
end
diff --git a/lib/puppet/indirector/node/ldap.rb b/lib/puppet/indirector/node/ldap.rb
index 2d58df68a..4cbc97573 100644
--- a/lib/puppet/indirector/node/ldap.rb
+++ b/lib/puppet/indirector/node/ldap.rb
@@ -39,7 +39,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
end
}
if node_type == 'parent'
- raise Puppet::Error.new("Could not find node '%s' with environment '%s'" % [name,name_env])
+ raise Puppet::Error.new("Could not find node '#{name}' with environment '#{name_env}'")
end
info = name2hash('default',name_env,'parent')
@@ -222,7 +222,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
information[:environment] ||= parent_info[:environment]
parent_info[:parent]
else
- raise Puppet::Error.new("Could not find parent node '%s'" % parent)
+ raise Puppet::Error.new("Could not find parent node '#{parent}'")
nil
end
@@ -249,7 +249,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
parents = [info[:name]]
while parent
if parents.include?(parent)
- raise ArgumentError, "Found loop in LDAP node parents; %s appears twice" % parent
+ raise ArgumentError, "Found loop in LDAP node parents; #{parent} appears twice"
end
parents << parent
parent = find_and_merge_parent(parent, info)
@@ -289,7 +289,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
if values.length > 1
raise Puppet::Error,
- "Node entry %s specifies more than one parent: %s" % [entry.dn, values.inspect]
+ "Node entry #{entry.dn} specifies more than one parent: #{values.inspect}"
end
return nil if values.empty?
return values.shift
diff --git a/lib/puppet/indirector/queue.rb b/lib/puppet/indirector/queue.rb
index 27ef2192c..0e9ff966c 100644
--- a/lib/puppet/indirector/queue.rb
+++ b/lib/puppet/indirector/queue.rb
@@ -36,12 +36,12 @@ class Puppet::Indirector::Queue < Puppet::Indirector::Terminus
def save(request)
begin
result = nil
- benchmark :info, "Queued %s for %s" % [indirection.name, request.key] do
+ benchmark :info, "Queued #{indirection.name} for #{request.key}" do
result = client.send_message(queue, request.instance.render(:pson))
end
result
rescue => detail
- raise Puppet::Error, "Could not write %s to queue: %s\nInstance::%s\n client : %s" % [request.key, detail,request.instance.to_s,client.to_s]
+ raise Puppet::Error, "Could not write #{request.key} to queue: #{detail}\nInstance::#{request.instance}\n client : #{client}"
end
end
@@ -61,7 +61,7 @@ class Puppet::Indirector::Queue < Puppet::Indirector::Terminus
# converts the _message_ from deserialized format to an actual model instance.
def self.intern(message)
result = nil
- benchmark :info, "Loaded queued %s" % [indirection.name] do
+ benchmark :info, "Loaded queued #{indirection.name}" do
result = model.convert_from(:pson, message)
end
result
@@ -76,7 +76,7 @@ class Puppet::Indirector::Queue < Puppet::Indirector::Terminus
yield(self.intern(msg))
rescue => detail
puts detail.backtrace if Puppet[:trace]
- Puppet.err "Error occured with subscription to queue %s for indirection %s: %s" % [queue, indirection_name, detail]
+ Puppet.err "Error occured with subscription to queue #{queue} for indirection #{indirection_name}: #{detail}"
end
end
end
diff --git a/lib/puppet/indirector/report/processor.rb b/lib/puppet/indirector/report/processor.rb
index 1ff2e0e84..1b4c5ef8d 100644
--- a/lib/puppet/indirector/report/processor.rb
+++ b/lib/puppet/indirector/report/processor.rb
@@ -34,10 +34,10 @@ class Puppet::Transaction::Report::Processor < Puppet::Indirector::Code
if Puppet[:trace]
puts detail.backtrace
end
- Puppet.err "Report %s failed: %s" % [name, detail]
+ Puppet.err "Report #{name} failed: #{detail}"
end
else
- Puppet.warning "No report named '%s'" % name
+ Puppet.warning "No report named '#{name}'"
end
end
end
diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb
index cd354ac16..6d19e59d7 100644
--- a/lib/puppet/indirector/request.rb
+++ b/lib/puppet/indirector/request.rb
@@ -100,7 +100,7 @@ class Puppet::Indirector::Request
def model
- raise ArgumentError, "Could not find indirection '%s'" % indirection_name unless i = indirection
+ raise ArgumentError, "Could not find indirection '#{indirection_name}'" unless i = indirection
i.model
end
@@ -130,10 +130,10 @@ class Puppet::Indirector::Request
when Symbol; value = CGI.escape(value.to_s)
when Array; value = CGI.escape(YAML.dump(value))
else
- raise ArgumentError, "HTTP REST queries cannot handle values of type '%s'" % value.class
+ raise ArgumentError, "HTTP REST queries cannot handle values of type '#{value.class}'"
end
- "%s=%s" % [key, value]
+ "#{key}=#{value}"
end.join("&")
end
@@ -150,7 +150,7 @@ class Puppet::Indirector::Request
def to_s
return uri if uri
- return "/%s/%s" % [indirection_name, key]
+ return "/#{indirection_name}/#{key}"
end
private
@@ -170,7 +170,7 @@ class Puppet::Indirector::Request
begin
uri = URI.parse(URI.escape(key))
rescue => detail
- raise ArgumentError, "Could not understand URL %s: %s" % [key, detail.to_s]
+ raise ArgumentError, "Could not understand URL #{key}: #{detail}"
end
# Just short-circuit these to full paths
diff --git a/lib/puppet/indirector/rest.rb b/lib/puppet/indirector/rest.rb
index f9b11c16f..f38d1f927 100644
--- a/lib/puppet/indirector/rest.rb
+++ b/lib/puppet/indirector/rest.rb
@@ -55,7 +55,7 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus
end
else
# Raise the http error if we didn't get a 'success' of some kind.
- message = "Error %s on SERVER: %s" % [response.code, (response.body||'').empty? ? response.message : uncompress_body(response)]
+ message = "Error #{response.code} on SERVER: #{(response.body||'').empty? ? response.message : uncompress_body(response)}"
raise Net::HTTPError.new(message, response)
end
end
diff --git a/lib/puppet/indirector/ssl_file.rb b/lib/puppet/indirector/ssl_file.rb
index 67202699d..f8034a4a1 100644
--- a/lib/puppet/indirector/ssl_file.rb
+++ b/lib/puppet/indirector/ssl_file.rb
@@ -49,7 +49,7 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus
def initialize
Puppet.settings.use(:main, :ssl)
- (collection_directory || file_location) or raise Puppet::DevError, "No file or directory setting provided; terminus %s cannot function" % self.class.name
+ (collection_directory || file_location) or raise Puppet::DevError, "No file or directory setting provided; terminus #{self.class.name} cannot function"
end
# Use a setting to determine our path.
@@ -68,11 +68,11 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus
path = path(request.key)
return false unless FileTest.exist?(path)
- Puppet.notice "Removing file %s %s at '%s'" % [model, request.key, path]
+ Puppet.notice "Removing file #{model} #{request.key} at '#{path}'"
begin
File.unlink(path)
rescue => detail
- raise Puppet::Error, "Could not remove %s: %s" % [request.key, detail]
+ raise Puppet::Error, "Could not remove #{request.key}: #{detail}"
end
end
@@ -92,8 +92,8 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus
path = path(request.key)
dir = File.dirname(path)
- raise Puppet::Error.new("Cannot save %s; parent directory %s does not exist" % [request.key, dir]) unless FileTest.directory?(dir)
- raise Puppet::Error.new("Cannot save %s; parent directory %s is not writable" % [request.key, dir]) unless FileTest.writable?(dir)
+ raise Puppet::Error.new("Cannot save #{request.key}; parent directory #{dir} does not exist") unless FileTest.directory?(dir)
+ raise Puppet::Error.new("Cannot save #{request.key}; parent directory #{dir} is not writable") unless FileTest.writable?(dir)
write(request.key, path) { |f| f.print request.instance.to_s }
end
@@ -143,7 +143,7 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus
full_file = File.join(dir, real_file)
- Puppet.notice "Fixing case in %s; renaming to %s" % [full_file, file]
+ Puppet.notice "Fixing case in #{full_file}; renaming to #{file}"
File.rename(full_file, file)
return true
@@ -160,7 +160,7 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus
begin
Puppet.settings.writesub(setting, path) { |f| yield f }
rescue => detail
- raise Puppet::Error, "Could not write %s to %s: %s" % [path, setting, detail]
+ raise Puppet::Error, "Could not write #{path} to #{setting}: #{detail}"
end
else
raise Puppet::DevError, "You must provide a setting to determine where the files are stored"
diff --git a/lib/puppet/indirector/terminus.rb b/lib/puppet/indirector/terminus.rb
index 4d1d58f87..60f8ec1f2 100644
--- a/lib/puppet/indirector/terminus.rb
+++ b/lib/puppet/indirector/terminus.rb
@@ -21,7 +21,7 @@ class Puppet::Indirector::Terminus
# Convert a constant to a short name.
def const2name(const)
- const.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| "_" + i.downcase }.intern
+ const.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| "_#{i.downcase}" }.intern
end
# Look up the indirection if we were only provided a name.
@@ -31,7 +31,7 @@ class Puppet::Indirector::Terminus
elsif ind = Puppet::Indirector::Indirection.instance(name)
@indirection = ind
else
- raise ArgumentError, "Could not find indirection instance %s for %s" % [name, self.name]
+ raise ArgumentError, "Could not find indirection instance #{name} for #{self.name}"
end
end
@@ -50,7 +50,7 @@ class Puppet::Indirector::Terminus
names = longname.split("::")
# Convert everything to a lower-case symbol, converting camelcase to underscore word separation.
- name = names.pop.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| "_" + i.downcase }.intern
+ name = names.pop.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| "_#{i.downcase}" }.intern
subclass.name = name
@@ -66,8 +66,8 @@ class Puppet::Indirector::Terminus
subclass.terminus_type = self.name
# Our subclass is specifically associated with an indirection.
- raise("Invalid name %s" % longname) unless names.length > 0
- indirection_name = names.pop.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| "_" + i.downcase }.intern
+ raise("Invalid name #{longname}") unless names.length > 0
+ indirection_name = names.pop.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| "_#{i.downcase}" }.intern
if indirection_name == "" or indirection_name.nil?
raise Puppet::DevError, "Could not discern indirection model from class constant"
@@ -123,7 +123,7 @@ class Puppet::Indirector::Terminus
def setup_instance_loading(type)
unless instance_loading?(type)
- instance_load type, "puppet/indirector/%s" % type
+ instance_load type, "puppet/indirector/#{type}"
end
end
end
diff --git a/lib/puppet/indirector/yaml.rb b/lib/puppet/indirector/yaml.rb
index 2ff267f06..d82cbfa1d 100644
--- a/lib/puppet/indirector/yaml.rb
+++ b/lib/puppet/indirector/yaml.rb
@@ -14,12 +14,12 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus
begin
readlock(file) { |fh| yaml = fh.read }
rescue => detail
- raise Puppet::Error, "Could not read YAML data for %s %s: %s" % [indirection.name, request.key, detail]
+ raise Puppet::Error, "Could not read YAML data for #{indirection.name} #{request.key}: #{detail}"
end
begin
return from_yaml(yaml)
rescue => detail
- raise Puppet::Error, "Could not parse YAML data for %s %s: %s" % [indirection.name, request.key, detail]
+ raise Puppet::Error, "Could not parse YAML data for #{indirection.name} #{request.key}: #{detail}"
end
end
@@ -39,7 +39,7 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus
begin
writelock(file, 0660) { |f| f.print to_yaml(request.instance) }
rescue TypeError => detail
- Puppet.err "Could not save %s %s: %s" % [self.name, request.key, detail]
+ Puppet.err "Could not save #{self.name} #{request.key}: #{detail}"
end
end