summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-07-14 21:13:04 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-07-14 21:13:04 +0000
commit60ef57815050497110925283299efde2b7aafcd2 (patch)
tree0d4369666d8206ba89a45040201c9812e33021ab
parent53c2f0a4c93d51eed664761bc652e73ccf078a82 (diff)
downloadpuppet-60ef57815050497110925283299efde2b7aafcd2.tar.gz
puppet-60ef57815050497110925283299efde2b7aafcd2.tar.xz
puppet-60ef57815050497110925283299efde2b7aafcd2.zip
Fixing the rest of #705, except for the env stuff, which I was not able to reproduce.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2697 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-xlib/puppet/provider/cron/crontab.rb1
-rwxr-xr-xlib/puppet/type/cron.rb8
-rw-r--r--lib/puppet/util/fileparsing.rb8
-rwxr-xr-xtest/ral/types/cron.rb16
4 files changed, 29 insertions, 4 deletions
diff --git a/lib/puppet/provider/cron/crontab.rb b/lib/puppet/provider/cron/crontab.rb
index fcf86fc46..3296544f9 100755
--- a/lib/puppet/provider/cron/crontab.rb
+++ b/lib/puppet/provider/cron/crontab.rb
@@ -30,6 +30,7 @@ Puppet::Type.type(:cron).provide(:crontab,
}
crontab = record_line :crontab, :fields => %w{minute hour monthday month weekday command},
+ :match => %r{^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$},
:optional => %w{minute hour weekday month monthday}, :absent => "*"
class << crontab
diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb
index f0188e8e7..84a8d8af6 100755
--- a/lib/puppet/type/cron.rb
+++ b/lib/puppet/type/cron.rb
@@ -301,8 +301,12 @@ Puppet::Type.newtype(:cron) do
end
def is_to_s(newvalue)
- if newvalue
- newvalue.join(",")
+ if newvalue
+ if newvalue.is_a?(Array)
+ newvalue.join(",")
+ else
+ newvalue
+ end
else
nil
end
diff --git a/lib/puppet/util/fileparsing.rb b/lib/puppet/util/fileparsing.rb
index 545a54071..8e69681cf 100644
--- a/lib/puppet/util/fileparsing.rb
+++ b/lib/puppet/util/fileparsing.rb
@@ -168,8 +168,12 @@ module Puppet::Util::FileParsing
if match = regex.match(line)
fields = []
ret = {}
- record.fields.zip(match.captures).each do |f, v|
- ret[f] = v
+ record.fields.zip(match.captures).each do |field, value|
+ if value == record.absent
+ ret[field] = :absent
+ else
+ ret[field] = value
+ end
end
else
nil
diff --git a/test/ral/types/cron.rb b/test/ral/types/cron.rb
index be94463d2..75a10c6fc 100755
--- a/test/ral/types/cron.rb
+++ b/test/ral/types/cron.rb
@@ -487,6 +487,22 @@ class TestCron < Test::Unit::TestCase
"target did not default to user with crontab")
end
end
+
+ # #705 - make sure extra spaces don't screw things up
+ def test_spaces_in_command
+ string = "echo multiple spaces"
+ cron = @crontype.create(:name => "testing", :command => string)
+ assert_apply(cron)
+
+ cron.class.clear
+ cron = @crontype.create(:name => "testing", :command => string)
+ # Now make sure that it's correctly in sync
+ cron.provider.class.prefetch("testing" => cron)
+ properties = cron.retrieve
+ command, result = properties.find { |prop, value| prop.name == :command }
+ assert_equal(string, result, "Cron did not pick up extra spaces in command")
+ assert(command.insync?(string), "Command changed with multiple spaces")
+ end
end