summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Kearney <bkearney@redhat.com>2009-02-12 09:32:01 -0500
committerJames Turnbull <james@lovedthanlost.net>2009-02-13 02:08:49 +1100
commitcc4d6586d420f4beea1eeef85cfe7a28f8e493ac (patch)
tree213a5b3d4b7234cc0fc9b8ecfff5d9f03d65cf8a
parent5e35166f1b7219d470916d1ee7a4e6852afaf1f9 (diff)
downloadpuppet-cc4d6586d420f4beea1eeef85cfe7a28f8e493ac.tar.gz
puppet-cc4d6586d420f4beea1eeef85cfe7a28f8e493ac.tar.xz
puppet-cc4d6586d420f4beea1eeef85cfe7a28f8e493ac.zip
Bug #1948: Added patch by jab to support the correct ins syntax. Updated the test cases as well
-rw-r--r--CHANGELOG2
-rw-r--r--lib/puppet/provider/augeas/augeas.rb32
-rw-r--r--spec/unit/provider/augeas/augeas.rb25
3 files changed, 41 insertions, 18 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 1eb84a02c..329e700f7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,6 @@
0.24.8
+ Fixing #1948 and #1953 - augeas ins bug: wrong number of arguments (1 for 3)
+
Fixing #944 - changing error message from warning to info - connection recycled
Fixed #961 - puppetd creating too many/not closing TCP connections
diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb
index 0ffddebb0..fd47da389 100644
--- a/lib/puppet/provider/augeas/augeas.rb
+++ b/lib/puppet/provider/augeas/augeas.rb
@@ -164,14 +164,34 @@ Puppet::Type.type(:augeas).provide(:augeas) do
fail("invalid command #{cmd_array.join[" "]}") if cmd_array.length < 2
command = cmd_array[0]
cmd_array.shift()
- cmd_array[0]=File.join(context, cmd_array[0])
- debug("sending command '#{command}' with params #{cmd_array.inspect}")
begin
case command
- when "set": aug.set(cmd_array[0], cmd_array[1])
- when "rm", "remove": aug.rm(cmd_array[0])
- when "clear": aug.clear(cmd_array[0])
- when "insert", "ins": aug.insert(cmd_array[0])
+ when "set":
+ cmd_array[0]=File.join(context, cmd_array[0])
+ debug("sending command '#{command}' with params #{cmd_array.inspect}")
+ aug.set(cmd_array[0], cmd_array[1])
+ when "rm", "remove":
+ cmd_array[0]=File.join(context, cmd_array[0])
+ debug("sending command '#{command}' with params #{cmd_array.inspect}")
+ aug.rm(cmd_array[0])
+ when "clear":
+ cmd_array[0]=File.join(context, cmd_array[0])
+ debug("sending command '#{command}' with params #{cmd_array.inspect}")
+ aug.clear(cmd_array[0])
+ when "insert", "ins"
+ if cmd_array.size < 3
+ fail("ins requires 3 parameters")
+ end
+ label = cmd_array[0]
+ where = cmd_array[1]
+ path = File.join(context, cmd_array[2])
+ case where
+ when "before": before = true
+ when "after": before = false
+ else fail("Invalid value '#{where}' for where param")
+ end
+ debug("sending command '#{command}' with params #{[label, where, path]}")
+ aug.insert(path, label, before)
else fail("Command '#{command}' is not supported")
end
rescue Exception => e
diff --git a/spec/unit/provider/augeas/augeas.rb b/spec/unit/provider/augeas/augeas.rb
index 1bbf18f83..4bc1814e5 100644
--- a/spec/unit/provider/augeas/augeas.rb
+++ b/spec/unit/provider/augeas/augeas.rb
@@ -206,30 +206,31 @@ describe provider_class do
@augeas.expects(:save).returns(true)
@provider.execute_changes.should == :executed
end
-
- it "should handle insert commands" do
- command = [["insert", "/Jar/Jar"]]
+
+
+ it "should handle ins commands with before" do
+ command = [["ins", "Binks", "before", "/Jar/Jar"]]
context = "/foo"
@resource.expects(:[]).times(2).returns(command).then.returns(context)
- @augeas.expects(:insert).with("/foo/Jar/Jar")
+ @augeas.expects(:insert).with("/foo/Jar/Jar", "Binks", true)
@augeas.expects(:save).returns(true)
@provider.execute_changes.should == :executed
- end
-
- it "should handle ins commands" do
- command = [["ins", "/Jar/Jar"]]
+ end
+
+ it "should handle ins commands with before" do
+ command = [["ins", "Binks", "after", "/Jar/Jar"]]
context = "/foo"
@resource.expects(:[]).times(2).returns(command).then.returns(context)
- @augeas.expects(:insert).with("/foo/Jar/Jar")
+ @augeas.expects(:insert).with("/foo/Jar/Jar", "Binks", false)
@augeas.expects(:save).returns(true)
@provider.execute_changes.should == :executed
- end
+ end
it "should handle multiple commands" do
- command = [["ins", "/Jar/Jar"], ["clear", "/Jar/Jar"]]
+ command = [["ins", "Binks", "after", "/Jar/Jar"], ["clear", "/Jar/Jar"]]
context = "/foo"
@resource.expects(:[]).times(2).returns(command).then.returns(context)
- @augeas.expects(:insert).with("/foo/Jar/Jar")
+ @augeas.expects(:insert).with("/foo/Jar/Jar", "Binks", false)
@augeas.expects(:clear).with("/foo/Jar/Jar")
@augeas.expects(:save).returns(true)
@provider.execute_changes.should == :executed