Age | Commit message (Collapse) | Author |
|
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.
|
|
|
|
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>
|
|
|
|
|
|
|
|
|
|
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": }
|
|
* 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
|
|
|
|
|
|
|
|
* 4.x:
Add reject() function
|
|
* 2.x:
Add reject() function
|
|
Like the grep function, but we can now reject members of an array
based on a pattern.
|
|
* 4.x:
(Maint) Add spec/functions to rake test task
Add example behaviors for ensure_packages() function
Add an ensure_packages function.
|
|
* 2.x:
(Maint) Add spec/functions to rake test task
Add example behaviors for ensure_packages() function
Add an ensure_packages function.
Conflicts:
Rakefile
|
|
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.
|
|
* 4.x:
(#17797) min() and max() functions
|
|
* 2.x:
(#17797) min() and max() functions
|
|
returns the min or max of all arguments given to them
|
|
* 4.x:
(#14670) Fixup file_line autorequire specs
(#14670) autorequire a file_line resource's path
|
|
* 2.x:
(#14670) Fixup file_line autorequire specs
(#14670) autorequire a file_line resource's path
|
|
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.
|
|
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.
|
|
* 4.x:
Add join_keys_to_values function
|
|
* 2.x:
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.
|
|
* jfryman-master:
puppet-lint cleanup
|
|
* 2.x:
Extend delete function for strings and hashes
Fixed typo
|
|
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.
|
|
|
|
* 2.x:
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.
|
|
* 2.x:
(#13974) Add predicate functions for interface facts
|
|
If one wishes to test if a host has a particular IP address (such as a floating
virtual address) or has an interface on a particular network (such as a
secondary management network), the facts that provide this information are
difficult to use within Puppet.
This patch addresses these needs by implementing functions
‘has_ip_address(value)’ and ‘has_ip_network(value)’. These functions look
through all interfaces for ipaddress_<interface> and network_<interface>
(respectively) having the requested <value>.
These functions are implemented on top of a lower-level predicate
function, ‘has_interface_with(kind, value)’, which iterates through the
interfaces in the ‘interfaces’ fact and checks the facts <kind>_<interface>
looking for <value>.
Additionally, the existence of a particular named interface can be checked for
by calling with only a single argument: has_interface_with(interface).
A Boolean is returned in all cases.
|
|
|
|
|
|
* 2.5.x:
(maint) Fix spec failures resulting from Facter API changes
|
|
This reverts commit 9e8c60a8b73fd96393b08d690c7197e62aae623e.
This was an error on my part. 3.1.x descends from 3.0.x _and_ 2.5.x, but 3.0.x does
not descend from 2.5.x. I should not have merged 2.5.x into 3.0.x,
instead I should have merged 2.5.x into 3.1.x skipping over the 3.0.x
merge up.
I'm slowly starting to understand the implications of semver on our
branching strategy... =)
|
|
This reverts commit c8c7afc7a00aaeeddea6514d9fe9508513e53a73, reversing
changes made to 03ec16e291a70ac5ac412be36ae3b86a771b98af.
This was a mistake on my part. 2.5 is a minor release and minor
releases should never be merged into patch level branches. 2.5.x should
have been merged into 3.1.x instead.
|
|
Without this patch stdlib tests fail against Facter 2.x and master but
not 1.6.x.
This patch fixes the problem by initializing the example group
differently depending on the version of Facter integrating into the
system. The adjusted methods are:
1.x - Facter.collection.loader.load
2.x - Facter.collection.load
The collection actually implements the load method in both version, it's
simply marked as private in 1.x.
|
|
* 2.5.x:
Update Modulefile, CHANGELOG for 2.5.0
Explicitly load functions used by ensure_resource
re-formatting
Add better docs about duplicate resource failures
Handle undef for parameter argument
Add function ensure_resource and defined_with_params
Revert "Revert "Merge branch 'haus-add_pe_facts_to_stdlib' into 2.4.x""
Revert "Merge branch 'haus-add_pe_facts_to_stdlib' into 2.4.x"
Prevent undefined method `split' for nil:NilClass with pe_foo_version facts
(maint) Clear all facts before each example
Add spec tests for pe_version facts
Add PE facts to stdlib
Conflicts:
CHANGELOG
Modulefile
spec/spec_helper.rb
|
|
This commit refactors to ensure 80 character lines.
|
|
This commit adds better handling of the case where
undef is passed as the parameter value.
This works by converting '' into []
|
|
This commit adds 2 new functions with unit tests.
defined_with_params works similarily to puppet's defined
function, except it allows you to also specify a hash of
params. defined_with_params will return true if a resource
also exists that matches the specified type/title (just like
with defined) as well as all of the specified params.
ensure_resource is a function that basically combines defined_with_params
with create_resources to conditionally create resources only if the
specified resource (title, type, params) does not already exist.
These functions are created to serve as an alternative to using
defined as follows:
if ! defined(Package['some_package']) {
package { 'some_package': ensure => present,
}
The issue with this usage is that there is no guarentee about
what parameters were set in the previous definition of the package
that made its way into the catalog.
ensure_resource could be used instead, as:
ensure_resource('package', 'some_package', { 'ensure' => 'present' })
This will creat the package resources only if another resource does
not exist with the specified parameters.
|
|
This reverts commit d6d23b495cda0e154b4e73982acc43e586564c0e.
This backwards-compatible additional functionality is targeted at the
next minor release. There are already backwards-incompatible changes in
the master branch so we need to establish a new minor branch.
|
|
This reverts commit 74e6411157b8df1af9a24c17971e3236f3096529, reversing
changes made to 417d219aa6e42f2a16af42c98aa063fc1d9d2ecd.
Here's why:
Actually... I just screwed this up.
I merged this new fact into 2.4.x but it's not fixing any bug. It's adding a
new fact, so this should go into master and we should release 2.5 since this is
new, backwards-compatible functionality.
|
|
Without this patch example groups must explicitly call `Facter.clear` to
clear any cached values between examples. This is a problem because
this behavior is not the concern of the example groups, the behavior is
the concern of the spec_helper or whatever facility we have in place to
initialize the system for testing.
This patch fixes the problem by duplicating the logic in the Facter
spec_helper to ensure facts are cleared out before each example.
This patch requires the example groups to explicitly load the facts they
require if the fact name does not match the filename.
|
|
This commit adds some basic spec tests for the pe_version facts. There are
basic postitive and negative cases.
|