puppet 2.7.21 → 2.7.22

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (101) hide show
  1. data/CHANGELOG +14 -0
  2. data/Gemfile.lock +2 -2
  3. data/ext/build_defaults.yaml +2 -3
  4. data/ext/debian/control +1 -1
  5. data/ext/packaging/README.md +496 -8
  6. data/ext/packaging/spec/tasks/00_utils_spec.rb +7 -7
  7. data/ext/packaging/spec/tasks/build_object_spec.rb +3 -0
  8. data/ext/packaging/tasks/00_utils.rake +2 -2
  9. data/ext/packaging/tasks/10_setupvars.rake +8 -1
  10. data/ext/packaging/tasks/build.rake +2 -0
  11. data/ext/packaging/tasks/deb_repos.rake +48 -15
  12. data/ext/packaging/tasks/jenkins.rake +30 -2
  13. data/ext/packaging/tasks/mock.rake +3 -2
  14. data/ext/packaging/tasks/pe_remote.rake +1 -1
  15. data/ext/packaging/tasks/pe_ship.rake +4 -5
  16. data/ext/packaging/tasks/pe_sign.rake +8 -0
  17. data/ext/packaging/tasks/pe_sles.rake +8 -7
  18. data/ext/packaging/tasks/pre_tasks.rake +0 -0
  19. data/ext/packaging/tasks/retrieve.rake +11 -1
  20. data/ext/packaging/tasks/rpm_repos.rake +71 -49
  21. data/ext/packaging/tasks/ship.rake +14 -2
  22. data/ext/packaging/tasks/sign.rake +9 -3
  23. data/ext/packaging/tasks/tar.rake +5 -0
  24. data/ext/packaging/tasks/vendor_gems.rake +110 -0
  25. data/install.rb +1 -1
  26. data/lib/puppet.rb +11 -0
  27. data/lib/puppet/indirector/report/processor.rb +1 -1
  28. data/lib/puppet/indirector/report/rest.rb +7 -0
  29. data/lib/puppet/indirector/resource/rest.rb +9 -0
  30. data/lib/puppet/indirector/rest.rb +81 -47
  31. data/lib/puppet/indirector/run/rest.rb +6 -0
  32. data/lib/puppet/network/formats.rb +20 -10
  33. data/lib/puppet/network/http/handler.rb +1 -1
  34. data/lib/puppet/node.rb +25 -0
  35. data/lib/puppet/node/facts.rb +23 -4
  36. data/lib/puppet/resource.rb +2 -4
  37. data/lib/puppet/resource/status.rb +28 -0
  38. data/lib/puppet/run.rb +24 -2
  39. data/lib/puppet/status.rb +6 -2
  40. data/lib/puppet/transaction/event.rb +19 -0
  41. data/lib/puppet/transaction/report.rb +39 -0
  42. data/lib/puppet/util/log.rb +19 -0
  43. data/lib/puppet/util/metric.rb +6 -0
  44. data/lib/puppet/util/monkey_patches.rb +0 -16
  45. data/lib/puppet/vendor.rb +55 -0
  46. data/lib/puppet/vendor/load_safe_yaml.rb +1 -0
  47. data/lib/puppet/vendor/require_vendored.rb +4 -0
  48. data/lib/puppet/vendor/safe_yaml/CHANGES.md +104 -0
  49. data/lib/puppet/vendor/safe_yaml/Gemfile +11 -0
  50. data/lib/puppet/vendor/safe_yaml/LICENSE.txt +22 -0
  51. data/lib/puppet/vendor/safe_yaml/README.md +179 -0
  52. data/lib/puppet/vendor/safe_yaml/Rakefile +6 -0
  53. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml.rb +253 -0
  54. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/deep.rb +34 -0
  55. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/parse/date.rb +27 -0
  56. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/parse/hexadecimal.rb +12 -0
  57. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/parse/sexagesimal.rb +26 -0
  58. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/psych_handler.rb +92 -0
  59. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/psych_resolver.rb +52 -0
  60. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/resolver.rb +94 -0
  61. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/safe_to_ruby_visitor.rb +17 -0
  62. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/syck_hack.rb +36 -0
  63. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/syck_node_monkeypatch.rb +43 -0
  64. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/syck_resolver.rb +38 -0
  65. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/transform.rb +41 -0
  66. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/transform/to_boolean.rb +21 -0
  67. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/transform/to_date.rb +11 -0
  68. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/transform/to_float.rb +33 -0
  69. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/transform/to_integer.rb +25 -0
  70. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/transform/to_nil.rb +18 -0
  71. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/transform/to_symbol.rb +13 -0
  72. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/transform/transformation_map.rb +47 -0
  73. data/lib/puppet/vendor/safe_yaml/lib/safe_yaml/version.rb +3 -0
  74. data/lib/puppet/vendor/safe_yaml/run_specs_all_ruby_versions.sh +21 -0
  75. data/lib/puppet/vendor/safe_yaml/safe_yaml.gemspec +18 -0
  76. data/lib/puppet/vendor/safe_yaml/spec/exploit.1.9.2.yaml +2 -0
  77. data/lib/puppet/vendor/safe_yaml/spec/exploit.1.9.3.yaml +2 -0
  78. data/lib/puppet/vendor/safe_yaml/spec/psych_resolver_spec.rb +10 -0
  79. data/lib/puppet/vendor/safe_yaml/spec/resolver_specs.rb +250 -0
  80. data/lib/puppet/vendor/safe_yaml/spec/safe_yaml_spec.rb +702 -0
  81. data/lib/puppet/vendor/safe_yaml/spec/spec_helper.rb +18 -0
  82. data/lib/puppet/vendor/safe_yaml/spec/support/exploitable_back_door.rb +29 -0
  83. data/lib/puppet/vendor/safe_yaml/spec/syck_resolver_spec.rb +10 -0
  84. data/lib/puppet/vendor/safe_yaml/spec/transform/base64_spec.rb +11 -0
  85. data/lib/puppet/vendor/safe_yaml/spec/transform/to_date_spec.rb +34 -0
  86. data/lib/puppet/vendor/safe_yaml/spec/transform/to_float_spec.rb +42 -0
  87. data/lib/puppet/vendor/safe_yaml/spec/transform/to_integer_spec.rb +59 -0
  88. data/lib/puppet/vendor/safe_yaml/spec/transform/to_symbol_spec.rb +49 -0
  89. data/lib/puppet/version.rb +1 -1
  90. data/spec/lib/puppet_spec/matchers.rb +8 -0
  91. data/spec/unit/file_serving/metadata_spec.rb +20 -28
  92. data/spec/unit/indirector/report/rest_spec.rb +41 -0
  93. data/spec/unit/indirector/rest_spec.rb +314 -339
  94. data/spec/unit/network/formats_spec.rb +36 -27
  95. data/spec/unit/network/http/handler_spec.rb +3 -12
  96. data/spec/unit/node_spec.rb +81 -0
  97. data/spec/unit/resource_spec.rb +5 -35
  98. data/spec/unit/run_spec.rb +22 -8
  99. data/spec/unit/status_spec.rb +6 -0
  100. data/test/network/handler/report.rb +0 -36
  101. metadata +148 -102
@@ -67,9 +67,9 @@ namespace :pl do
67
67
  rsync_to('pkg/apple/*.dmg', @build.yum_host, @build.dmg_path)
68
68
  end if @build.build_dmg
69
69
 
70
- desc "ship tarball and signature to #{@build.yum_host}"
70
+ desc "ship tarball and signature to #{@build.tar_host}"
71
71
  task :ship_tar => 'pl:fetch' do
72
- rsync_to("pkg/#{@build.project}-#{@build.version}.tar.gz*", @build.yum_host, @build.tarball_path)
72
+ rsync_to("pkg/#{@build.project}-#{@build.version}.tar.gz*", @build.tar_host, @build.tarball_path)
73
73
  end
74
74
 
75
75
  desc "UBER ship: ship all the things in pkg"
@@ -101,6 +101,18 @@ namespace :pl do
101
101
  remote_ssh_cmd(@build.distribution_server, "mkdir -p #{artifact_dir}")
102
102
  rsync_to("pkg/", @build.distribution_server, "#{artifact_dir}/ --exclude repo_configs")
103
103
  end
104
+
105
+ desc "Ship generated repository configs to the distribution server"
106
+ task :ship_repo_configs do
107
+ if empty_dir?("pkg/repo_configs")
108
+ warn "No repo configs have been generated! Try pl:deb_repo_configs or pl:rpm_repo_configs"
109
+ exit 1
110
+ end
111
+ invoke_task("pl:fetch")
112
+ repo_dir = "#{@build.jenkins_repo_path}/#{@build.project}/#{@build.ref}/repo_configs"
113
+ remote_ssh_cmd(@build.distribution_server, "mkdir -p #{repo_dir}")
114
+ rsync_to("pkg/repo_configs/", @build.distribution_server, repo_dir)
115
+ end
104
116
  end
105
117
  end
106
118
 
@@ -98,9 +98,15 @@ namespace :pl do
98
98
  warn "There were files found in pkg/. Maybe you wanted to build/retrieve something first?"
99
99
  exit 1
100
100
  end
101
- sign_tasks = ["pl:sign_tar", "pl:sign_rpms", "pl:sign_deb_changes"]
102
- remote_repo = remote_bootstrap(@build.distribution_server, 'HEAD')
103
- build_params = remote_buildparams(@build.distribution_server, @build)
101
+ # Because rpms and debs are laid out differently in PE under pkg/ they
102
+ # have a different sign task to address this. Rather than create a whole
103
+ # extra :jenkins task for signing PE, we determine which sign task to use
104
+ # based on if we're building PE
105
+ rpm_sign_task = @build.build_pe ? "pe:sign_rpms" : "pl:sign_rpms"
106
+ deb_sign_task = @build.build_pe ? "pe:sign_deb_changes" : "pl:sign_deb_changes"
107
+ sign_tasks = ["pl:sign_tar", rpm_sign_task, deb_sign_task]
108
+ remote_repo = remote_bootstrap(@build.distribution_server, 'HEAD')
109
+ build_params = remote_buildparams(@build.distribution_server, @build)
104
110
  rsync_to('pkg', @build.distribution_server, remote_repo)
105
111
  remote_ssh_cmd(@build.distribution_server, "cd #{remote_repo} ; rake #{sign_tasks.join(' ')} PARAMS_FILE=#{build_params}")
106
112
  rsync_from("#{remote_repo}/pkg/", @build.distribution_server, "pkg/")
@@ -1,6 +1,11 @@
1
1
  namespace :package do
2
2
  desc "Create a source tar archive"
3
3
  task :tar => [ :clean ] do
4
+
5
+ if @build.pre_tar_task
6
+ invoke_task(@build.pre_tar_task)
7
+ end
8
+
4
9
  Rake::Task["package:doc"].invoke if @build.build_doc
5
10
  tar = ENV['TAR'] || 'tar'
6
11
  workdir = "pkg/#{@build.project}-#{@build.version}"
@@ -0,0 +1,110 @@
1
+ # This is an optional pre-tar-task, so we only want to present it if we're
2
+ # using it
3
+ if @build.pre_tar_task == "package:vendor_gems"
4
+ namespace :package do
5
+ desc "vendor gems required by project"
6
+ task :vendor_gems do
7
+ check_tool("bundle")
8
+ require 'bundler'
9
+
10
+ class UI
11
+ LEVELS = %w(silent error warn confirm info debug)
12
+
13
+ def warn(message, newline = nil)
14
+ puts message
15
+ end
16
+
17
+ def debug(message, newline = nil)
18
+ puts message
19
+ end
20
+
21
+ def trace(message, newline = nil)
22
+ puts message
23
+ end
24
+
25
+ def error(message, newline = nil)
26
+ puts message
27
+ end
28
+
29
+ def info(message, newline = nil)
30
+ puts message
31
+ end
32
+
33
+ def confirm(message, newline = nil)
34
+ end
35
+
36
+ def debug?
37
+ true
38
+ end
39
+
40
+ def ask(message)
41
+ end
42
+
43
+ def quiet?
44
+ false
45
+ end
46
+
47
+ def level=(level)
48
+ raise ArgumentError unless LEVELS.include?(level.to_s)
49
+ @level = level
50
+ end
51
+
52
+ def level(name = nil)
53
+ name ? LEVELS.index(name) <= LEVELS.index(@level) : @level
54
+ end
55
+
56
+ def silence
57
+ old_level, @level = @level, "silent"
58
+ yield
59
+ ensure
60
+ @level = old_level
61
+ end
62
+
63
+ end
64
+
65
+ class RGProxy < ::Gem::SilentUI
66
+ def initialize(ui)
67
+ @ui = ui
68
+ super()
69
+ end
70
+
71
+ def say(message)
72
+ if message =~ /native extensions/
73
+ @ui.info "with native extensions "
74
+ else
75
+ @ui.debug(message)
76
+ end
77
+ end
78
+ end
79
+
80
+
81
+ # Cache all the gems locally without using the shared GEM_PATH
82
+ Bundler.settings[:cache_all] = true
83
+ Bundler.settings[:local] = true
84
+ Bundler.settings[:disable_shared_gems] = true
85
+ # Make sure we cache all the gems, despite what the local config file says...
86
+ Bundler.settings.without = []
87
+
88
+ # Stupid bundler requires this because it's not abstracted out into a library that doesn't need IO
89
+ Bundler.ui = UI.new()
90
+ Bundler.rubygems.ui = ::RGProxy.new(Bundler.ui)
91
+ Bundler.ui.level = "debug"
92
+
93
+ # Load the the Gemfile and resolve gems using RubyGems.org
94
+ definition = Bundler.definition
95
+ definition.validate_ruby!
96
+ definition.resolve_remotely!
97
+
98
+ mkdir_p Bundler.app_cache
99
+
100
+ # Cache the gems
101
+ definition.specs.each do |spec|
102
+ # Fetch Rubygem specs
103
+ Bundler::Fetcher.fetch(spec) if spec.source.is_a?(Bundler::Source::Rubygems)
104
+ # Cache everything but bundler itself...
105
+ spec.source.cache(spec) unless spec.name == "bundler"
106
+ end
107
+
108
+ end
109
+ end
110
+ end
data/install.rb CHANGED
@@ -121,7 +121,7 @@ end
121
121
 
122
122
  def do_libs(libs, strip = 'lib/')
123
123
  libs.each do |lf|
124
- olf = File.join(InstallOptions.site_dir, lf.gsub(/#{strip}/, ''))
124
+ olf = File.join(InstallOptions.site_dir, lf.sub(/^#{strip}/, ''))
125
125
  op = File.dirname(olf)
126
126
  if $haveftools
127
127
  File.makedirs(op, true)
@@ -7,6 +7,8 @@ rescue LoadError
7
7
  end
8
8
 
9
9
  # see the bottom of the file for further inclusions
10
+ # Also see the new Vendor support - towards the end
11
+
10
12
  require 'singleton'
11
13
  require 'facter'
12
14
  require 'puppet/error'
@@ -112,6 +114,15 @@ module Puppet
112
114
  def self.newtype(name, options = {}, &block)
113
115
  Puppet::Type.newtype(name, options, &block)
114
116
  end
117
+
118
+ # Load vendored (setup paths, and load what is needed upfront).
119
+ # See the Vendor class for how to add additional vendored gems/code
120
+ require "puppet/vendor"
121
+ Puppet::Vendor.load_vendored
122
+
123
+ # Set default for YAML.load to unsafe so we don't affect programs
124
+ # requiring puppet -- in puppet we will call safe explicitly
125
+ SafeYAML::OPTIONS[:default_mode] = :unsafe
115
126
  end
116
127
 
117
128
  require 'puppet/type'
@@ -49,7 +49,7 @@ class Puppet::Transaction::Report::Processor < Puppet::Indirector::Code
49
49
  end
50
50
 
51
51
  def processors(&blk)
52
- return if Puppet[:reports] == "none"
52
+ return [] if Puppet[:reports] == "none"
53
53
  reports.each do |name|
54
54
  if mod = Puppet::Reports.report(name)
55
55
  yield(mod)
@@ -4,4 +4,11 @@ class Puppet::Transaction::Report::Rest < Puppet::Indirector::REST
4
4
  desc "Get server report over HTTP via REST."
5
5
  use_server_setting(:report_server)
6
6
  use_port_setting(:report_port)
7
+
8
+ private
9
+
10
+ def deserialize_save(content_type, body)
11
+ format = Puppet::Network::FormatHandler.protected_format(content_type)
12
+ format.intern(Array, body)
13
+ end
7
14
  end
@@ -2,4 +2,13 @@ require 'puppet/indirector/status'
2
2
  require 'puppet/indirector/rest'
3
3
 
4
4
  class Puppet::Resource::Rest < Puppet::Indirector::REST
5
+
6
+ private
7
+
8
+ def deserialize_save(content_type, body)
9
+ # Body is [ral_res.to_resource, transaction.report]
10
+ format = Puppet::Network::FormatHandler.protected_format(content_type)
11
+ ary = format.intern(Array, body)
12
+ [Puppet::Resource.from_pson(ary[0]), Puppet::Transaction::Report.from_pson(ary[1])]
13
+ end
5
14
  end
@@ -32,36 +32,6 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus
32
32
  Puppet.settings[port_setting || :masterport].to_i
33
33
  end
34
34
 
35
- # Figure out the content type, turn that into a format, and use the format
36
- # to extract the body of the response.
37
- def deserialize(response, multiple = false)
38
- case response.code
39
- when "404"
40
- return nil
41
- when /^2/
42
- raise "No content type in http response; cannot parse" unless response['content-type']
43
-
44
- content_type = response['content-type'].gsub(/\s*;.*$/,'') # strip any appended charset
45
-
46
- body = uncompress_body(response)
47
-
48
- # Convert the response to a deserialized object.
49
- if multiple
50
- model.convert_from_multiple(content_type, body)
51
- else
52
- model.convert_from(content_type, body)
53
- end
54
- else
55
- # Raise the http error if we didn't get a 'success' of some kind.
56
- raise convert_to_http_error(response)
57
- end
58
- end
59
-
60
- def convert_to_http_error(response)
61
- message = "Error #{response.code} on SERVER: #{(response.body||'').empty? ? response.message : uncompress_body(response)}"
62
- Net::HTTPError.new(message, response)
63
- end
64
-
65
35
  # Provide appropriate headers.
66
36
  def headers
67
37
  add_accept_encoding({"Accept" => model.supported_formats.join(", ")})
@@ -127,39 +97,58 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus
127
97
  else
128
98
  http_get(request, uri_with_query_string, headers)
129
99
  end
130
- result = deserialize response
131
- result.name = request.key if result.respond_to?(:name=)
132
- result
100
+
101
+ if is_http_200?(response)
102
+ content_type, body = parse_response(response)
103
+ result = deserialize_find(content_type, body)
104
+ result.name = request.key if result.respond_to?(:name=)
105
+ result
106
+ else
107
+ nil
108
+ end
133
109
  end
134
110
 
135
111
  def head(request)
136
112
  response = http_head(request, indirection2uri(request), headers)
137
- case response.code
138
- when "404"
139
- return false
140
- when /^2/
141
- return true
142
- else
143
- # Raise the http error if we didn't get a 'success' of some kind.
144
- raise convert_to_http_error(response)
145
- end
113
+
114
+ !!is_http_200?(response)
146
115
  end
147
116
 
148
117
  def search(request)
149
- unless result = deserialize(http_get(request, indirection2uri(request), headers), true)
150
- return []
118
+ response = http_get(request, indirection2uri(request), headers)
119
+
120
+ if is_http_200?(response)
121
+ content_type, body = parse_response(response)
122
+ deserialize_search(content_type, body) || []
123
+ else
124
+ []
151
125
  end
152
- result
153
126
  end
154
127
 
155
128
  def destroy(request)
156
129
  raise ArgumentError, "DELETE does not accept options" unless request.options.empty?
157
- deserialize http_delete(request, indirection2uri(request), headers)
130
+
131
+ response = http_delete(request, indirection2uri(request), headers)
132
+
133
+ if is_http_200?(response)
134
+ content_type, body = parse_response(response)
135
+ deserialize_destroy(content_type, body)
136
+ else
137
+ nil
138
+ end
158
139
  end
159
140
 
160
141
  def save(request)
161
142
  raise ArgumentError, "PUT does not accept options" unless request.options.empty?
162
- deserialize http_put(request, indirection2uri(request), request.instance.render, headers.merge({ "Content-Type" => request.instance.mime }))
143
+
144
+ response = http_put(request, indirection2uri(request), request.instance.render, headers.merge({ "Content-Type" => request.instance.mime }))
145
+
146
+ if is_http_200?(response)
147
+ content_type, body = parse_response(response)
148
+ deserialize_save(content_type, body)
149
+ else
150
+ nil
151
+ end
163
152
  end
164
153
 
165
154
  def validate_key(request)
@@ -168,6 +157,51 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus
168
157
 
169
158
  private
170
159
 
160
+ def is_http_200?(response)
161
+ case response.code
162
+ when "404"
163
+ false
164
+ when /^2/
165
+ true
166
+ else
167
+ # Raise the http error if we didn't get a 'success' of some kind.
168
+ raise convert_to_http_error(response)
169
+ end
170
+ end
171
+
172
+ def convert_to_http_error(response)
173
+ message = "Error #{response.code} on SERVER: #{(response.body||'').empty? ? response.message : uncompress_body(response)}"
174
+ Net::HTTPError.new(message, response)
175
+ end
176
+
177
+ # Returns the content_type, stripping any appended charset, and the
178
+ # body, decompressed if necessary (content-encoding is checked inside
179
+ # uncompress_body)
180
+ def parse_response(response)
181
+ if response['content-type']
182
+ [ response['content-type'].gsub(/\s*;.*$/,''),
183
+ body = uncompress_body(response) ]
184
+ else
185
+ raise "No content type in http response; cannot parse"
186
+ end
187
+ end
188
+
189
+ def deserialize_find(content_type, body)
190
+ model.convert_from(content_type, body)
191
+ end
192
+
193
+ def deserialize_search(content_type, body)
194
+ model.convert_from_multiple(content_type, body)
195
+ end
196
+
197
+ def deserialize_destroy(content_type, body)
198
+ model.convert_from(content_type, body)
199
+ end
200
+
201
+ def deserialize_save(content_type, body)
202
+ nil
203
+ end
204
+
171
205
  def environment
172
206
  Puppet::Node::Environment.new
173
207
  end
@@ -3,4 +3,10 @@ require 'puppet/indirector/rest'
3
3
 
4
4
  class Puppet::Run::Rest < Puppet::Indirector::REST
5
5
  desc "Trigger Agent runs via REST."
6
+
7
+ private
8
+
9
+ def deserialize_save(content_type, body)
10
+ model.convert_from(content_type, body)
11
+ end
6
12
  end
@@ -3,12 +3,20 @@ require 'puppet/network/format_handler'
3
3
  Puppet::Network::FormatHandler.create_serialized_formats(:yaml) do
4
4
  # Yaml doesn't need the class name; it's serialized.
5
5
  def intern(klass, text)
6
- YAML.safely_load(text)
6
+ data = YAML.load(text, :safe => true, :deserialize_symbols => true)
7
+ return data if data.is_a?(klass)
8
+ klass.from_pson(data)
7
9
  end
8
10
 
9
11
  # Yaml doesn't need the class name; it's serialized.
10
12
  def intern_multiple(klass, text)
11
- YAML.safely_load(text)
13
+ YAML.load(text, :safe => true, :deserialize_symbols => true).collect do |data|
14
+ if data.is_a?(klass)
15
+ data
16
+ else
17
+ klass.from_pson(data)
18
+ end
19
+ end
12
20
  end
13
21
 
14
22
  def render(instance)
@@ -45,11 +53,15 @@ Puppet::Network::FormatHandler.create_serialized_formats(:b64_zlib_yaml) do
45
53
  end
46
54
 
47
55
  def intern(klass, text)
48
- decode(text)
56
+ requiring_zlib do
57
+ Puppet::Network::FormatHandler.format(:yaml).intern(klass, decode(text))
58
+ end
49
59
  end
50
60
 
51
61
  def intern_multiple(klass, text)
52
- decode(text)
62
+ requiring_zlib do
63
+ Puppet::Network::FormatHandler.format(:yaml).intern_multiple(klass, decode(text))
64
+ end
53
65
  end
54
66
 
55
67
  def render(instance)
@@ -64,15 +76,13 @@ Puppet::Network::FormatHandler.create_serialized_formats(:b64_zlib_yaml) do
64
76
  true
65
77
  end
66
78
 
67
- def encode(text)
68
- requiring_zlib do
69
- Base64.encode64(Zlib::Deflate.deflate(text, Zlib::BEST_COMPRESSION))
70
- end
79
+ def decode(data)
80
+ Zlib::Inflate.inflate(Base64.decode64(data))
71
81
  end
72
82
 
73
- def decode(yaml)
83
+ def encode(text)
74
84
  requiring_zlib do
75
- YAML.safely_load(Zlib::Inflate.inflate(Base64.decode64(yaml)))
85
+ Base64.encode64(Zlib::Deflate.deflate(text, Zlib::BEST_COMPRESSION))
76
86
  end
77
87
  end
78
88
  end