Remove inifile class, test, and dependency

PR #156 merged a base class called `inifile` that dynamically queried
hiera using explicit `hiera_hash()` functions and required functions
from stdlib.

It is an anti-pattern for component classes to contain hiera
functions (even ones that do not trigger under all circumstances) as
this leads to tight-coupling with hiera data structures. It also
promotes the anti-pattern of declaring resources directly in hiera.

Also, inifile is not going to receive a major version increase for a
while (we hope) and so adding a dependency is not desirable at this
point.

Unfortunately this feedback was missed while reviewing the original PR,
so it has to be reverted.
This commit is contained in:
Hunter Haugen 2016-03-07 11:33:32 -08:00
parent decebd45d1
commit 52bc6f8dfc
4 changed files with 0 additions and 217 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,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

@ -8,7 +8,6 @@
"project_page": "https://github.com/puppetlabs/puppetlabs-inifile",
"issues_url": "https://tickets.puppetlabs.com/browse/MODULES",
"dependencies": [
{"name":"puppetlabs/stdlib","version_requirement":">= 4.2.0 < 5.0.0"}
],
"data_provider": null,
"operatingsystem_support": [

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