diff options
author | Bryan Jen <bryan.jen@gmail.com> | 2015-08-06 11:00:17 -0700 |
---|---|---|
committer | Bryan Jen <bryan.jen@gmail.com> | 2015-08-06 11:00:17 -0700 |
commit | 061d0c29fc54391f3e713e9ed76da3933b19083b (patch) | |
tree | e4bdbfb53098c64a2fcc10089c2b5e6dd0f8675c | |
parent | e815da59620c4fe7ae3e612b99ef20e8924f8f23 (diff) | |
parent | a7adcda803abe82e6a16e2410c10d58abedbd82d (diff) |
Merge pull request #497 from domcleal/tickets/master/MODULES-2316
(MODULES-2316) Change file_type boolean parameter to symbols
-rw-r--r-- | lib/puppet/provider/file_line/ruby.rb | 4 | ||||
-rw-r--r-- | lib/puppet/type/file_line.rb | 4 | ||||
-rwxr-xr-x | spec/unit/puppet/provider/file_line/ruby_spec.rb | 2 | ||||
-rwxr-xr-x | spec/unit/puppet/type/file_line_spec.rb | 2 |
4 files changed, 6 insertions, 6 deletions
diff --git a/lib/puppet/provider/file_line/ruby.rb b/lib/puppet/provider/file_line/ruby.rb index ea1d44d..d4cdfec 100644 --- a/lib/puppet/provider/file_line/ruby.rb +++ b/lib/puppet/provider/file_line/ruby.rb @@ -1,6 +1,6 @@ Puppet::Type.type(:file_line).provide(:ruby) do def exists? - if !resource[:replace] and count_matches(match_regex) > 0 + if resource[:replace].to_s != 'true' and count_matches(match_regex) > 0 true else lines.find do |line| @@ -10,7 +10,7 @@ Puppet::Type.type(:file_line).provide(:ruby) do end 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] handle_create_with_match elsif resource[:after] diff --git a/lib/puppet/type/file_line.rb b/lib/puppet/type/file_line.rb index 190105c..4a96ba7 100644 --- a/lib/puppet/type/file_line.rb +++ b/lib/puppet/type/file_line.rb @@ -1,4 +1,3 @@ -require 'puppet/parameter/boolean' Puppet::Type.newtype(:file_line) do desc <<-EOT @@ -79,8 +78,9 @@ Puppet::Type.newtype(:file_line) do 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' + newvalues(true, false) defaultto true end diff --git a/spec/unit/puppet/provider/file_line/ruby_spec.rb b/spec/unit/puppet/provider/file_line/ruby_spec.rb index 5eff09a..792391a 100755 --- a/spec/unit/puppet/provider/file_line/ruby_spec.rb +++ b/spec/unit/puppet/provider/file_line/ruby_spec.rb @@ -85,7 +85,7 @@ describe provider_class do :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 context "when matching" do diff --git a/spec/unit/puppet/type/file_line_spec.rb b/spec/unit/puppet/type/file_line_spec.rb index 58c88e3..f1430f2 100755 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -50,7 +50,7 @@ describe Puppet::Type.type(:file_line) do expect(file_line[:ensure]).to eq :present end it 'should default to replace => true' do - expect(file_line[:replace]).to eq true + expect(file_line[:replace]).to eq :true end it "should autorequire the file it manages" do |