Commit graph

101 commits

Author SHA1 Message Date
David Schmitt
77022c5050 Merge pull request #208 from dmitryilyin/master
Add insert_type and subsetting_key_val_separator
2016-07-21 18:25:13 +01:00
Helen Campbell
fff45971c8 Additional tests - multiple ini settings creation 2016-07-18 17:27:13 +01:00
Helen Campbell
752aa8e564 Revert "Remove brackets from ini_setting titles to workaround PUP-4709"
This reverts commit b425fe5a49.
2016-07-18 11:17:37 +01:00
Dmitry Ilyin
357ecf8e8e Add insert_type and subsetting_key_val_separator
* Insert_type and insert value can define where
  a new subsetting element will be placed.
* subsetting_key_val_separator allows you to have
  a separator character between a subsetting name
  and its value.
* Refactor ini_subsetting and its spec.
2016-07-01 13:49:10 +03:00
tphoney
23db839138 {maint} modulesync 0794b2c 2016-06-30 15:27:28 +01:00
David Schmitt
5013ba39b7 Update to newest modulesync_configs [9ca280f] 2016-04-18 20:15:09 +01:00
tphoney
a731ce92de (maint) fix test to run under strict variables 2016-04-08 13:54:05 +01:00
Hunter Haugen
072accdb1e (MODULES-3145) Cast values to strings before passing to provider
Puppet gets confused when false values get passed to the provider
because of
https://github.com/puppetlabs/puppet/blob/4.4.0/lib/puppet/property.rb#L247-L248
so lets just cast them all to strings; ini files are untyped anyway.
2016-03-17 15:39:58 -07:00
Hunter Haugen
52bc6f8dfc 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.
2016-03-07 11:33:32 -08:00
Hunter Haugen
f77ab45542 Fix acceptance test for removed section
The 199 PR updated ini_setting to remove empty sections after the last
value is removed. This fixes the acceptance test.
2016-03-01 16:23:06 -08:00
Hunter Haugen
2027a0b2ab Remove empty sections after last setting is removed
Empty sections hanging around are not useful, so if the last line in a
section is removed then remove the section. If the section still has
comments, then just leave it be.

This does not add the ability to remove sections that do not have
settings to begin with; only allows cleaning a file as puppet makes
changes to it.
2016-02-29 14:07:21 -08:00
David Schmitt
57bb3fe438 (FM-4046) Update to current msync configs [006831f]
This moves all copyright statements to the NOTICE file in accordance with the ASFs guidelines on applying the Apache-2.0 license.
2016-02-16 16:33:31 +00:00
Dominic Cleal
b425fe5a49 Remove brackets from ini_setting titles to workaround PUP-4709
Puppet 4.0 and 4.1 are affected by PUP-4709 which raises duplicate
resource errors when using create_ini_settings(), due to the inclusion
of square brackets in the resource titles.

    Error while evaluating a Function Call, Duplicate
    declaration: Ini_setting[[foo] bar] is already declared; cannot
    redeclare

Removing these from the function allows it to work on these Puppet
versions without error.
2016-02-09 08:06:57 +00:00
TP Honey
1635b84377 Merge pull request #152 from stepanstipl/feature-keep_secret2
Added keep_secret parameter feature
2016-02-02 14:12:17 +00:00
David Schmitt
2c76f60cf2 (FM-4049) Update to current msync configs [2c99161] 2016-01-27 14:34:40 +00:00
Stepan Stipl
af4b3f287a Acceptance tests for show_diff 2016-01-15 20:47:07 +00:00
Stepan Stipl
4853927093 Implemented show_diff parameter, with similar behaviour as show_diff on
type file

show_diff => true (default) prints diff to logs
show_diff => md5 prints only md5 hashes instead of actual values
show_diff => false redacts any information about values

Global show_diff config takes priotiry over this one.
2016-01-15 20:47:07 +00:00
Garrett Honeycutt
d83f3011f9 Add ability to specify a hash of ini_settings and ini_subsettings.
This added functionality allows you to specify hashes for ini_setting
and ini_subsetting so that they might be stored in Hiera. Without this
patch, you need to use ini_setting and ini_subsetting resources strictly
in code whereas with this patch, you could describe this in Hiera.
2016-01-06 12:27:21 -05:00
David Danzilio
a94f51e68d Adding path to create_ini_settings resources
Currently the create_ini_settings function creates an ini_setting with a
title comprised of the section and setting names. This means that we
run into resource conflicts when defining the same section/setting
combinations but in different files. Since the path parameter is
required, we can safely add this to the title of the ini_setting
resource created by the create_ini_settings function. This commit does
just that.
2015-08-12 18:00:57 -04:00
Gary Larizza
d452e6ca1e Support a space as a key_val_separator
Previously, trying to use a space as a key_val_separator in the ini_setting
type would fail because #strip is being called on the key_val_separator
attribute, which completely kills the space. This commit checks to see
if key_val_separator has been set as a space, and, if so, sets the `k_v_s`
variable in the library to be ' ' instead of ''.  This in turn allows the
provider to check for existing values (instead of inserting the value every
time Puppet is run).
2015-08-06 13:56:16 -07:00
Morgan Haskel
2ab47100c7 MODULES-2212 - Add use_exact_match parameter for subsettings
There's no way to distinguish between a subsetting with a value and a
subsetting with no value, so add a parameter to allow that to be
specified.
2015-07-31 16:11:27 -07:00
Mike Dorman
c784253096 MODULES-1599 Match only on space and tab whitespace after k/v separator
The previous match for \s would also match on newlines.  This caused
existing settings with blank values to have the newline considered part
of the whitespace surrounding the separator.  When such settings are
set with a value, the value ends up on the next line.

Also adding acceptance test for this particular situation.
2015-06-18 15:06:44 -06:00
Hunter Haugen
3c92a35df5 Correct the name of the require 2015-06-11 16:49:46 -07:00
Hunter Haugen
6acf750d62 Add helper to install puppet/pe/puppet-agent 2015-06-11 15:31:27 -07:00
Justin Stoller
9a7c0f38dc (maint) allow setting PUPPET_VERSION in acceptance 2015-06-08 22:15:08 -07:00
Hunter Haugen
c72bfbb9b1 Merge pull request #129 from duritong/create_ini_settings
introduce create_ini_settings
2015-05-27 13:15:33 -07:00
WhatsARanjit
b0fb47d4ec Added ability to specify section_prefix and section_suffix to accomodate files with sections that don't follow [section_name] format. AIX for example uses section_name: format. 2015-04-15 03:56:08 -04:00
Bryan Jen
69bee205c4 Adds acceptance testing for setting names containing white space in the middle 2015-03-31 15:28:42 -07:00
Michael Siroskey
a747f6656f Fixed SETTING_REGEX and COMMENTED_SETTING_REGEX to allow spaces in setting names. 2015-03-31 14:27:45 -07:00
duritong
9f03e8a3d1 remove dead code
found some dead code to remove
2015-03-23 22:29:22 +01:00
Travis Fields
4dfb8e1089 Force acceptance test ordering with require and before 2015-02-09 16:07:47 -08:00
Travis Fields
8e2689bdbb Fixes issues due to serverspec upgrade and usage of obsolete should contain method for files 2015-02-09 13:16:55 -08:00
mh
6eb8f9ca98 introduce create_ini_settings
create_ini_settings is a function that allows you to create
ini_setting resources from a simple hash:

    $settings = {  section1 => {
        setting1 => val1
      },
      section2 => {
        setting2 => val2,
        setting3 => {
          ensure => absent
        }
      }
    }
    $defaults = {
      path => '/tmp/foo.ini'
    }
    create_ini_settings($settings,$defaults)

Will create the following resources

    ini_setting{'[section1] setting1':
      ensure  => present,
      section => 'section1',
      setting => 'setting1',
      value   => 'val1',
      path    => '/tmp/foo.ini',
    }
    ini_setting{'[section2] setting2':
      ensure  => present,
      section => 'section2',
      setting => 'setting2',
      value   => 'val2',
      path    => '/tmp/foo.ini',
    }
    ini_setting{'[section2] setting3':
      ensure  => absent,
      section => 'section2',
      setting => 'setting3',
      path    => '/tmp/foo.ini',
    }

This allows one to create much easier classes
that should be able to manage an arbritary set of
ini-style settings without having to specify each
one of them.
2015-01-28 22:09:34 +01:00
Morgan Haskel
be5fc47f00 Merge pull request #141 from petems/dry_up_spec_test
Replace code with pre-existing shared_example
2015-01-15 08:49:00 -08:00
Jonathan Tripathy
a21dd813b2 Removed pending unit tests.
This functionality does not exist and thus was cluttering the output.
2015-01-13 17:02:10 -08:00
Peter Souter
9280f81be5 Replace code with pre-existing shared_example
Noticed this when I was testing the module out with a FreeBSD host this code duplicates the shared_example used in the rest of the spec, so I DRY'd it up! 👍
2015-01-11 19:45:27 -08:00
Morgan Haskel
15f972d092 Rebase/fix the flexible k/v separator. 2014-12-18 10:45:30 -08:00
Pete Johns
c4fa6a614a Fix spec: predicates return booleans 2014-12-18 10:22:20 -08:00
Igor Galić
3288d415e9 WIP: Allow changing key value separator beyond indentation
We have many ini-style configuration files which use : as key value
separator. We'd like to be able to manage them with ini_setting as well.
This here is a naïve first attempt in that direction.

Please note that despite the fact that this *should* match, it's failing
unit tests.. This is a work in progress.
2014-12-18 10:22:20 -08:00
Pete Johns
3e46c13dc2 Fix Ruby 1.9.3 build 2014-11-08 18:52:20 +11:00
Pete Johns
efeb174427 Add spec for #123
I may have made this configuration file up
2014-11-08 18:47:08 +11:00
Pete Johns
d98e9bcb77 Add failing spec for KDE Configuration with braces in setting names
Refer https://github.com/puppetlabs/puppetlabs-inifile/pull/131
2014-11-08 17:05:59 +11:00
Huan Do
f343c41cd8 modify test to compare to a hash which better tests the state of each setting
also update @@COMMENTED_SETTING_REGEX to be roughly equal to "(\s*)[#;]+" + @@SETTING_REGEX
2014-09-12 16:55:24 -07:00
Huan Do
681f5c0cb4 fix issue where single characters settings were not being saved.
see https://github.com/boxen/puppet-git/issues/30
2014-09-08 23:12:09 -07:00
Morgan Haskel
7f54eb1279 Update spec_helper for consistency. 2014-08-28 12:39:44 -04:00
Hunter Haugen
09b574ea1d Merge pull request #115 from johnsyweb/handle-quotation-marks-in-section-names
Handle quotation marks in section names
2014-07-07 14:49:22 -07:00
Hunter Haugen
07c4827f53 Merge remote-tracking branch 'puppetlabs/master' into temp
Conflicts:
	Gemfile
2014-07-07 14:23:33 -07:00
Pete Johns
b3fed85b57 Spec for MODULES-1194
Ini_file module does not recognize section names with forward slashes in them

https://tickets.puppetlabs.com/browse/MODULES-1194
2014-07-04 14:31:39 +10:00
Pete Johns
069aa56d5c Merge remote-tracking branch 'origin/master' into handle-quotation-marks-in-section-names 2014-07-04 14:11:04 +10:00
Pete Johns
bd99244353 Test allowing $ signs in section names
Verifying that this PR addresses https://github.com/puppetlabs/puppetlabs-inifile/pull/98
2014-06-28 13:22:01 +10:00