Skip to content

Commit e1962ec

Browse files
author
Joshua Hoblitt
committed
give up all hope of a post stdlib 4.1.0 release happening
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.
1 parent 30bd33d commit e1962ec

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed

.fixtures.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ fixtures:
22
repositories:
33
"stdlib":
44
repo: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
5-
ref: "f496005bf3db8a5202bf9c16daf9a524b178c67a"
5+
ref: "4.0.0"
66
symlinks:
77
"pureftpd": "#{source_dir}"

Modulefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ project_page 'https://github.com/jhoblitt/puppet-pureftpd'
77
source 'https://github.com/jhoblitt/puppet-pureftpd.git'
88
summary 'Manages the pure-ftpd package with comprehensive configuration support'
99
description 'Manages the pure-ftpd package with comprehensive configuration support'
10-
dependency 'puppetlabs/stdlib', '> 4.1.0'
10+
dependency 'puppetlabs/stdlib', '>= 4.0.0'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# copied from stdlib commit id f496005bf3db8a5202bf9c16daf9a524b178c67a
2+
# Includes a fix for string handling not included in the latest stdlib release
3+
# (4.1.0 as of 2014-01-27). Presumably, the next release of stdlib will
4+
# include this fix and will allow this function to be removed.
5+
module Puppet::Parser::Functions
6+
newfunction(:pureftpd_merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
7+
Merges two or more hashes together and returns the resulting hash.
8+
9+
For example:
10+
11+
$hash1 = {'one' => 1, 'two', => 2}
12+
$hash2 = {'two' => 'dos', 'three', => 'tres'}
13+
$merged_hash = merge($hash1, $hash2)
14+
# The resulting hash is equivalent to:
15+
# $merged_hash = {'one' => 1, 'two' => 'dos', 'three' => 'tres'}
16+
17+
When there is a duplicate key, the key in the rightmost hash will "win."
18+
19+
ENDHEREDOC
20+
21+
if args.length < 2
22+
raise Puppet::ParseError, ("merge(): wrong number of arguments (#{args.length}; must be at least 2)")
23+
end
24+
25+
# The hash we accumulate into
26+
accumulator = Hash.new
27+
# Merge into the accumulator hash
28+
args.each do |arg|
29+
next if arg.is_a? String and arg.empty? # empty string is synonym for puppet's undef
30+
unless arg.is_a?(Hash)
31+
raise Puppet::ParseError, "merge: unexpected argument type #{arg.class}, only expects hash arguments"
32+
end
33+
accumulator.merge!(arg)
34+
end
35+
# Return the fully merged hash
36+
accumulator
37+
end
38+
end

manifests/init.pp

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
$enable_ldap = { ldapconfigfile => $pureftpd::params::ldap_conf_path }
6363

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

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

100100
# instantiate a pureftpd::config::mysql will notify the service class
101-
$safe_config_pgsql = merge($config_pgsql,
101+
$safe_config_pgsql = pureftpd_merge($config_pgsql,
102102
{ notify => Class[ 'pureftpd::service' ] }
103103
)
104104
create_resources( 'class',
@@ -112,7 +112,7 @@
112112
Class[ 'pureftpd::config::pgsql' ]
113113
}
114114

115-
$safe_config = merge(
115+
$safe_config = pureftpd_merge(
116116
$config,
117117
{ notify => Class[ 'pureftpd::service' ] },
118118
$enable_ldap,

0 commit comments

Comments
 (0)