Skip to content

Commit 2faf561

Browse files
authored
Merge pull request #9034 from joshcooper/drop_pson
(PUP-9648) Prepare for PSON removal
2 parents f13f392 + c14de49 commit 2faf561

33 files changed

+104
-160
lines changed

acceptance/lib/puppet/acceptance/module_utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def get_default_modulepath_for_host(host)
4444
# @param host [String] hostname
4545
# @return [Array] paths for found modules
4646
def get_installed_modules_for_host(host)
47-
on host, puppet("module list --render-as pson")
47+
on host, puppet("module list --render-as json")
4848
str = stdout.lines.to_a.last
4949
pat = /\(([^()]+)\)/
5050
mods = str.scan(pat).flatten

acceptance/tests/language/exported_resources.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
step 'stop puppet server' do
1818
on(master, "service #{master['puppetservice']} stop")
1919
end
20-
step 'remove cached agent pson catalogs from the master' do
20+
step 'remove cached agent json catalogs from the master' do
2121
on(master, "rm -f #{File.join(master.puppet['yamldir'],'catalog','*')}",
2222
:accept_all_exit_codes => true)
2323
end
@@ -33,10 +33,10 @@
3333
end
3434
end
3535

36-
storeconfigs_backend_name = 'pson_storeconfigs'
36+
storeconfigs_backend_name = 'json_storeconfigs'
3737
step 'create a yaml storeconfigs terminus in the modulepath' do
3838
moduledir = File.join(environmentpath,tmp_environment,'modules')
39-
terminus_class_name = 'PsonStoreconfigs'
39+
terminus_class_name = 'JsonStoreconfigs'
4040
manifest = <<MANIFEST
4141
File {
4242
ensure => directory,
@@ -64,8 +64,8 @@ def save(request)
6464
# This is quite likely a bad idea, since we are not managing ownership or modes.
6565
Dir.mkdir(basedir) unless Puppet::FileSystem.exist?(basedir)
6666
begin
67-
# We cannot dump anonymous modules in yaml, so dump to json/pson
68-
File.open(file, "w") { |f| f.write request.instance.to_pson }
67+
# We cannot dump anonymous modules in yaml, so dump to json
68+
File.open(file, "w") { |f| f.write request.instance.to_json }
6969
rescue TypeError => detail
7070
Puppet.err "Could not save \#{self.name} \#{request.key}: \#{detail}"
7171
end
@@ -108,7 +108,7 @@ class Puppet::Resource::#{terminus_class_name} < Puppet::Indirector::Yaml
108108
def search(request)
109109
catalog_dir = File.join(Puppet.run_mode.server? ? Puppet[:yamldir] : Puppet[:clientyamldir], "catalog", "*")
110110
results = Dir.glob(catalog_dir).collect { |file|
111-
catalog = Puppet::Resource::Catalog.convert_from(:pson, File.read(file))
111+
catalog = Puppet::Resource::Catalog.convert_from(:json, File.read(file))
112112
if catalog.name == request.options[:host]
113113
next
114114
end

acceptance/tests/security/cve-2013-1652_improper_query_params.rb

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

2727
cert_path = on(agent, puppet('agent', "--configprint hostcert")).stdout.chomp
2828
key_path = on(agent, puppet('agent', "--configprint hostprivkey")).stdout.chomp
29-
curl_base = "curl --tlsv1 -g --cert \"#{cert_path}\" --key \"#{key_path}\" -k -H 'Accept: pson'"
29+
curl_base = "curl --tlsv1 -g --cert \"#{cert_path}\" --key \"#{key_path}\" -k -H 'Accept: application/json'"
3030

3131
curl_call = "#{curl_base} '#{payload}'"
3232

acceptance/tests/security/cve-2013-1652_poison_other_node_cache.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
master, puppet('agent', "--configprint hostprivkey")).stdout.chomp
2222

2323
curl_base = "curl --tlsv1 -g --cert \"#{cert_path}\" " +
24-
"--key \"#{key_path}\" -k -H 'Accept: pson'"
24+
"--key \"#{key_path}\" -k -H 'Accept: application/json'"
2525

2626
step "Attempt to poison the master's node cache" do
2727
yamldir = puppet_config(master, 'yamldir', section: 'master')

acceptance/tests/server_returns_pson_when_preferred_serialization_set.rb

Lines changed: 0 additions & 36 deletions
This file was deleted.

lib/puppet.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
require_relative 'puppet/util/feature'
2121
require_relative 'puppet/util/suidmanager'
2222
require_relative 'puppet/util/run_mode'
23-
# PSON is deprecated, use JSON instead
24-
require_relative 'puppet/external/pson/common'
25-
require_relative 'puppet/external/pson/version'
26-
require_relative 'puppet/external/pson/pure'
2723
require_relative 'puppet/gettext/config'
2824
require_relative 'puppet/defaults'
2925

lib/puppet/defaults.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,6 +1711,11 @@ def self.initialize_default_settings!(settings)
17111711
instances will be serialized using this method, since not all classes
17121712
can be guaranteed to support this format, but it will be used for all
17131713
classes that support it.",
1714+
:hook => proc { |value|
1715+
if value == "pson" && !Puppet.features.pson?
1716+
raise(Puppet::Settings::ValidationError, "The 'puppet-pson' gem must be installed to use the PSON serialization format.")
1717+
end
1718+
}
17141719
},
17151720
:agent_catalog_run_lockfile => {
17161721
:default => "$statedir/agent_catalog_run.lock",

lib/puppet/feature/pson.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
require_relative '../../puppet/util/feature'
2+
3+
# PSON is deprecated, use JSON instead
4+
Puppet.features.add(:pson, :libs => ['puppet/external/pson/common','puppet/external/pson/version', 'puppet/external/pson/pure'])

lib/puppet/http/service/report.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ def put_report(name, report, environment:)
5454

5555
if response.success?
5656
response
57-
elsif !@session.supports?(:report, 'json') && Puppet[:preferred_serialization_format] != 'pson'
58-
#TRANSLATORS "pson", "preferred_serialization_format", and "puppetserver" should not be translated
59-
raise Puppet::HTTP::ProtocolError.new(_("To submit reports to a server running puppetserver %{server_version}, set preferred_serialization_format to pson") % { server_version: response[Puppet::HTTP::HEADER_PUPPET_VERSION]})
6057
else
6158
raise Puppet::HTTP::ResponseError.new(response)
6259
end

lib/puppet/indirector/report/rest.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,6 @@ def save(request)
2020
raise convert_to_http_error(e.response)
2121
end
2222

23-
# This is called by the superclass when not using our httpclient.
24-
def handle_response(request, response)
25-
if !response.success?
26-
server_version = response[Puppet::Network::HEADER_PUPPET_VERSION]
27-
if server_version &&
28-
SemanticPuppet::Version.parse(server_version).major < Puppet::Indirector::REST::MAJOR_VERSION_JSON_DEFAULT &&
29-
Puppet[:preferred_serialization_format] != 'pson'
30-
format = Puppet[:preferred_serialization_format]
31-
raise Puppet::Error.new(_("Server version %{version} does not accept reports in '%{format}', use `preferred_serialization_format=pson`") % {version: server_version, format: format})
32-
end
33-
end
34-
end
35-
3623
private
3724

3825
def deserialize_save(content_type, body)

0 commit comments

Comments
 (0)