Merge pull request #202 from puppetlabs/1.5.x

1.5.x
This commit is contained in:
Bryan Jen 2016-03-10 16:29:46 -07:00
commit 49c2e6038b
5 changed files with 16 additions and 221 deletions

View file

@ -1,7 +1,3 @@
fixtures:
repositories:
stdlib:
repo: 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
ref: '4.2.0'
symlinks:
inifile: "#{source_dir}"

View file

@ -1,3 +1,14 @@
## Supported Release 1.5.0
### Summary
This release adds the long-awaited `show_diff` parameter for diffing the complete file on changes (or can also just show the md5 sums).
### Features
- Added `show_diff` parameter to show diffs on changes.
- Remove empty ini sections when the last line in the section is removed.
### Bugfixes
- Workaround `create_ini_settings()` duplicate resources puppet bug PUP-4709
## Supported Release 1.4.3
###Summary

View file

@ -1,46 +0,0 @@
# == Class: inifile
#
# Use create_resources() to allow the specification of ini_setting and
# ini_subsetting entries.
#
class inifile (
$ini_settings = undef,
$ini_subsettings = undef,
$ini_settings_hiera_merge = true,
$ini_subsettings_hiera_merge = true,
) {
if is_string($ini_settings_hiera_merge) == true {
$ini_settings_hiera_merge_bool = str2bool($ini_settings_hiera_merge)
} else {
$ini_settings_hiera_merge_bool = $ini_settings_hiera_merge
}
validate_bool($ini_settings_hiera_merge_bool)
if is_string($ini_subsettings_hiera_merge) == true {
$ini_subsettings_hiera_merge_bool = str2bool($ini_subsettings_hiera_merge)
} else {
$ini_subsettings_hiera_merge_bool = $ini_subsettings_hiera_merge
}
validate_bool($ini_subsettings_hiera_merge_bool)
if $ini_settings != undef {
if $ini_settings_hiera_merge_bool == true {
$ini_settings_real = hiera_hash('inifile::ini_settings')
} else {
$ini_settings_real = $ini_settings
}
validate_hash($ini_settings_real)
create_resources('ini_setting',$ini_settings_real)
}
if $ini_subsettings != undef {
if $ini_subsettings_hiera_merge_bool == true {
$ini_subsettings_real = hiera_hash('inifile::ini_subsettings')
} else {
$ini_subsettings_real = $ini_subsettings
}
validate_hash($ini_subsettings_real)
create_resources('ini_subsetting',$ini_subsettings_real)
}
}

View file

@ -1,12 +1,15 @@
{
"name": "puppetlabs-inifile",
"version": "1.4.3",
"version": "1.5.0",
"author": "Puppet Labs",
"summary": "Resource types for managing settings in INI files",
"license": "Apache-2.0",
"source": "https://github.com/puppetlabs/puppetlabs-inifile",
"project_page": "https://github.com/puppetlabs/puppetlabs-inifile",
"issues_url": "https://tickets.puppetlabs.com/browse/MODULES",
"dependencies": [
],
"data_provider": null,
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
@ -93,14 +96,11 @@
"requirements": [
{
"name": "pe",
"version_requirement": ">= 3.0.0 < 2015.4.0"
"version_requirement": ">= 3.0.0"
},
{
"name": "puppet",
"version_requirement": ">= 3.0.0 < 5.0.0"
}
],
"dependencies": [
{"name":"puppetlabs/stdlib","version_requirement":">= 4.2.0"}
]
}

View file

@ -1,166 +0,0 @@
require 'spec_helper'
describe 'inifile' do
describe 'with default options' do
it { should compile.with_all_deps }
it { should contain_class('inifile') }
end
describe 'with parameter ini_settings_hiera_merge' do
context 'set to an invalid type (non-string and a non-boolean)' do
let(:params) { { :ini_settings_hiera_merge => ['invalid','type'] } }
it 'should fail' do
expect {
should contain_class('inifile')
}.to raise_error(Puppet::Error,/\["invalid", "type"\] is not a boolean./)
end
end
['true',true,'false',false].each do |value|
context "set to #{value}" do
let(:params) { { :ini_settings_hiera_merge => value } }
it { should contain_class('inifile') }
end
end
end
describe 'with parameter ini_settings' do
context 'set to an invalid type (non-hash)' do
let(:params) do
{
:ini_settings => ['invalid','type'],
:ini_settings_hiera_merge => false,
}
end
it 'should fail' do
expect {
should contain_class('inifile')
}.to raise_error(Puppet::Error,/\["invalid", "type"\] is not a Hash./)
end
end
context 'set to a valid hash' do
let(:params) { { :ini_settings_hiera_merge => false,
:ini_settings => {
'sample setting' => {
'ensure' => 'absent',
'path' => '/tmp/foo.ini',
'section' => 'foo',
'setting' => 'foosetting',
'value' => 'FOO!',
},
'colorize_git' => {
'ensure' => 'present',
'path' => '/root/.gitconfig',
'section' => 'color',
'setting' => 'ui',
'value' => 'auto',
}
} } }
it { should contain_class('inifile') }
it {
should contain_ini_setting('sample setting').with({
'ensure' => 'absent',
'path' => '/tmp/foo.ini',
'section' => 'foo',
'setting' => 'foosetting',
'value' => 'FOO!',
})
}
it {
should contain_ini_setting('colorize_git').with({
'ensure' => 'present',
'path' => '/root/.gitconfig',
'section' => 'color',
'setting' => 'ui',
'value' => 'auto',
})
}
end
end
describe 'with parameter ini_subsettings_hiera_merge' do
context 'set to an invalid type (non-string and a non-boolean)' do
let(:params) { { :ini_subsettings_hiera_merge => ['invalid','type'] } }
it 'should fail' do
expect {
should contain_class('inifile')
}.to raise_error(Puppet::Error,/\["invalid", "type"\] is not a boolean./)
end
end
['true',true,'false',false].each do |value|
context "set to #{value}" do
let(:params) { { :ini_subsettings_hiera_merge => value } }
it { should contain_class('inifile') }
end
end
end
describe 'with parameter ini_subsettings' do
context 'set to an invalid type (non-hash)' do
let(:params) do
{
:ini_subsettings => ['invalid','type'],
:ini_subsettings_hiera_merge => false,
}
end
it 'should fail' do
expect {
should contain_class('inifile')
}.to raise_error(Puppet::Error,/\["invalid", "type"\] is not a Hash./)
end
end
context 'set to a valid hash' do
let(:params) { { :ini_subsettings_hiera_merge => false,
:ini_subsettings => {
'sample setting' => {
'ensure' => 'absent',
'path' => '/tmp/foo.ini',
'section' => 'foo',
'setting' => 'foosetting',
'value' => 'FOO!',
},
'colorize_git' => {
'ensure' => 'present',
'path' => '/root/.gitconfig',
'section' => 'color',
'setting' => 'ui',
'value' => 'auto',
}
} } }
it { should contain_class('inifile') }
it {
should contain_ini_subsetting('sample setting').with({
'ensure' => 'absent',
'path' => '/tmp/foo.ini',
'section' => 'foo',
'setting' => 'foosetting',
'value' => 'FOO!',
})
}
it {
should contain_ini_subsetting('colorize_git').with({
'ensure' => 'present',
'path' => '/root/.gitconfig',
'section' => 'color',
'setting' => 'ui',
'value' => 'auto',
})
}
end
end
end