From 69cf2fe278eb20b718663535bbae18965a1ece63 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 19 May 2006 18:31:20 +0000 Subject: Adding a small fix to cron tabs; they will at least parse tabs that have env settings in them, although you still cannot, at this point, set them. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1216 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/type/cron.rb | 12 ++++++++++++ test/types/cron.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb index ea34f4629..917a6ffb1 100755 --- a/lib/puppet/type/cron.rb +++ b/lib/puppet/type/cron.rb @@ -256,6 +256,14 @@ module Puppet class << self attr_accessor :filetype + + def cronobj(name) + if defined? @tabs + return @tabs[name] + else + return nil + end + end end attr_accessor :uid @@ -353,6 +361,10 @@ module Puppet when /^#/: # add other comments to the list as they are @instances[user] << line + when /^\s*(\w+)\s*=\s*(.+)\s*$/: + # Match env settings. For now, just chunk them in there, + # but eventually we'll want to manage them in the model somehow. + @instances[user] << line else if match = /^(\S+) (\S+) (\S+) (\S+) (\S+) (.+)$/.match(line) fields().zip(match.captures).each { |param, value| diff --git a/test/types/cron.rb b/test/types/cron.rb index 496274d88..22c2e98f9 100755 --- a/test/types/cron.rb +++ b/test/types/cron.rb @@ -422,6 +422,34 @@ class TestCron < Test::Unit::TestCase end end end + + # Make sure we don't puke on env settings + def test_envsettings + cron = mkcron("envtst") + + assert_apply(cron) + + obj = Puppet::Type::Cron.cronobj(@me) + + assert(obj) + + text = obj.read + + text = "SHELL = /path/to/some/thing\n" + text + + obj.write(text) + + assert_nothing_raised { + cron.retrieve + } + + cron[:command] = "/some/other/command" + + assert_apply(cron) + + assert(obj.read =~ /SHELL/, "lost env setting") + + end end # $Id$ -- cgit