From 9e17c25117f9f3012f64d3d39053750159632782 Mon Sep 17 00:00:00 2001 From: Jacob Helwig Date: Wed, 22 Sep 2010 15:57:51 -0700 Subject: Fix #4743: Allow the audit meta-parameter to accept both 'all', and :all --- lib/puppet/type.rb | 6 +++--- spec/unit/type_spec.rb | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index f9aacece8..1b6e7dcd7 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -965,7 +965,7 @@ class Type the value, and any changes already get logged." validate do |list| - list = Array(list) + list = Array(list).collect {|p| p.to_sym} unless list == [:all] list.each do |param| next if @resource.class.validattr?(param) @@ -990,8 +990,8 @@ class Type end def properties_to_audit(list) - if list == :all - list = all_properties if list == :all + if !list.kind_of?(Array) && list.to_sym == :all + list = all_properties else list = Array(list).collect { |p| p.to_sym } end diff --git a/spec/unit/type_spec.rb b/spec/unit/type_spec.rb index 487750e52..48b00ec4a 100755 --- a/spec/unit/type_spec.rb +++ b/spec/unit/type_spec.rb @@ -545,6 +545,13 @@ describe Puppet::Type.metaparamclass(:audit) do @resource[:audit].should == list end + it "should accept the string 'all' to specify auditing all possible properties" do + @resource[:audit] = 'all' + + list = @resource.class.properties.collect { |p| p.name } + @resource[:audit].should == list + end + it "should fail if asked to audit an invalid property" do lambda { @resource[:audit] = :foobar }.should raise_error(Puppet::Error) end -- cgit From bba04e08ccf631291a042cca5985591899eca869 Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Wed, 22 Sep 2010 16:47:37 -0700 Subject: Fix for #4746 -- Newline goes at the _end_ of the line Fredrik Eriksson's suggested change, from the ticket. --- lib/puppet/provider/service/freebsd.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/provider/service/freebsd.rb b/lib/puppet/provider/service/freebsd.rb index 10970e4da..c75c3c9ab 100644 --- a/lib/puppet/provider/service/freebsd.rb +++ b/lib/puppet/provider/service/freebsd.rb @@ -78,7 +78,7 @@ Puppet::Type.type(:service).provide :freebsd, :parent => :init do # Add a new setting to the rc files def rc_add(service, rcvar, yesno) - append = "\n\# Added by Puppet\n#{rcvar}_enable=\"#{yesno}\"" + append = "\# Added by Puppet\n#{rcvar}_enable=\"#{yesno}\"\n" # First, try the one-file-per-service style if File.exists?(@@rcconf_dir) File.open(@@rcconf_dir + "/#{service}", File::WRONLY | File::APPEND | File::CREAT, 0644) { -- cgit From 06bf566cf71b5a690c61887dff0538922b026f64 Mon Sep 17 00:00:00 2001 From: Jesse Wolfe Date: Tue, 21 Sep 2010 13:19:11 -0700 Subject: [#4787] Missing require causing failure This code was using a constant that might not always be loaded. --- lib/puppet/type/tidy.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb index 64a7a1a88..65cc077cf 100755 --- a/lib/puppet/type/tidy.rb +++ b/lib/puppet/type/tidy.rb @@ -1,5 +1,6 @@ Puppet::Type.newtype(:tidy) do require 'puppet/file_serving/fileset' + require 'puppet/file_bucket/dipper' @doc = "Remove unwanted files based on specific criteria. Multiple criteria are OR'd together, so a file that is too large but is not -- cgit From 8cd1540f82cbdf903c164bdbc2c7229e34a4178b Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Fri, 17 Sep 2010 16:42:40 -0700 Subject: [#4692] undefined variables cause :undef to be passed to functions The :undef symbol, which we use internally to distinguish between undefined variables and variables whose value is the empty string, is being leaked in calls to functions (e.g. "split"). This is a departure from 0.25.x behavior, where undefined variables evaluated to "". This patch restores the 0.25.x behavior. --- lib/puppet/parser/ast/function.rb | 2 +- spec/unit/parser/ast/function_spec.rb | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/puppet/parser/ast/function.rb b/lib/puppet/parser/ast/function.rb index 74023f631..80e6e6512 100644 --- a/lib/puppet/parser/ast/function.rb +++ b/lib/puppet/parser/ast/function.rb @@ -28,7 +28,7 @@ class Puppet::Parser::AST end # We don't need to evaluate the name, because it's plaintext - args = @arguments.safeevaluate(scope) + args = @arguments.safeevaluate(scope).map { |x| x == :undef ? '' : x } scope.send("function_#{@name}", args) end diff --git a/spec/unit/parser/ast/function_spec.rb b/spec/unit/parser/ast/function_spec.rb index c57c7f098..38e344157 100644 --- a/spec/unit/parser/ast/function_spec.rb +++ b/spec/unit/parser/ast/function_spec.rb @@ -61,20 +61,30 @@ describe Puppet::Parser::AST::Function do end it "should call the underlying ruby function" do - argument = stub 'arg', :safeevaluate => "nothing" + argument = stub 'arg', :safeevaluate => ["nothing"] Puppet::Parser::Functions.stubs(:function).with("exist").returns(true) func = Puppet::Parser::AST::Function.new :name => "exist", :ftype => :statement, :arguments => argument - @scope.expects(:function_exist).with("nothing") + @scope.expects(:function_exist).with(["nothing"]) + + func.evaluate(@scope) + end + + it "should convert :undef to '' in arguments" do + argument = stub 'arg', :safeevaluate => ["foo", :undef, "bar"] + Puppet::Parser::Functions.stubs(:function).with("exist").returns(true) + func = Puppet::Parser::AST::Function.new :name => "exist", :ftype => :statement, :arguments => argument + + @scope.expects(:function_exist).with(["foo", "", "bar"]) func.evaluate(@scope) end it "should return the ruby function return for rvalue functions" do - argument = stub 'arg', :safeevaluate => "nothing" + argument = stub 'arg', :safeevaluate => ["nothing"] Puppet::Parser::Functions.stubs(:function).with("exist").returns(true) func = Puppet::Parser::AST::Function.new :name => "exist", :ftype => :statement, :arguments => argument - @scope.stubs(:function_exist).with("nothing").returns("returning") + @scope.stubs(:function_exist).with(["nothing"]).returns("returning") func.evaluate(@scope).should == "returning" end -- cgit