Skip to content

Commit 53f5a73

Browse files
committed
Deprecating functions that have been ported to Puppet 5.5.0.
1 parent d303fff commit 53f5a73

File tree

13 files changed

+61
-33
lines changed

13 files changed

+61
-33
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,8 @@ Converts the case of a string or of all strings in an array to lowercase.
11631163

11641164
#### `empty`
11651165

1166+
**Deprecated. Puppet 5.5.0 has introduced a built in `empty` function, which will take precedence over the stdlib function. See [Puppet 5.5.0 Release Notes](https://puppet.com/docs/puppet/5.5/release_notes.html#new-features).**
1167+
11661168
Returns `true` if the argument is an array or hash that contains no elements, or an empty string. Returns `false` when the argument is a numerical value.
11671169

11681170
*Type*: rvalue.
@@ -1274,6 +1276,8 @@ fact('vmware."VRA.version"')
12741276

12751277
#### `flatten`
12761278

1279+
**Deprecated. Puppet 5.5.0 has introduced a built in `flatten` function, which will take precedence over the stdlib function. See [Puppet 5.5.0 Release Notes](https://puppet.com/docs/puppet/5.5/release_notes.html#new-features).**
1280+
12771281
Flattens deeply nested arrays and returns a single flat array as a result.
12781282

12791283
For example, `flatten(['a', ['b', ['c']]])` returns ['a','b','c'].
@@ -1631,6 +1635,8 @@ Returns `true` if the variable passed to this function is a string.
16311635

16321636
#### `join`
16331637

1638+
**Deprecated. Puppet 5.5.0 has introduced a built in `join` function, which will take precedence over the stdlib function. See [Puppet 5.5.0 Release Notes](https://puppet.com/docs/puppet/5.5/release_notes.html#new-features).**
1639+
16341640
Joins an array into a string using a separator. For example, `join(['a','b','c'], ",")` results in: "a,b,c".
16351641

16361642
*Type*: rvalue.
@@ -1647,12 +1653,16 @@ For example, `join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ")` results in ["a i
16471653

16481654
#### `keys`
16491655

1656+
**Deprecated. Puppet 5.5.0 has introduced a built in `keys` function, which will take precedence over the stdlib function. See [Puppet 5.5.0 Release Notes](https://puppet.com/docs/puppet/5.5/release_notes.html#new-features).**
1657+
16501658
Returns the keys of a hash as an array.
16511659

16521660
*Type*: rvalue.
16531661

16541662
#### `length`
16551663

1664+
**Deprecated. Puppet 5.5.0 has introduced a built in `length` function, which will take precedence over the stdlib function. See [Puppet 5.5.0 Release Notes](https://puppet.com/docs/puppet/5.5/release_notes.html#new-features).**
1665+
16561666
Returns the length of a given string, array or hash. Replaces the deprecated `size()` function.
16571667

16581668
*Type*: rvalue.
@@ -2774,6 +2784,8 @@ validate_x509_rsa_key_pair($cert, $key)
27742784

27752785
#### `values`
27762786

2787+
**Deprecated. Puppet 5.5.0 has introduced a built in `values` function, which will take precedence over the stdlib function. See [Puppet 5.5.0 Release Notes](https://puppet.com/docs/puppet/5.5/release_notes.html#new-features).**
2788+
27772789
Returns the values of a given hash.
27782790

27792791
For example, given `$hash = {'a'=1, 'b'=2, 'c'=3} values($hash)` returns [1,2,3].

lib/puppet/parser/functions/empty.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ module Puppet::Parser::Functions
77
DOC
88
) do |arguments|
99

10+
function_deprecation([:empty, 'This method is deprecated, this function is now shipped with Puppet in versions 5.5.0 and later. For more information please see Puppet 5.5.0 Release Notes.'])
11+
1012
raise(Puppet::ParseError, "empty(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
1113
value = arguments[0]
1214

lib/puppet/parser/functions/flatten.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ module Puppet::Parser::Functions
1414
DOC
1515
) do |arguments|
1616

17+
function_deprecation([:flatten, 'This method is deprecated, this function is now shipped with Puppet in versions 5.5.0 and later. For more information please see Puppet 5.5.0 Release Notes'])
18+
1719
raise(Puppet::ParseError, "flatten(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
1820

1921
array = arguments[0]

lib/puppet/parser/functions/join.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ module Puppet::Parser::Functions
1313
DOC
1414
) do |arguments|
1515

16+
function_deprecation([:join, 'This method is deprecated, this function is now shipped with Puppet in versions 5.5.0 and later. For more information please see Puppet 5.5.0 Release Notes'])
17+
1618
# Technically we support two arguments but only first is mandatory ...
1719
raise(Puppet::ParseError, "join(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
1820

lib/puppet/parser/functions/keys.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ module Puppet::Parser::Functions
77
DOC
88
) do |arguments|
99

10+
function_deprecation([:keys, 'This method is deprecated, this function is now shipped with Puppet in versions 5.5.0 and later. For more information please see Puppet 5.5.0 Release Notes.'])
11+
1012
raise(Puppet::ParseError, "keys(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
1113

1214
hash = arguments[0]

lib/puppet/parser/functions/values.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ module Puppet::Parser::Functions
2020
DOC
2121
) do |arguments|
2222

23+
function_deprecation([:values, 'This method is deprecated, this function is now shipped with Puppet in versions 5.5.0 and later. For more information please see Puppet 5.5.0 Release Notes.'])
24+
2325
raise(Puppet::ParseError, "values(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
2426

2527
hash = arguments[0]

spec/acceptance/values_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
notice(inline_template('<%= @output.inspect %>'))
2424
DOC
2525
it 'handles non-hash arguments' do
26-
expect(apply_manifest(pp2, :expect_failures => true).stderr).to match(%r{Requires hash})
26+
expect(apply_manifest(pp2, :expect_failures => true).stderr).to match(%r{Requires hash}) if return_puppet_version < '5.5.0'
27+
expect(apply_manifest(pp2, :expect_failures => true).stderr).to match(%r{expects a Hash value}) if return_puppet_version >= '5.5.0'
2728
end
2829
end
2930
end

spec/functions/empty_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
describe 'empty' do
44
it { is_expected.not_to eq(nil) }
5-
it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
5+
it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } if Puppet.version < '5.5.0'
66
it {
77
pending('Current implementation ignores parameters after the first.')
88
is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError)

spec/functions/flatten_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
describe 'flatten' do
44
it { is_expected.not_to eq(nil) }
5-
it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
6-
it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError) }
7-
it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) }
8-
it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) }
5+
it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } if Puppet.version < '5.5.0'
6+
it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError) } if Puppet.version < '5.5.0'
7+
it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) } if Puppet.version < '5.5.0'
8+
it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) } if Puppet.version < '5.5.0'
99
it { is_expected.to run.with_params([]).and_return([]) }
1010
it { is_expected.to run.with_params(['one']).and_return(['one']) }
1111
it { is_expected.to run.with_params([['one']]).and_return(['one']) }

spec/functions/join_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
describe 'join' do
44
it { is_expected.not_to eq(nil) }
5-
it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
5+
it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } if Puppet.version < '5.5.0'
66
it {
77
pending('Current implementation ignores parameters after the second.')
88
is_expected.to run.with_params([], '', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
99
}
10-
it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Requires array to work with}) }
11-
it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, %r{Requires string to work with}) }
10+
it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Requires array to work with}) } if Puppet.version < '5.5.0'
11+
it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, %r{Requires string to work with}) } if Puppet.version < '5.5.0'
1212

1313
it { is_expected.to run.with_params([]).and_return('') }
1414
it { is_expected.to run.with_params([], ':').and_return('') }

0 commit comments

Comments
 (0)