Skip to content

Commit

Permalink
Update puppetlabs-inifile to be5fc47
Browse files Browse the repository at this point in the history
This module update commit was generated by Bade.
For more info please check https://github.com/paramite/bade

This commit is setting modules to following state:
inifile
 - old commit: 6b399c2
 - new commit: be5fc47

Signed-off-by: Gael Chamoulaud <[email protected]>
  • Loading branch information
strider committed Jan 26, 2015
1 parent 8690445 commit 7a1ac31
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 109 deletions.
2 changes: 1 addition & 1 deletion Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mod 'horizon',
:git => 'https://github.com/stackforge/puppet-horizon.git'

mod 'inifile',
:commit => '6b399c2bc6b34fd01c704dd5836c61935cf9e4f1',
:commit => 'be5fc47f00466a2e6293145b3a0d4fcb586bcf15',
:git => 'https://github.com/puppetlabs/puppetlabs-inifile.git'

mod 'ipa',
Expand Down
2 changes: 2 additions & 0 deletions inifile/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ spec/fixtures/
.vagrant/
.bundle/
coverage/
.idea/
*.iml
21 changes: 18 additions & 3 deletions inifile/Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"

def location_for(place, fake_version = nil)
if place =~ /^(git:[^#]*)#(.*)/
[fake_version, { :git => $1, :branch => $2, :require => false }].compact
elsif place =~ /^file:\/\/(.*)/
['>= 0', { :path => File.expand_path($1), :require => false }]
else
[place, { :require => false }]
end
end

group :development, :unit_tests do
gem 'rake', :require => false
gem 'rspec-puppet', :require => false
Expand All @@ -10,19 +20,24 @@ group :development, :unit_tests do
gem 'json', :require => false
end

beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
group :system_tests do
gem 'beaker-rspec', :require => false
if beaker_rspec_version
gem 'beaker-rspec', *location_for(beaker_rspec_version)
else
gem 'beaker-rspec', :require => false
end
gem 'serverspec', :require => false
end

if facterversion = ENV['FACTER_GEM_VERSION']
gem 'facter', facterversion, :require => false
gem 'facter', *location_for(facterversion)
else
gem 'facter', :require => false
end

if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
gem 'puppet', *location_for(puppetversion)
else
gem 'puppet', :require => false
end
Expand Down
10 changes: 2 additions & 8 deletions inifile/lib/puppet/type/ini_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,9 @@

newparam(:key_val_separator) do
desc 'The separator string to use between each setting name and value. ' +
'Defaults to " = ", but you could use this to override e.g. whether ' +
'or not the separator should include whitespace.'
'Defaults to " = ", but you could use this to override e.g. ": ", or' +
'whether or not the separator should include whitespace.'
defaultto(" = ")

validate do |value|
unless value.scan('=').size == 1
raise Puppet::Error, ":key_val_separator must contain exactly one = character."
end
end
end

newproperty(:value) do
Expand Down
10 changes: 2 additions & 8 deletions inifile/lib/puppet/type/ini_subsetting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,9 @@

newparam(:key_val_separator) do
desc 'The separator string to use between each setting name and value. ' +
'Defaults to " = ", but you could use this to override e.g. whether ' +
'or not the separator should include whitespace.'
'Defaults to " = ", but you could use this to override e.g. ": ", or' +
'whether or not the separator should include whitespace.'
defaultto(" = ")

validate do |value|
unless value.scan('=').size == 1
raise Puppet::Error, ":key_val_separator must contain exactly one = character."
end
end
end

newparam(:quote_char) do
Expand Down
12 changes: 8 additions & 4 deletions inifile/lib/puppet/util/ini_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ module Puppet
module Util
class IniFile

@@SECTION_REGEX = /^\s*\[([^\]]*)\]\s*$/
@@SETTING_REGEX = /^(\s*)([^\s=]*)(\s*=\s*)(.*)\s*$/
@@COMMENTED_SETTING_REGEX = /^(\s*)[#;]+(\s*)([^\s=]*)(\s*=[ \t]*)(.*)\s*$/

def initialize(path, key_val_separator = ' = ')

k_v_s = key_val_separator.strip

@@SECTION_REGEX = /^\s*\[([^\]]*)\]\s*$/
@@SETTING_REGEX = /^(\s*)([^\s#{k_v_s}]*)(\s*#{k_v_s}\s*)(.*)\s*$/
@@COMMENTED_SETTING_REGEX = /^(\s*)[#;]+(\s*)([^\s#{k_v_s}]*)(\s*#{k_v_s}[ \t]*)(.*)\s*$/


@path = path
@key_val_separator = key_val_separator
@section_names = []
Expand Down
64 changes: 1 addition & 63 deletions inifile/spec/acceptance/ini_setting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,7 @@
apply_manifest(pp, :catch_changes => true)
end

describe file("#{tmpdir}/ini_setting.ini") do
it { should be_file }
#XXX Solaris 10 doesn't support multi-line grep
it("should contain four = five\n[one]\ntwo = three", :unless => fact('osfamily') == 'Solaris') {
should contain("four = five\n[one]\ntwo = three")
}
end
it_behaves_like 'has_content', "#{tmpdir}/ini_setting.ini", pp, "four = five\n[one]\ntwo = three"
end

context '=> absent for key/value' do
Expand Down Expand Up @@ -113,40 +107,6 @@
end
end

context '=> absent for section', :pending => "cannot ensure absent on a section" do
before :all do
if fact('osfamily') == 'Darwin'
shell("echo \"four = five\n[one]\ntwo = three\" > #{tmpdir}/ini_setting.ini")
else
shell("echo -e \"four = five\n[one]\ntwo = three\" > #{tmpdir}/ini_setting.ini")
end
end
after :all do
shell("cat #{tmpdir}/ini_setting.ini", :acceptable_exit_codes => [0,1,2])
shell("rm #{tmpdir}/ini_setting.ini", :acceptable_exit_codes => [0,1,2])
end

pp = <<-EOS
ini_setting { 'ensure => absent for section':
ensure => absent,
path => "#{tmpdir}/ini_setting.ini",
section => 'one',
}
EOS

it 'applies the manifest twice' do
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end

describe file("#{tmpdir}/ini_setting.ini") do
it { should be_file }
it { should contain('four = five') }
it { should_not contain('[one]') }
it { should_not contain('two = three') }
end
end

context '=> absent for global' do
before :all do
if fact('osfamily') == 'Darwin'
Expand Down Expand Up @@ -282,27 +242,5 @@
it_behaves_like 'has_content', "#{tmpdir}/key_val_separator.ini", pp, content
end
end

{
"key_val_separator => ''," => /must contain exactly one/,
"key_val_separator => ','," => /must contain exactly one/,
"key_val_separator => ' '," => /must contain exactly one/,
"key_val_separator => ' == '," => /must contain exactly one/,
}.each do |parameter, error|
context "with \"#{parameter}\" raises \"#{error}\"" do
pp = <<-EOS
ini_setting { "with #{parameter} raises #{error}":
ensure => present,
section => 'one',
setting => 'two',
value => 'three',
path => "#{tmpdir}/key_val_separator.ini",
#{parameter}
}
EOS

it_behaves_like 'has_error', "#{tmpdir}/key_val_separator.ini", pp, error
end
end
end
end
51 changes: 29 additions & 22 deletions inifile/spec/unit/puppet/provider/ini_setting/ruby_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -495,39 +495,46 @@ def self.file_path
EOS
}

it "should fail if the separator doesn't include an equals sign" do
expect {
Puppet::Type::Ini_setting.new(common_params.merge(
:section => 'section2',
:setting => 'foo',
:value => 'yippee',
:key_val_separator => '+'))
}.to raise_error Puppet::Error, /must contain exactly one/
it "should modify an existing setting" do
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:section => 'section2',
:setting => 'foo',
:value => 'yippee',
:key_val_separator => '='))
provider = described_class.new(resource)
provider.exists?.should be true
provider.value.should == 'bar'
provider.value=('yippee')
validate_file(<<-EOS
[section2]
foo=yippee
EOS
)
end

it "should fail if the separator includes more than one equals sign" do
expect {
Puppet::Type::Ini_setting.new(common_params.merge(
:section => 'section2',
:setting => 'foo',
:value => 'yippee',
:key_val_separator => ' = foo = '))
}.to raise_error Puppet::Error, /must contain exactly one/
end
end

context "when overriding the separator to something other than =" do
let(:orig_content) {
<<-EOS
[section2]
foo: bar
EOS
}

it "should modify an existing setting" do
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:section => 'section2',
:setting => 'foo',
:value => 'yippee',
:key_val_separator => '='))
:key_val_separator => ': '))
provider = described_class.new(resource)
provider.exists?.should be true
provider.value.should == 'bar'
provider.value=('yippee')
validate_file(<<-EOS
[section2]
foo=yippee
foo: yippee
EOS
)
end
Expand All @@ -537,14 +544,14 @@ def self.file_path
:section => 'section2',
:setting => 'bar',
:value => 'baz',
:key_val_separator => '='))
:key_val_separator => ': '))
provider = described_class.new(resource)
provider.exists?.should be false
provider.create
validate_file(<<-EOS
[section2]
foo=bar
bar=baz
foo: bar
bar: baz
EOS
)
end
Expand Down

0 comments on commit 7a1ac31

Please sign in to comment.