Skip to content

Commit

Permalink
give up all hope of a post stdlib 4.1.0 release happening
Browse files Browse the repository at this point in the history
This module is dependant the behavior of the stdlib merge() function as
of commit f496005bf3db8a5202bf9c16daf9a524b178c67a, which was merged
after lastest (4.1.0) release.  Since that release is almost a year old
now, it's looking unlikely that there will be another release in the
near future.

As a workaround, the merge() function has been copied into this module as
pureftpd_merge() and the Module dep as been reduced to stdlib >= 4.0.0.
  • Loading branch information
Joshua Hoblitt committed Apr 8, 2014
1 parent 30bd33d commit e1962ec
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ fixtures:
repositories:
"stdlib":
repo: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
ref: "f496005bf3db8a5202bf9c16daf9a524b178c67a"
ref: "4.0.0"
symlinks:
"pureftpd": "#{source_dir}"
2 changes: 1 addition & 1 deletion Modulefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ project_page 'https://github.com/jhoblitt/puppet-pureftpd'
source 'https://github.com/jhoblitt/puppet-pureftpd.git'
summary 'Manages the pure-ftpd package with comprehensive configuration support'
description 'Manages the pure-ftpd package with comprehensive configuration support'
dependency 'puppetlabs/stdlib', '> 4.1.0'
dependency 'puppetlabs/stdlib', '>= 4.0.0'
38 changes: 38 additions & 0 deletions lib/puppet/parser/functions/pureftpd_merge.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# copied from stdlib commit id f496005bf3db8a5202bf9c16daf9a524b178c67a
# Includes a fix for string handling not included in the latest stdlib release
# (4.1.0 as of 2014-01-27). Presumably, the next release of stdlib will
# include this fix and will allow this function to be removed.
module Puppet::Parser::Functions
newfunction(:pureftpd_merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
Merges two or more hashes together and returns the resulting hash.
For example:
$hash1 = {'one' => 1, 'two', => 2}
$hash2 = {'two' => 'dos', 'three', => 'tres'}
$merged_hash = merge($hash1, $hash2)
# The resulting hash is equivalent to:
# $merged_hash = {'one' => 1, 'two' => 'dos', 'three' => 'tres'}
When there is a duplicate key, the key in the rightmost hash will "win."
ENDHEREDOC

if args.length < 2
raise Puppet::ParseError, ("merge(): wrong number of arguments (#{args.length}; must be at least 2)")
end

# The hash we accumulate into
accumulator = Hash.new
# Merge into the accumulator hash
args.each do |arg|
next if arg.is_a? String and arg.empty? # empty string is synonym for puppet's undef
unless arg.is_a?(Hash)
raise Puppet::ParseError, "merge: unexpected argument type #{arg.class}, only expects hash arguments"
end
accumulator.merge!(arg)
end
# Return the fully merged hash
accumulator
end
end
8 changes: 4 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
$enable_ldap = { ldapconfigfile => $pureftpd::params::ldap_conf_path }

# instantiate a pureftpd::config::ldap that will notify the service class
$safe_config_ldap = merge($config_ldap,
$safe_config_ldap = pureftpd_merge($config_ldap,
{ notify => Class[ 'pureftpd::service' ] }
)
create_resources( 'class',
Expand All @@ -80,7 +80,7 @@
$enable_mysql = { mysqlconfigfile => $pureftpd::params::mysql_conf_path }

# instantiate a pureftpd::config::mysql that will notify the service class
$safe_config_mysql = merge($config_mysql,
$safe_config_mysql = pureftpd_merge($config_mysql,
{ notify => Class[ 'pureftpd::service' ] }
)
create_resources( 'class',
Expand All @@ -98,7 +98,7 @@
$enable_pgsql = { pgsqlconfigfile => $pureftpd::params::pgsql_conf_path }

# instantiate a pureftpd::config::mysql will notify the service class
$safe_config_pgsql = merge($config_pgsql,
$safe_config_pgsql = pureftpd_merge($config_pgsql,
{ notify => Class[ 'pureftpd::service' ] }
)
create_resources( 'class',
Expand All @@ -112,7 +112,7 @@
Class[ 'pureftpd::config::pgsql' ]
}

$safe_config = merge(
$safe_config = pureftpd_merge(
$config,
{ notify => Class[ 'pureftpd::service' ] },
$enable_ldap,
Expand Down

0 comments on commit e1962ec

Please sign in to comment.