diff options
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/face/certificate.rb | 2 | ||||
-rw-r--r-- | lib/puppet/face/resource.rb | 2 | ||||
-rw-r--r-- | lib/puppet/indirector.rb | 2 | ||||
-rw-r--r-- | lib/puppet/interface/action.rb | 2 | ||||
-rw-r--r-- | lib/puppet/interface/action_builder.rb | 4 | ||||
-rw-r--r-- | lib/puppet/interface/option_builder.rb | 4 | ||||
-rw-r--r-- | lib/puppet/network/client.rb | 2 | ||||
-rw-r--r-- | lib/puppet/network/format.rb | 2 | ||||
-rwxr-xr-x | lib/puppet/provider/mount/parsed.rb | 18 | ||||
-rw-r--r-- | lib/puppet/provider/ssh_authorized_key/parsed.rb | 6 | ||||
-rw-r--r-- | lib/puppet/resource.rb | 2 | ||||
-rw-r--r-- | lib/puppet/type/ssh_authorized_key.rb | 12 | ||||
-rw-r--r-- | lib/puppet/util.rb | 1 | ||||
-rw-r--r-- | lib/puppet/util/selinux.rb | 2 |
14 files changed, 43 insertions, 18 deletions
diff --git a/lib/puppet/face/certificate.rb b/lib/puppet/face/certificate.rb index ee2b2873f..859946623 100644 --- a/lib/puppet/face/certificate.rb +++ b/lib/puppet/face/certificate.rb @@ -8,7 +8,7 @@ Puppet::Indirector::Face.define(:certificate, '0.0.1') do summary "Provide access to the CA for certificate management" description <<-EOT This face interacts with a local or remote Puppet certificate - authority. Currently, its behavior is not a full superset of puppet + authority. Currently, its behavior is not a full superset of puppet cert; specifically, it is unable to mimic puppet cert's "clean" option, and its "generate" action submits a CSR rather than creating a signed certificate. diff --git a/lib/puppet/face/resource.rb b/lib/puppet/face/resource.rb index ed6360888..87e587624 100644 --- a/lib/puppet/face/resource.rb +++ b/lib/puppet/face/resource.rb @@ -7,7 +7,7 @@ Puppet::Indirector::Face.define(:resource, '0.0.1') do summary "Interact directly with resources via the RAL, like ralsh" description <<-EOT This face provides a Ruby API with functionality similar to the puppet - resource (née ralsh) command line application. It is not intended to be + resource (originally ralsh) command line application. It is not intended to be used from the command line. EOT notes <<-EOT diff --git a/lib/puppet/indirector.rb b/lib/puppet/indirector.rb index 7267ac7f3..86ede5994 100644 --- a/lib/puppet/indirector.rb +++ b/lib/puppet/indirector.rb @@ -18,7 +18,7 @@ module Puppet::Indirector terminus_name = termini["terminus"] cache_name = termini["cache"] - Puppet::Indirector::Terminus.terminus_classes(indirection_name) + Puppet::Indirector::Terminus.terminus_class(indirection_name, terminus_name || cache_name) indirection = Puppet::Indirector::Indirection.instance(indirection_name) raise "Indirection #{indirection_name} does not exist" unless indirection diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb index 622371a4e..3c377a49f 100644 --- a/lib/puppet/interface/action.rb +++ b/lib/puppet/interface/action.rb @@ -192,7 +192,7 @@ class Puppet::Interface::Action # but will on 1.9.2, which treats it as "no arguments". Which bites, # because this just begs for us to wind up in the horrible situation # where a 1.8 vs 1.9 error bites our end users. --daniel 2011-04-19 - raise ArgumentError, "action when_invoked requires at least one argument (options)" + raise ArgumentError, "when_invoked requires at least one argument (options) for action #{@name}" elsif arity > 0 then range = Range.new(1, arity - 1) decl = range.map { |x| "arg#{x}" } << "options = {}" diff --git a/lib/puppet/interface/action_builder.rb b/lib/puppet/interface/action_builder.rb index 62db8de06..4948f5fab 100644 --- a/lib/puppet/interface/action_builder.rb +++ b/lib/puppet/interface/action_builder.rb @@ -49,9 +49,9 @@ class Puppet::Interface::ActionBuilder # Metaprogram the simple DSL from the target class. Puppet::Interface::Action.instance_methods.grep(/=$/).each do |setter| next if setter =~ /^=/ - property = setter.sub(/=$/, '') + property = setter.to_s.chomp('=') - unless public_instance_methods.include? property + unless method_defined? property # Using eval because the argument handling semantics are less awful than # when we use the define_method/block version. The later warns on older # Ruby versions if you pass the wrong number of arguments, but carries diff --git a/lib/puppet/interface/option_builder.rb b/lib/puppet/interface/option_builder.rb index 8f358c222..5676ec977 100644 --- a/lib/puppet/interface/option_builder.rb +++ b/lib/puppet/interface/option_builder.rb @@ -18,9 +18,9 @@ class Puppet::Interface::OptionBuilder # Metaprogram the simple DSL from the option class. Puppet::Interface::Option.instance_methods.grep(/=$/).each do |setter| next if setter =~ /^=/ - dsl = setter.sub(/=$/, '') + dsl = setter.to_s.chomp('=') - unless private_instance_methods.include? dsl + unless private_method_defined? dsl define_method(dsl) do |value| @option.send(setter, value) end end end diff --git a/lib/puppet/network/client.rb b/lib/puppet/network/client.rb index cd88b9d84..c56b21393 100644 --- a/lib/puppet/network/client.rb +++ b/lib/puppet/network/client.rb @@ -23,7 +23,7 @@ class Net::HTTP # JJM: This is a "backport" of sorts to older ruby versions which # do not have this accessor. See #896 for more information. - attr_accessor :enable_post_connection_check unless Net::HTTP.instance_methods.include? "enable_post_connection_check" + attr_accessor :enable_post_connection_check unless Net::HTTP.method_defined? "enable_post_connection_check" end # The base class for all of the clients. Many clients just directly diff --git a/lib/puppet/network/format.rb b/lib/puppet/network/format.rb index 9cd6cf0b5..69895c344 100644 --- a/lib/puppet/network/format.rb +++ b/lib/puppet/network/format.rb @@ -106,6 +106,6 @@ class Puppet::Network::Format method = send(name) - return(type == :class ? klass.respond_to?(method) : klass.instance_methods.include?(method)) + return(type == :class ? klass.respond_to?(method) : klass.method_defined?(method)) end end diff --git a/lib/puppet/provider/mount/parsed.rb b/lib/puppet/provider/mount/parsed.rb index 7c3f41bbd..8d48dad57 100755 --- a/lib/puppet/provider/mount/parsed.rb +++ b/lib/puppet/provider/mount/parsed.rb @@ -47,6 +47,24 @@ Puppet::Type.type(:mount).provide( end end + def self.instances + providers = super + mounts = mountinstances.dup + + # Update fstab entries that are mounted + providers.each do |prov| + if mounts.delete({:name => prov.get(:name), :mounted => :yes}) then + prov.set(:ensure => :mounted) + end + end + + # Add mounts that are not in fstab but mounted + mounts.each do |mount| + providers << new(:ensure => :ghost, :name => mount[:name]) + end + providers + end + def self.prefetch(resources = nil) # Get providers for all resources the user defined and that match # a record in /etc/fstab. diff --git a/lib/puppet/provider/ssh_authorized_key/parsed.rb b/lib/puppet/provider/ssh_authorized_key/parsed.rb index 6a3855c0e..81b1fbcfa 100644 --- a/lib/puppet/provider/ssh_authorized_key/parsed.rb +++ b/lib/puppet/provider/ssh_authorized_key/parsed.rb @@ -42,12 +42,6 @@ require 'puppet/provider/parsedfile' 0600 end - def target - @resource.should(:target) || File.expand_path("~#{@resource.should(:user)}/.ssh/authorized_keys") - rescue - raise Puppet::Error, "Target not defined and/or specified user does not exist yet" - end - def user uid = File.stat(target).uid Etc.getpwuid(uid).name diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb index 214516908..59e387d00 100644 --- a/lib/puppet/resource.rb +++ b/lib/puppet/resource.rb @@ -269,7 +269,7 @@ class Puppet::Resource else " %-#{attr_max}s => %s,\n" % [ k, "\'#{v}\'" ] end - } + }.join "%s { '%s':\n%s}" % [self.type.to_s.downcase, self.title, attributes] end diff --git a/lib/puppet/type/ssh_authorized_key.rb b/lib/puppet/type/ssh_authorized_key.rb index 8338e2d64..170dc8383 100644 --- a/lib/puppet/type/ssh_authorized_key.rb +++ b/lib/puppet/type/ssh_authorized_key.rb @@ -14,6 +14,10 @@ module Puppet system-wide primary key and therefore has to be unique." isnamevar + + validate do |value| + raise Puppet::Error, "Resourcename must not contain whitespace: #{value}" if value =~ /\s/ + end end newproperty(:type) do @@ -28,6 +32,10 @@ module Puppet newproperty(:key) do desc "The key itself; generally a long string of hex digits." + + validate do |value| + raise Puppet::Error, "Key must not contain whitespace: #{value}" if value =~ /\s/ + end end newproperty(:user) do @@ -82,6 +90,10 @@ module Puppet value.join(",") end end + + validate do |value| + raise Puppet::Error, "Options must be provided as an array, not a comma separated list" if value != :absent and value.include?(',') + end end autorequire(:user) do diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index d06f44808..ce9d4642b 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -1,5 +1,6 @@ # A module to collect utility functions. +require 'English' require 'puppet/util/monkey_patches' require 'sync' require 'puppet/external/lock' diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb index cec8a57d9..255388d58 100644 --- a/lib/puppet/util/selinux.rb +++ b/lib/puppet/util/selinux.rb @@ -140,7 +140,7 @@ module Puppet::Util::SELinux def read_mounts mounts = "" begin - if File.instance_methods.include? "read_nonblock" + if File.method_defined? "read_nonblock" # If possible we use read_nonblock in a loop rather than read to work- # a linux kernel bug. See ticket #1963 for details. mountfh = File.open("/proc/mounts") |