Commit graph

16 commits

Author SHA1 Message Date
Pete Johns
961447dfdf be_true and be_false are deprecated
Replace with `be true` and `be false` and make predicate return a
boolean.

> Methods that don't return a boolean, shouldn't end in a question mark.
-- https://github.com/bbatsov/ruby-style-guide#naming
2014-06-26 20:04:33 +10:00
Michal Růžička
560bbc622f Add quote_char parameter to the ini_subsetting resource type
The quote_char is used to quote the entire setting when it is modified
as a result of changes to some subsettings.

For an example let's assume we have a setting of this form:
  JAVA_ARGS=-Xmx256m
and we want to add the '-Xms' parameter to the setting, for that purpose
we define a resource like this:
  ini_subsetting { '-Xms':
    ensure     => present,
    path       => '/some/config/file',
    section    => '',
    setting    => 'JAVA_ARGS',
    subsetting => '-Xms'
    value      => '256m',
  }
which results into the following setting:
  JAVA_ARGS=-Xmx256m -Xms256m
But this is not what we intended - if this setting is read by the bash
shell the '-Xms256m' parameter is interpreted as a command to be
executed rather than a value to be assigned to the JAVA_ARGS variable.

To fix this problem the quote_char parameter was added to the
ini_subsetting resource type, and we'll take advantage of it to fix the
problem in the above example like so:
  ini_subsetting { '-Xms':
    ensure     => present,
    path       => '/some/config/file',
    section    => '',
    setting    => 'JAVA_ARGS',
    quote_char => '"',
    subsetting => '-Xms'
    value      => '256m',
  }
which will result into:
  JAVA_ARGS="-Xmx256m -Xms256m"
which is what we intended.
2014-05-07 17:04:43 +02:00
Richard Clamp
b0c8d5c34a allow for the namevar construction
The default type would always have a section as part of its namevar, but if
you're inheriting from ini_setting you may be modelling a flat file with no
sections.

This pushes the formation of the namevar from the section_name and setting into
a method, then demonstrates overriding it so that inherited_ini_setting can just
be

   inherited_ini_file { 'setting':
     value => '12',
   }

and continue to be purgable.
2013-07-16 10:18:15 +01:00
Richard Clamp
857496424c Fix the sample usage in the README
If you follow the example in the README you may not have implemented the
:key_value_separator parameter in your type, and you get the wonderful failure
case:

   Puppet::Error: Invalid parameter key_val_separator(:key_val_separator)

This change looks first, and if the user hasn't specified that attribute in
their type in their type, it falls back to '='
2013-07-16 10:18:15 +01:00
Chris Price
6c245ef674 Update Modulefile and Changelog, prepping for 0.10.0 release
This commit also adds some comments clarifying the new code
that was added to support purging.
2013-04-02 15:10:43 -07:00
Chris Price
e824ab2aba Merge pull request #29 from kbrezina/subsetting
Added 'ini_subsetting' custom resource type
2013-03-25 11:00:41 -07:00
Karel Brezina
4351d8b9c8 Added 'ini_subsetting' custom resource type 2013-03-25 11:34:37 +01:00
Dan Bode
2f22483c87 Add purging support to ini file
This commit adds purging to ini file native types.

Purging will only work for child providers that
implement the method: self.file_path. This is
because collecting all instances of the type (
which is a requirement for purging) is only possible
when the path of the file that is being managed
can be accessed by the class instance (in the
method self.instances.)

This commit adds the following method to the internal
of the ini_file:
- get_settings - has of all settings/values for
a given section

It also adds the following method to the section
class:
- setting_names - list of all setting names in a
section.

These methods are required for the instances method
to be able to list the values for all settings of
each section.
2013-03-04 15:38:58 -08:00
Dan Bode
1106d70e88 Add support for removing lines
This commit adds the ability to ensure that lines are absent.
2012-10-10 17:40:38 -07:00
Dan Bode
cbc90d3834 Make value a property
This commit converts value to a property so that it
can be managed and modified when a file already has
a value set.

It was previously treating the line creation state
the same as the update case, which is not in
alignment with Puppet's model.
2012-10-02 18:53:53 -07:00
Dan Bode
1564c473a9 Make ruby provider a better parent.
In order to allow the provider to be a parent for
other providers, I have implemented the following
methods: section, setting, file_path, separator so
that they can be overridden by child providers and
decouple this provider from its type.
2012-10-02 18:52:34 -07:00
Chris Price
8d1fdc5c29 Allow overriding separator string between key/val pairs
This introduces a new parameter, 'key_val_separator', which
can be set in order to override the string that is used
as a separator between the key/value pair of a setting line.
The default is ' = ', but you could set the param to '=' if
you don't want to include whitespace in your settings file.
2012-09-19 15:42:16 -07:00
Stephen
d2c1e07e80 Fixed regex to match sections and settings with non alphanumeric
characters. Fixed writing to file without any sections at all.
Fixed exists checking for variable type by always casting to string
and added all the tests for the above items.
2012-08-14 13:38:08 +01:00
Stephen
dde3a14ab0 fix path for require statement 2012-08-13 18:54:01 +01:00
Chris Price
9c76b6af12 First (basic) working version of ini_setting provider 2012-07-28 21:59:54 -07:00
Chris Price
91273a5a2b Started writing some tests, work has been punted 2012-06-14 11:42:49 -07:00