Merge pull request #497 from domcleal/tickets/master/MODULES-2316
(MODULES-2316) Change file_type boolean parameter to symbols
This commit is contained in:
commit
061d0c29fc
4 changed files with 6 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
||||||
Puppet::Type.type(:file_line).provide(:ruby) do
|
Puppet::Type.type(:file_line).provide(:ruby) do
|
||||||
def exists?
|
def exists?
|
||||||
if !resource[:replace] and count_matches(match_regex) > 0
|
if resource[:replace].to_s != 'true' and count_matches(match_regex) > 0
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
lines.find do |line|
|
lines.find do |line|
|
||||||
|
@ -10,7 +10,7 @@ Puppet::Type.type(:file_line).provide(:ruby) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
unless !resource[:replace] and count_matches(match_regex) > 0
|
unless resource[:replace].to_s != 'true' and count_matches(match_regex) > 0
|
||||||
if resource[:match]
|
if resource[:match]
|
||||||
handle_create_with_match
|
handle_create_with_match
|
||||||
elsif resource[:after]
|
elsif resource[:after]
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'puppet/parameter/boolean'
|
|
||||||
Puppet::Type.newtype(:file_line) do
|
Puppet::Type.newtype(:file_line) do
|
||||||
|
|
||||||
desc <<-EOT
|
desc <<-EOT
|
||||||
|
@ -79,8 +78,9 @@ Puppet::Type.newtype(:file_line) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
newparam(:replace, :boolean => true, :parent => Puppet::Parameter::Boolean) do
|
newparam(:replace) do
|
||||||
desc 'If true, replace line that matches. If false, do not write line if a match is found'
|
desc 'If true, replace line that matches. If false, do not write line if a match is found'
|
||||||
|
newvalues(true, false)
|
||||||
defaultto true
|
defaultto true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ describe provider_class do
|
||||||
:replace => 'asgadga',
|
:replace => 'asgadga',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}.to raise_error(Puppet::Error, /Invalid value "asgadga"\. Valid values are true, false, yes, no\./)
|
}.to raise_error(Puppet::Error, /Invalid value "asgadga"\. Valid values are true, false\./)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context "when matching" do
|
context "when matching" do
|
||||||
|
|
|
@ -50,7 +50,7 @@ describe Puppet::Type.type(:file_line) do
|
||||||
expect(file_line[:ensure]).to eq :present
|
expect(file_line[:ensure]).to eq :present
|
||||||
end
|
end
|
||||||
it 'should default to replace => true' do
|
it 'should default to replace => true' do
|
||||||
expect(file_line[:replace]).to eq true
|
expect(file_line[:replace]).to eq :true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should autorequire the file it manages" do
|
it "should autorequire the file it manages" do
|
||||||
|
|
Loading…
Reference in a new issue