0001-Added-patch-by-jab-to-support-the-correct-ins-syntax.patch
| b/lib/puppet/provider/augeas/augeas.rb | ||
|---|---|---|
| 164 | 164 |
fail("invalid command #{cmd_array.join[" "]}") if cmd_array.length < 2
|
| 165 | 165 |
command = cmd_array[0] |
| 166 | 166 |
cmd_array.shift() |
| 167 |
cmd_array[0]=File.join(context, cmd_array[0]) |
|
| 168 |
debug("sending command '#{command}' with params #{cmd_array.inspect}")
|
|
| 169 | 167 |
begin |
| 170 | 168 |
case command |
| 171 |
when "set": aug.set(cmd_array[0], cmd_array[1]) |
|
| 172 |
when "rm", "remove": aug.rm(cmd_array[0]) |
|
| 173 |
when "clear": aug.clear(cmd_array[0]) |
|
| 174 |
when "insert", "ins": aug.insert(cmd_array[0]) |
|
| 169 |
when "set": |
|
| 170 |
cmd_array[0]=File.join(context, cmd_array[0]) |
|
| 171 |
debug("sending command '#{command}' with params #{cmd_array.inspect}")
|
|
| 172 |
aug.set(cmd_array[0], cmd_array[1]) |
|
| 173 |
when "rm", "remove": |
|
| 174 |
cmd_array[0]=File.join(context, cmd_array[0]) |
|
| 175 |
debug("sending command '#{command}' with params #{cmd_array.inspect}")
|
|
| 176 |
aug.rm(cmd_array[0]) |
|
| 177 |
when "clear": |
|
| 178 |
cmd_array[0]=File.join(context, cmd_array[0]) |
|
| 179 |
debug("sending command '#{command}' with params #{cmd_array.inspect}")
|
|
| 180 |
aug.clear(cmd_array[0]) |
|
| 181 |
when "insert", "ins" |
|
| 182 |
if cmd_array.size < 3 |
|
| 183 |
fail("ins requires 3 parameters")
|
|
| 184 |
end |
|
| 185 |
label = cmd_array[0] |
|
| 186 |
where = cmd_array[1] |
|
| 187 |
path = File.join(context, cmd_array[2]) |
|
| 188 |
case where |
|
| 189 |
when "before": before = true |
|
| 190 |
when "after": before = false |
|
| 191 |
else fail("Invalid value '#{where}' for where param")
|
|
| 192 |
end |
|
| 193 |
debug("sending command '#{command}' with params #{[label, where, path]}")
|
|
| 194 |
aug.insert(path, label, before) |
|
| 175 | 195 |
else fail("Command '#{command}' is not supported")
|
| 176 | 196 |
end |
| 177 | 197 |
rescue Exception => e |
| b/spec/unit/provider/augeas/augeas.rb | ||
|---|---|---|
| 206 | 206 |
@augeas.expects(:save).returns(true) |
| 207 | 207 |
@provider.execute_changes.should == :executed |
| 208 | 208 |
end |
| 209 |
|
|
| 210 |
it "should handle insert commands" do |
|
| 211 |
command = [["insert", "/Jar/Jar"]] |
|
| 209 |
|
|
| 210 | ||
| 211 |
it "should handle ins commands with before" do |
|
| 212 |
command = [["ins", "Binks", "before", "/Jar/Jar"]] |
|
| 212 | 213 |
context = "/foo" |
| 213 | 214 |
@resource.expects(:[]).times(2).returns(command).then.returns(context) |
| 214 |
@augeas.expects(:insert).with("/foo/Jar/Jar")
|
|
| 215 |
@augeas.expects(:insert).with("/foo/Jar/Jar", "Binks", true)
|
|
| 215 | 216 |
@augeas.expects(:save).returns(true) |
| 216 | 217 |
@provider.execute_changes.should == :executed |
| 217 |
end
|
|
| 218 |
|
|
| 219 |
it "should handle ins commands" do |
|
| 220 |
command = [["ins", "/Jar/Jar"]] |
|
| 218 |
end |
|
| 219 | ||
| 220 |
it "should handle ins commands with before" do
|
|
| 221 |
command = [["ins", "Binks", "after", "/Jar/Jar"]]
|
|
| 221 | 222 |
context = "/foo" |
| 222 | 223 |
@resource.expects(:[]).times(2).returns(command).then.returns(context) |
| 223 |
@augeas.expects(:insert).with("/foo/Jar/Jar")
|
|
| 224 |
@augeas.expects(:insert).with("/foo/Jar/Jar", "Binks", false)
|
|
| 224 | 225 |
@augeas.expects(:save).returns(true) |
| 225 | 226 |
@provider.execute_changes.should == :executed |
| 226 |
end |
|
| 227 |
end
|
|
| 227 | 228 |
|
| 228 | 229 |
it "should handle multiple commands" do |
| 229 |
command = [["ins", "/Jar/Jar"], ["clear", "/Jar/Jar"]] |
|
| 230 |
command = [["ins", "Binks", "after", "/Jar/Jar"], ["clear", "/Jar/Jar"]]
|
|
| 230 | 231 |
context = "/foo" |
| 231 | 232 |
@resource.expects(:[]).times(2).returns(command).then.returns(context) |
| 232 |
@augeas.expects(:insert).with("/foo/Jar/Jar")
|
|
| 233 |
@augeas.expects(:insert).with("/foo/Jar/Jar", "Binks", false)
|
|
| 233 | 234 |
@augeas.expects(:clear).with("/foo/Jar/Jar")
|
| 234 | 235 |
@augeas.expects(:save).returns(true) |
| 235 | 236 |
@provider.execute_changes.should == :executed |
| 236 |
- |
|