Commit graph

292 commits

Author SHA1 Message Date
Adrien Thebo
d60d872c1a Merge branch 'pull-180'
This closes GH-180
2013-09-18 21:56:16 -07:00
Adrien Thebo
63811b9d59 (maint) Simplify validate_cmd specs 2013-09-18 21:48:45 -07:00
sgzijl
9e0d8a8e0a (#22214): close content file before executing checkscript
Right now validation seems to be done against zero byte generated temp
files. We need to close the file before executing validation against it.
2013-09-18 21:32:07 -07:00
Adrien Thebo
7ccf8cf09b Merge pull request #184 from lmello/fix_bug_20681_delete_undef_values
delete_undef_values function fix bug #20681
2013-09-18 10:08:49 -07:00
Leonardo Rodrigues de Mello
80a8b7bd1f (#20681) fix behaviour of delete_undef_values
The issue #20681 describe the error of delete() function
removing the elements from the origin array/hash/string.

This issue affected other delete functions. Because
ruby delete and delete_if functions make destructive
changes to the origin array/hash.

The delete_undef_values removed elements from the
origin array/hash and this is not the desired behaviour.

To solve this, we should dup or clone the array/hash
before using the delete or delete_if ruby functions.

We should also check if args[0] is not nil before using
dup, since dup on nil raises exception.

This fix the problem and add unit tests, so we could
enforce this behaviour and prevent regressions.
2013-09-18 11:19:52 -03:00
Adrien Thebo
c2f584d2c2 Merge pull request #183 from lmello/fix_bug_20681_delete_at
delete_at added spec to check against bug #20681
2013-09-17 11:39:29 -07:00
Adrien Thebo
1011670bad Merge pull request #182 from lmello/fix_bug_20681_delete_values
delete_values() fix bug #20681.
2013-09-17 11:35:57 -07:00
Adrien Thebo
f7f70fe9ee Merge pull request #185 from lmello/refactor_16498
(#16498) Added unit test for loadyaml function.
2013-09-17 11:33:57 -07:00
Leonardo Rodrigues de Mello
bcd84f5c3d (#16498) Added unit test for loadyaml function.
As stated on the issue #16498, it would be great to have unit tests
for all the functions.

Function loadyaml was missing a unit test. This commit added the
unit test to loadyaml function.
2013-09-17 15:16:25 -03:00
Adrien Thebo
5cc5e293cf Merge pull request #178 from lmello/fix_bug_20681
bug # 20681 delete() function should not remove elements from original list
2013-09-17 11:07:21 -07:00
Leonardo Rodrigues de Mello
b43c044581 (#20681) delete_at function unit test against issue
The issue #20681 describe the error of delete() function
removing the elements from the origin array/hash/string.

This issue affected the other delete functions.

The delete_at function is not afected by this bug, but
it did not had the unit test to check against it.

I had added the unit test so we could prevent regressions
on the future and also have better test coverage.
2013-09-17 12:09:50 -03:00
Leonardo Rodrigues de Mello
51d96088c1 (#20681) fix behaviour of delete_values
The issue #20681 describe the error of delete() function
removing the elements from the origin array/hash/string.

This issue affected other delete functions. Because
ruby delete and delete_if functions make destructive
changes to the origin array/hash.

The delete_undef_values removed elements from the
origin hash and this is not the desired behaviour.

To solve this, we should dup or clone the hash
before using the delete or delete_if ruby functions.

This fix the problem and add unit tests, so we could
enforce this behaviour and prevent regressions.
2013-09-17 12:05:23 -03:00
Adrien Thebo
ebec9de534 Merge pull request #179 from lmello/function_pick_error_msg
enhanced the error message of pick function.
2013-09-16 13:45:24 -07:00
Leonardo Rodrigues de Mello
c14cbf31e2 bug # 20681 delete() function should not remove elements from original list
The setup: list with 3 elements, delete one:
$test_list = [‘a’, ‘b’, ‘c’]
$test_deleted = delete($test_list, ‘a’)

Print out the elements in ‘test_deleted’:
notify { ‘group_output2’:  withpath => true, name     => “$cfeng::test_deleted”, }
Notice: /Stage[main]/Syslog/Notify[group_output2]/message: bc

Good!  Run-on output shows that ‘a’ was deleted

Print out the elements in ‘test_list’:
notify { ‘group_output1’: withpath => true, name     => “$cfeng::test_list”, }
Notice: /Stage[main]/Syslog/Notify[group_output1]/message: bc

WHAT!?  'a' was deleted from ‘test_list’ as well! Expected abc as output!

This behaviour is confirmed for string, hash and array.
This is fixed on this commit, I had  added two spec tests to cover that cases.

bug #20681 spec test for delete() function.

I had forgot in the last commit the spec test for hash in the
delete function.

bug # 20681 delete() function change aproach.

Instead of rejecting elements from the original list, we use
collection = arguments[0].dup .
then latter we could continue to use delete and gsub! on collection
without impact on original argument.

this is a better solution than the previous one, and works on ruby
1.8.7, 1.9.3 and 2.0.0.

The previous solution does not work on ruby 1.8.7.

delete function remove typo whitespace.

fix typo whitespaces.
2013-09-16 10:19:35 -03:00
Leonardo Rodrigues de Mello
30e994fb6e enhanced the error message of pick function.
When pick function fail return a better error message like
the other stdlib functions, indicating that the error
is on function pick.

This would help people that see the error to identity it is
related to a incorrect use of stdlib function pick, instead of having
to grep all puppet libraries and manifests source for the old message.

I had also changed the spec test.

pick function change spec  as suggested GH-179

Fix the spec test to use expect {}.to instead of lambda {}.should
as explained by Adrienthebo.

"Using expect { }.to is preferred over lambda { }.should.
 In addition it's best practice to do a string match against the
error message to ensure that we're catching the right error,
instead of any error of the right type."

Also fixed a typo on the error message, it was missing one space.

pick function stylish fix as suggested on GH179
2013-09-16 10:03:20 -03:00
Jeff McCune
948be0bb99 (maint) Improve the tests and readability of file_line
Without this patch the implementation of the file_line provider is a bit
convoluted with respect to the newly introduced "after" parameter.

This patch addresses the problem by separating out the concerns of each
case into their own methods of handling the behavior with the match
parameter, handling the behavior with the after parameter, or simply
appending the line.
2013-08-29 16:27:27 -07:00
Dan Prince
221277e852 Update file_line resource to support 'after'.
When adding new lines to a file the 'after' option can be useful
when you need to insert file lines into the middle of a file.

This is particularly helpful when using file_line with sectioned
config files.

NOTE: the after option only works when adding new lines. If you are
updating an existing (matched) line it will simply modify it in place.
This assumes it was in the right place to begin with.
2013-08-29 15:07:29 -07:00
Jeff McCune
806430224a (maint) Fix failing spec test with Puppet 3.3.0-rc2
Without this patch the stdlib spec tests are failing against recent
versions of Puppet.  The root cause of this problem is a change in the
behavior of create_resources in Puppet 6baa57b.  The change in behavior
caused the :name key to be omitted from the hash returned by
Puppet::Parser::Resource#to_hash which in turn is causing the test
failure.

This patch addresses the problem by updating the test to match the
description of the example.  Only the attribute :ensure is checked
instead of the full hash itself.
2013-08-29 13:02:31 -07:00
Adrien Thebo
6dd6d060df Merge pull request #172 from ptomulik/fix/delete_xxx_spec
small fix to delete_values_spec.rb and README.markdown
2013-08-28 15:39:32 -07:00
Paweł Tomulik
bb9f7d1726 small fix to delete_values_spec.rb and README.markdown 2013-08-14 02:23:36 +02:00
Adrien Thebo
200e585ea7 (maint) refactor validate_slength tests 2013-08-12 12:55:46 -07:00
Adrien Thebo
0a02295c42 Merge pull request #167 from mhellmic/minlength
extend the validate_slength function to accept a minimum length
2013-08-06 09:48:44 -07:00
Martin Hellmich
0206d367c0 changed the validate_slength function to accept a min length
An optional third parameter can be given a min length. The function
then only passes successfully, if all strings are in the range
min_length <= string <= max_length

update and fix function and unit tests

the check for the minlength has to be written differently
because 0 values should be possible. We now check
a) if the input is convertible, and throw a ParseError and
b) if the input .is_a?(Numeric) and ask for a positive number
it's not as clean as for maxlength, but keeps a similar behaviour

refined the error checking for the min length

try to convert to Integer(args[2]) and fail,
if it's not possible

changed the tests accordingly to the new parameter checking
2013-08-06 10:05:16 +02:00
Paweł Tomulik
2069415204 added delete_values() and delete_undef_values() functions 2013-08-05 22:12:26 +02:00
Tomas Doran
b2e23dc65b Adjust to use default URI.escape escape list
Conform to RFC per comments on: https://github.com/puppetlabs/puppetlabs-stdlib/pull/164

Conflicts:
	lib/puppet/parser/functions/uriescape.rb
	spec/unit/puppet/parser/functions/uriescape_spec.rb
2013-07-22 13:12:28 -07:00
Alex O'Rielly
964a9ad619 (#21416) Allow file_line to match multiple lines
Without this commit the file_line type will outright fail if multiple
lines match the given regex. This commit allows the file_line type and
provider to optionally match and modify all matching lines.

Changeset rebased into a single commit by Adrien Thebo <adrien@puppetlabs.com>
2013-07-11 16:25:56 -07:00
Adrien Thebo
ca7633c0e4 Merge pull request #158 from wfarr/validate_ip
[#20862] Add functions to validate ipv4 and ipv6 addresses
2013-06-07 15:06:41 -07:00
Adrien Thebo
77768e5d8d (maint) Remove syntax decoration from range_spec 2013-05-28 11:17:00 -07:00
Adrien Thebo
65380bcdfb (maint) Clean up range_spec error expectation
Replace `lambda` with `expect` for making an error expectation

Add an explicit error message in expectation
2013-05-28 11:14:28 -07:00
Adrien Thebo
dd0a4220d5 (maint) Use present tense in range_spec messages 2013-05-28 11:13:20 -07:00
Adrien Thebo
1fcb854f15 (maint) split up range spec with describe blocks 2013-05-28 11:11:50 -07:00
Adrien Thebo
0f2d69fdfd Merge remote-tracking branch 'pr/56' into pull-56
Conflicts:
	lib/puppet/parser/functions/range.rb
	spec/unit/puppet/parser/functions/range_spec.rb
2013-05-28 11:07:41 -07:00
fiddyspence
3707c47dcd Adding base64 function
Adding base64 function and spec test.  Included a bonus fix to
validate_slength_spec.rb to put the expectation message in the right
place.
2013-05-24 16:33:24 +01:00
Will Farrington
e0fd7299f6 Don't run certain tests under 1.8.7 2013-05-22 17:43:37 -07:00
Will Farrington
5d5796a7d5 Update ipv6 examples 2013-05-22 17:37:08 -07:00
Will Farrington
cf37a128a0 Add functions to validate ipv4 and ipv6 addresses 2013-05-22 17:10:45 -07:00
Hailee Kenney
a2abfb9894 Merge pull request #155 from AlexCline/feature/master/array_comparison_functions
(#20684) Add array comparison functions, difference, intersection and union
2013-05-15 13:56:15 -07:00
Adrien Thebo
dad3a2948f Merge pull request #147 from mhellmic/master
don't fail on undef variable in merge
2013-05-15 10:58:04 -07:00
Alex Cline
737aa31546 (#20684) Add array comparison functions, difference, intersection and union.
Included is code, tests and documentation for the difference, intersection
and union functions for comparing arrays.
2013-05-13 12:14:15 -04:00
Martin Hellmich
b975bd66aa Added rspec tests for the new behaviour of merge accepting empty strings
added test that '' is accepted
changed a test that a number is correctly rejected with a type error
2013-05-08 18:24:46 +02:00
Jeff McCune
226c191e27 Merge branch 'fix_facts_dot_d_with_pe'
* fix_facts_dot_d_with_pe:
  (maint) Indent facter_dot_d with 2 spaces
  (#20582) Restore facter_dot_d to stdlib for PE users
  Revert "Revert "Revert "Merge branch 'hkenney-ticket/master/2157_remove_facts_dot_d'"""
  (maint) Update Gemfile with GEM_FACTER_VERSION

closes #153
2013-05-07 12:10:06 -07:00
Jeff McCune
3b887c880c (#20582) Restore facter_dot_d to stdlib for PE users
Without this patch Puppet Enterprise users who install the most recent
version of stdlib lose the ability to resolve certain facts critical to
the operation of Puppet Enterprise.  These facts are defined externally
in the file
`/etc/puppetlabs/facter/facts.d/puppet_enterprise_installer.txt`.
As an example, Puppet Enterprise catalogs fail to compile if the
`fact_stomp_server`, and `fact_stomp_port` facts are not defined.

`facter_dot_d` was removed from stdlib version 4 because Facter version
1.7 now supports external facts defined in
`/etc/puppetlabs/facter/facts.d/puppet_enterprise_installer.txt`.
Puppet Enterprise does not yet include Facter 1.7, however.  The most
recent PE release, 2.8.1, includes Facter 1.6.17.  With this version of
Facter, users who replace the version of stdlib that ships with PE with
the most recent version from the Forge will lose the ability to resolve
facts from
`/etc/puppetlabs/facter/facts.d/puppet_enterprise_installer.txt`.

This patch addresses the problem by detecting if Facter version < 1.7 is
loaded.  If so, then the facter_dot_d.rb facts will be defined using the
stdlib custom fact.  If Facter >= 1.7 is being used then stdlib will not
define external facts.
2013-05-07 09:42:35 -07:00
Alex Cline
b33cc24a3c Refactor ensure_resource expectations
This splits out the ensure_resource expectations into separate
blocks for clarity.  Per adrienthebo's recommendation.
2013-05-06 15:30:35 -04:00
Alex Cline
e08734af5a (#20548) Allow an array of resource titles to be passed into the ensure_resource function
This patch allows an array of resource titles to be passed into
the ensure_resource function.  Each item in the array will be
checked for existence and will be created if it doesn't already
exist.
2013-05-03 15:47:27 -04:00
Raphaël Pinson
2ba9e4721b Add a dirname function 2013-05-02 15:17:35 +02:00
Jeff McCune
d2e692dce3 Add behavior example for anchor refresh propagation
Without this patch we don't have a spec test to make sure the anchor
resource type passes notify events along.  This patch addresses the
problem by using RSpec Puppet to build a catalog, apply the catalog,
then pull a resource out of the transaction and make sure the resource
was triggered.
2013-04-11 17:55:40 -07:00
Jeff McCune
435226abfd (maint) Add the behavior for count() with arrays and hashes
Without this patch the expected behavior of the count() function when
dealing with an out of bound array index and with a hash key that does
not exist is implicitly encoded in the spec examples.  This is a problem
because the expected behavior is not clear for something similar to the
following example:

    node default {
      $ary = [ 1, 2, 3 ]
      $ary_undef = $ary[100]
      $hsh = { 'one' => 1 }
      $hsh_undef = $hsh['dne']
      $count = count(['hi', $ary_undef, $hsh_undef])
      notice "Count is ${count}"
    }

This patch addresses the problem by making the expected behavior
explicit in the examples.
2013-04-10 14:33:10 -07:00
Erik Dalén
f28550e789 Add a count function
Similar to the ruby count method on arrays.
2013-04-10 14:39:25 +02:00
Amos Shapira
7a2fb80834 (#19998) Implement any2array
This change is to implement a new function "any2array", which will take any
argument or arguments and create an array which contains it. If the argument
is a single array then it will be returned as-is. If the argument is a single
hash then it will be converted into an array. Otherwise (if there are more than
one argument, or the only argument is not an array or a hash) the function will
return an array containing all the arguments.
2013-04-03 14:05:20 -07:00
Steve Huff
c372f17770 Cleanup per adrianthebo suggestions
* use Float() to process string arguments
* get rid of doubly nested arrays
* removing needless ternary operator
* improving error message handling
2013-04-01 11:44:09 -04:00
Steve Huff
8d217f0012 (19864) num2bool match fix
This is a bit more heavy-handed than I might like, but it does appear to
do the right things:

* accepts numeric input appropriately, truncating floats
* matches string input against a regex, then coerces number-looking
  strings to int
* makes a best effort to coerce anything else to a string, then subjects
  it to the same treatment
* raises an error in the event of incorrect number of arguments or
  non-number-looking strings

I've also included some additional unit tests.
2013-03-29 15:06:36 -04:00
Steve Huff
4a5218a8af Reworked number-handling logic
No more coercing to String and regex matching.  Instead, we now coerce
to Integer at the beginning or raise an error if we cannot coerce to
Integer.

A consequence of this change is that the function will now accept
blatantly non-numeric strings as input, and return false.  This seems a
bit goofy to me, but it's how String#to_i works.  If we really don't
like this, then I'm open to suggestions.
2013-03-29 12:54:37 -04:00
Steve Huff
e6916f83fd Enable num2bool to accept numeric input
Also ignore rspec fixtures directory
2013-03-29 12:53:56 -04:00
Adrien Thebo
4078a6ff44 Merge branch '4.x' 2013-03-27 14:04:19 -07:00
Adrien Thebo
87c0f0c454 Merge branch '2.x' into 3.x 2013-03-27 14:04:00 -07:00
Erik Dalén
ff5dd5d75a Allow comparisons of Numeric and number as String
Puppet passes numbers as String to functions, but it makes more sense to
compare them as Numeric.
But sometimes Puppet passes them as the wrong type, see:
https://projects.puppetlabs.com/issues/19812
2013-03-27 14:03:31 -07:00
Richard Soderberg
88a93ac6cd add suffix function to accompany the prefix function 2013-03-26 15:46:55 -07:00
Kristof Willaert
05273419e1 Add floor function implementation and unit tests 2013-03-19 10:00:57 +01:00
Eric Shamow
961dcab15d (#13610) Add is_function_available to stdlib
This function provides a simple wrapper around
Puppet::Parser::Functions.function for access within Puppet manifests.
This will allow users to check whether or not a plugin or functionality
such as hiera is installed on the server.
2013-03-18 15:44:50 -07:00
Adrien Thebo
6dfd7f6b73 Merge branch '4.x' 2013-03-18 15:38:14 -07:00
Adrien Thebo
c0a0682706 Merge branch '2.x' into 3.x 2013-03-18 15:37:56 -07:00
Justin Lambert
5d5a4d466e str2bool should return a boolean if called with a boolean 2013-03-18 15:37:36 -07:00
Uwe Stuehler
5a11279cc5 Fix number of arguments check in flatten()
The function only uses the first argument, so raise an error with
too few arguments *and* with too many arguments.
2013-03-18 15:07:13 -07:00
Adrien Thebo
c12d3d7d51 Merge branch '2.x' into 3.x 2013-03-18 15:06:07 -07:00
Uwe Stuehler
e80207bede Fix number of arguments check in flatten()
The function only uses the first argument, so raise an error with
too few arguments *and* with too many arguments.
2013-03-18 15:04:50 -07:00
Jeff McCune
a45d4f1307 Revert "Merge pull request #130 from jhoblitt/has_element"
This reverts commit f7a18189ec, reversing
changes made to 36a7b29630.

I'm reverting this change because of concerns raised by Peter Meier that
it duplicates the "in" operator in the DSL.  The "in" operator is new
information that I did not posses when I made the decision to merge.
Because of this new information I'm un-merging and continuing the
discussion in the comments of
https://projects.puppetlabs.com/issues/19272

Reference: GH-130
2013-02-15 11:57:42 -08:00
Joshua Hoblitt
95cf3fed68 (#19272) Add has_element() function
It is exceptionally difficult to determine if an array contains an element matching a specific value without an iteration or loop construct.

This function is the Puppet equivalent of Array.includes?(foo) in Ruby.  The implementation is a verbatim copy of has_key() with the minor modifications needed to support arrays instead of hashes.
2013-02-14 12:06:21 -07:00
Adrien Thebo
36a7b29630 Merge branch 'pull-126' 2013-02-12 10:20:22 -08:00
fatmcgav
3cef5d9e33 (#19201) Add concat function to join two arrays
Without this patch applied there is no easy way to append one array to
another.  This is a problem because it is often desirable to join two
arrays without flattening the contents into a single, one dimensional
array.

This patch addresses the problem by adding a `concat()` function which
takes two arguments.  The arguments will be concatenated together and a
new array returned to the caller.

Reviewed-by: Jeff McCune <jeff@puppetlabs.com>
2013-02-12 10:00:09 -08:00
Raphaël Pinson
683ac8f8aa validate_cmd: Use Puppet::Util.execute 2013-02-06 18:03:11 +01:00
stephen
5f22933e75 ammend .should raise_error to .to raise_error 2013-02-06 08:12:42 -08:00
Raphaël Pinson
3a97c2314c Add validate_augeas function 2013-01-18 22:02:13 +01:00
Raphaël Pinson
6902cc582e Add validate_cmd function 2013-01-18 09:06:02 -08:00
Jaka Hudoklin
20e0e07090 Add getparam function to get defined resource parameters
As far as i know there's no other puppet-dsl-like way to get parameter of
defined resource, so that's why i implemented getparam function, which takes
resource reference and parameter name and returns parameter value.

    Here's another example why this function is really useful:

    define config($path, $config_param1, $config_param2) { }

    define example_resource($config) {
        $path = getparam($config, "path")

        notice("Path is $path")
    }

    define example_resource2($example_resource, $config = getparam($example_resource, "config")) {
        $config_param1 = getparam($config, "config_param1")

        notice("Config parameter is $config_param1")
    }

    define example_resource3($example_resource, $config = getparam($example_resource, "config")) {
        $config_param2 = getparam($config, "config_param2")

        notice("Config parameter is $config_param2")
    }

    class test_getparam {

        config { "config_instance":
            path => "/some/config/path",
            config_param1 => "someconfigtext1",
            config_param2 => "someconfigtext2",
        }

        example_resource { "example_resource_instance":
            config => Config["config_instance"]
        }

        example_resource2 { "example_resource_instance":
            example_resource => Example_resource["example_resource_instance"]
        }

        example_resource3 { "example_resource_instance":
            example_resource => Example_resource2["example_resource_instance"]
        }
    }

    class { "test_getparam": }
2013-01-09 17:51:12 -08:00
Jeff McCune
388cfa547d Merge branch '4.x'
* 4.x:
  Add test/validation for is_float if created from an arithmetical operation
  Add test/validation for is_integer if created from an arithmetical operation
  Add test/validation for is_numeric if created from an arithmetical operation
2013-01-03 13:39:42 -08:00
stephen
a773281760 Add test/validation for is_float if created from an arithmetical operation 2013-01-03 13:37:55 -08:00
stephen
b86f5dc129 Add test/validation for is_integer if created from an arithmetical operation 2013-01-03 13:37:55 -08:00
stephen
190b9438c5 Add test/validation for is_numeric if created from an arithmetical operation 2013-01-03 13:37:55 -08:00
Jeff McCune
bdef98d632 Merge branch '4.x'
* 4.x:
  Add reject() function
2012-11-28 14:29:39 -08:00
Jeff McCune
16fe71867c Merge branch '2.x' into 3.x
* 2.x:
  Add reject() function
2012-11-28 14:29:14 -08:00
Peter Meier
a79b2cdf43 Add reject() function
Like the grep function, but we can now reject members of an array
based on a pattern.
2012-11-28 14:28:31 -08:00
Jeff McCune
4f91efa56e Merge branch '4.x'
* 4.x:
  (Maint) Add spec/functions to rake test task
  Add example behaviors for ensure_packages() function
  Add an ensure_packages function.
2012-11-27 16:22:26 -08:00
Jeff McCune
aa1e743e38 Merge branch '2.x' into 3.x
* 2.x:
  (Maint) Add spec/functions to rake test task
  Add example behaviors for ensure_packages() function
  Add an ensure_packages function.

Conflicts:
	Rakefile
2012-11-27 16:22:11 -08:00
Jeff McCune
616b4521f4 Add example behaviors for ensure_packages() function
Without this patch the ensure_packages() function has no rspec behavior
examples.  This patch fixes the problem by filling out a spec file with
expected behaviors I could think of.
2012-11-27 16:16:28 -08:00
Jeff McCune
e590e1b00e Merge branch '4.x'
* 4.x:
  (#17797) min() and max() functions
2012-11-26 16:34:23 -08:00
Jeff McCune
276abac257 Merge branch '2.x' into 3.x
* 2.x:
  (#17797) min() and max() functions
2012-11-26 16:34:04 -08:00
Erik Dalén
9954133844 (#17797) min() and max() functions
returns the min or max of all arguments given to them
2012-11-26 16:33:44 -08:00
Jeff McCune
06952967bf Merge branch '4.x'
* 4.x:
  (#14670) Fixup file_line autorequire specs
  (#14670) autorequire a file_line resource's path
2012-11-26 11:41:34 -08:00
Jeff McCune
0648148bfb Merge branch '2.x' into 3.x
* 2.x:
  (#14670) Fixup file_line autorequire specs
  (#14670) autorequire a file_line resource's path
2012-11-26 11:41:01 -08:00
Jeff McCune
d8cde95295 (#14670) Fixup file_line autorequire specs
Without this patch applied the file_line autorequire examples are
failing.  This is a problem because the failures are false positives and
should be passing given the implementation.

This patch fixes the problem by changing the examples to directly test
the existence of the relationship by finding it in the list of
autorequire relationships.
2012-11-26 11:37:08 -08:00
Peter Meier
dfcee63afb (#14670) autorequire a file_line resource's path
If we manage a file we edit with file_line, it should be autorequired by
file_line.  Without this patch applied the relationship is not
automatically setup and the user is forced to manually manage the
relationship.
2012-11-26 10:35:18 -08:00
Jeff McCune
32419e77ed Merge branch '4.x'
* 4.x:
  Add join_keys_to_values function
2012-11-20 16:17:08 -05:00
Jeff McCune
ad262b56a4 Merge branch '2.x' into 3.x
* 2.x:
  Add join_keys_to_values function
2012-11-20 16:16:50 -05:00
Joshua Harlan Lifton
ee0f2b307d Add join_keys_to_values function
This commit adds a function that joins each of a hash's keys with that
key's corresponding value, separated by a separator string. The
arguments are a hash and separator string. The return value is an
array of joined key/value pairs.
2012-11-20 16:16:03 -05:00
Jeff McCune
326a13908b Merge branch 'jfryman-master'
* jfryman-master:
  puppet-lint cleanup
2012-11-19 11:23:50 -05:00
Jeff McCune
824ea6d49f Merge branch '2.x' into 3.x
* 2.x:
  Extend delete function for strings and hashes
  Fixed typo
2012-11-19 08:45:31 -05:00
Joshua Harlan Lifton
7322e4dc2f Extend delete function for strings and hashes
Previous to this commit, the delete function only acted on
arrays. This commit adds the same functionality for hashes and strings
in the obvious way: delete(h, k) would delete the k key from the h
hash and delete(s, sub) would delete all instances of the sub
substring from the s string.
2012-11-19 08:44:44 -05:00
James Fryman
88acc52393 puppet-lint cleanup 2012-11-15 10:38:03 -06:00
Jeff McCune
5353cd77b7 Merge branch '2.x' into 3.x
* 2.x:
  Add the pick() function
2012-11-15 08:57:21 -05:00
Gary Larizza
ba6dd13990 Add the pick() function
This function is similar to a coalesce function in SQL in that it will
return
the first value in a list of values that is not undefined or an empty
string
(two things in Puppet that will return a boolean false value).
Typically,
this function is used to check for a value in the Puppet
Dashboard/Enterprise
Console, and failover to a default value like the following:

  $real_jenkins_version = pick($::jenkins_version, '1.449')

The value of $real_jenkins_version will first look for a top-scope
variable
called 'jenkins_version' (note that parameters set in the Puppet
Dashboard/
Enterprise Console are brought into Puppet as top-scope variables), and,
failing that, will use a default value of 1.449.
2012-11-15 08:52:19 -05:00