Skip to content

Commit 2c629c6

Browse files
author
Domenic Del Nano
committed
Add puppet absolute path resources
1 parent 8e17792 commit 2c629c6

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Puppet::Functions.create_function(:is_absolute_path) do
2+
dispatch :deprecation_gen do
3+
param 'Any', :scope
4+
repeated_param 'Any', :args
5+
end
6+
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
7+
def call(scope, *args)
8+
manipulated_args = [scope] + args
9+
self.class.dispatcher.dispatch(self, scope, manipulated_args)
10+
end
11+
def deprecation_gen(scope, *args)
12+
call_function('deprecation', 'is_absolute_path', "This method is deprecated, please use match expressions with Stdlib::Compat::Absolute_Path instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
13+
scope.send("function_is_absolute_path", args)
14+
end
15+
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Puppet::Functions.create_function(:validate_absolute_path) do
2+
dispatch :deprecation_gen do
3+
param 'Any', :scope
4+
repeated_param 'Any', :args
5+
end
6+
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
7+
def call(scope, *args)
8+
manipulated_args = [scope] + args
9+
self.class.dispatcher.dispatch(self, scope, manipulated_args)
10+
end
11+
def deprecation_gen(scope, *args)
12+
call_function('deprecation', 'validate_absolute_path', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_Path. There is further documentation for validate_legacy function in the README.")
13+
scope.send("function_validate_absolute_path", args)
14+
end
15+
end

lib/puppet/parser/functions/is_absolute_path.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module Puppet::Parser::Functions
2323
is_absolute_path($undefined)
2424
2525
ENDHEREDOC
26-
26+
function_deprecation([:is_absolute_path, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_path. There is further documentation for validate_legacy function in the README.'])
2727
require 'puppet/util'
2828

2929
path = args[0]
@@ -47,4 +47,4 @@ module Puppet::Parser::Functions
4747
end
4848
value
4949
end
50-
end
50+
end

lib/puppet/parser/functions/validate_absolute_path.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ module Puppet::Parser::Functions
2626
2727
ENDHEREDOC
2828

29+
# The deprecation function was being called twice, as validate_absolute_path calls is_absolute_path. I have removed it from here so it only calls deprecation once within is_absolute_path.
30+
# function_deprecation([:validate_absolute_path, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_path. There is further documentation for validate_legacy function in the README.'])
31+
2932
require 'puppet/util'
3033

3134
unless args.length > 0 then

0 commit comments

Comments
 (0)