Skip to content

Commit c0c7ccb

Browse files
committed
(CONT-801) Deprecate parsepson.rb
1 parent 55c4aea commit c0c7ccb

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/puppet/functions/parsepson.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# frozen_string_literal: true
22

33
# @summary
4+
# **Deprecated:** Starting Puppet 8, we no longer natively support PSON usage. This function should be removed once we stop supporting Puppet 7.
5+
#
46
# This function accepts PSON, a Puppet variant of JSON, as a string and converts
57
# it into the correct Puppet structure
68
#
@@ -20,7 +22,9 @@
2022
end
2123

2224
def parsepson(pson_string, default = :no_default_provided)
23-
PSON.load(pson_string)
25+
call_function('deprecation', 'parsepson', 'This method is deprecated. From Puppet 8, PSON is no longer natively supported. Please use JSON.parse().')
26+
27+
PSON.load(pson_string) if Puppet::Util::Package.versioncmp(Puppet.version, '8').negative?
2428
rescue StandardError => e
2529
Puppet.debug("Parsing PSON failed with error: #{e.message}")
2630
raise e if default == :no_default_provided

spec/functions/parsepson_spec.rb

+5
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,9 @@
6565
end
6666
end
6767
end
68+
if Puppet::Util::Package.versioncmp(Puppet.version, '8.0.0').positive?
69+
it 'doesnt work on Puppet 8' do
70+
expect(subject).to run.with_params('{"a":"1","b":"2"}').and_return(nil)
71+
end
72+
end
6873
end

0 commit comments

Comments
 (0)