puppet 6.10.1 → 6.11.0

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 (242) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -4
  3. data/Gemfile.lock +20 -12
  4. data/ext/project_data.yaml +3 -2
  5. data/ext/regexp_nodes/regexp_nodes.rb +4 -4
  6. data/ext/windows/service/daemon.rb +33 -8
  7. data/install.rb +6 -6
  8. data/lib/puppet.rb +8 -0
  9. data/lib/puppet/application.rb +1 -1
  10. data/lib/puppet/application/agent.rb +3 -0
  11. data/lib/puppet/application/apply.rb +2 -2
  12. data/lib/puppet/application/describe.rb +3 -9
  13. data/lib/puppet/application/device.rb +3 -0
  14. data/lib/puppet/application/doc.rb +1 -1
  15. data/lib/puppet/application/lookup.rb +1 -1
  16. data/lib/puppet/application/script.rb +2 -2
  17. data/lib/puppet/application/ssl.rb +25 -21
  18. data/lib/puppet/configurer.rb +42 -0
  19. data/lib/puppet/configurer/downloader.rb +2 -6
  20. data/lib/puppet/context/trusted_information.rb +42 -4
  21. data/lib/puppet/defaults.rb +19 -4
  22. data/lib/puppet/face/module/list.rb +5 -5
  23. data/lib/puppet/face/module/search.rb +1 -1
  24. data/lib/puppet/face/module/uninstall.rb +1 -1
  25. data/lib/puppet/face/module/upgrade.rb +1 -1
  26. data/lib/puppet/file_serving/http_metadata.rb +1 -1
  27. data/lib/puppet/file_system.rb +0 -8
  28. data/lib/puppet/file_system/memory_file.rb +1 -1
  29. data/lib/puppet/file_system/posix.rb +3 -2
  30. data/lib/puppet/forge.rb +3 -3
  31. data/lib/puppet/functions.rb +1 -2
  32. data/lib/puppet/gettext/module_translations.rb +1 -1
  33. data/lib/puppet/graph/rb_tree_map.rb +2 -2
  34. data/lib/puppet/graph/simple_graph.rb +4 -3
  35. data/lib/puppet/http.rb +29 -0
  36. data/lib/puppet/http/client.rb +156 -0
  37. data/lib/puppet/http/errors.rb +30 -0
  38. data/lib/puppet/http/redirector.rb +48 -0
  39. data/lib/puppet/http/resolver.rb +5 -0
  40. data/lib/puppet/http/resolver/settings.rb +5 -0
  41. data/lib/puppet/http/resolver/srv.rb +13 -0
  42. data/lib/puppet/http/response.rb +34 -0
  43. data/lib/puppet/http/retry_after_handler.rb +47 -0
  44. data/lib/puppet/http/service.rb +18 -0
  45. data/lib/puppet/http/service/ca.rb +49 -0
  46. data/lib/puppet/http/session.rb +55 -0
  47. data/lib/puppet/indirector/file_bucket_file/file.rb +1 -1
  48. data/lib/puppet/indirector/hiera.rb +2 -0
  49. data/lib/puppet/indirector/request.rb +1 -1
  50. data/lib/puppet/indirector/resource/ral.rb +1 -3
  51. data/lib/puppet/indirector/resource/validator.rb +1 -1
  52. data/lib/puppet/interface.rb +2 -1
  53. data/lib/puppet/interface/documentation.rb +1 -1
  54. data/lib/puppet/loaders.rb +0 -1
  55. data/lib/puppet/metatype/manager.rb +1 -1
  56. data/lib/puppet/module.rb +1 -1
  57. data/lib/puppet/module/task.rb +20 -4
  58. data/lib/puppet/module_tool/applications/installer.rb +1 -1
  59. data/lib/puppet/module_tool/applications/uninstaller.rb +3 -3
  60. data/lib/puppet/module_tool/metadata.rb +1 -1
  61. data/lib/puppet/module_tool/shared_behaviors.rb +4 -4
  62. data/lib/puppet/module_tool/tar/mini.rb +1 -1
  63. data/lib/puppet/network/http.rb +2 -6
  64. data/lib/puppet/network/http/api/indirected_routes.rb +12 -11
  65. data/lib/puppet/network/http/connection.rb +10 -12
  66. data/lib/puppet/network/http/pool.rb +2 -0
  67. data/lib/puppet/network/http/site.rb +5 -1
  68. data/lib/puppet/network/resolver.rb +4 -4
  69. data/lib/puppet/node/environment.rb +4 -2
  70. data/lib/puppet/pal/pal_impl.rb +2 -2
  71. data/lib/puppet/parser/ast.rb +1 -1
  72. data/lib/puppet/parser/ast/resourceparam.rb +1 -1
  73. data/lib/puppet/parser/functions.rb +1 -1
  74. data/lib/puppet/parser/scope.rb +8 -7
  75. data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +1 -1
  76. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +1 -1
  77. data/lib/puppet/pops/evaluator/external_syntax_support.rb +3 -2
  78. data/lib/puppet/pops/evaluator/runtime3_support.rb +4 -7
  79. data/lib/puppet/pops/loader/module_loaders.rb +1 -1
  80. data/lib/puppet/pops/loader/task_instantiator.rb +4 -0
  81. data/lib/puppet/pops/loaders.rb +1 -1
  82. data/lib/puppet/pops/lookup/hiera_config.rb +1 -0
  83. data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
  84. data/lib/puppet/pops/merge_strategy.rb +22 -18
  85. data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
  86. data/lib/puppet/pops/parser/interpolation_support.rb +4 -4
  87. data/lib/puppet/pops/parser/locator.rb +1 -1
  88. data/lib/puppet/pops/parser/pn_parser.rb +17 -16
  89. data/lib/puppet/pops/puppet_stack.rb +52 -48
  90. data/lib/puppet/pops/types/p_sensitive_type.rb +1 -1
  91. data/lib/puppet/pops/types/p_uri_type.rb +1 -1
  92. data/lib/puppet/pops/types/string_converter.rb +10 -10
  93. data/lib/puppet/pops/types/types.rb +3 -3
  94. data/lib/puppet/property.rb +1 -1
  95. data/lib/puppet/property/ensure.rb +1 -1
  96. data/lib/puppet/provider/exec.rb +6 -2
  97. data/lib/puppet/provider/nameservice/directoryservice.rb +1 -1
  98. data/lib/puppet/provider/nameservice/pw.rb +2 -2
  99. data/lib/puppet/provider/package/apt.rb +5 -1
  100. data/lib/puppet/provider/package/dnfmodule.rb +87 -0
  101. data/lib/puppet/provider/package/dpkg.rb +31 -17
  102. data/lib/puppet/provider/package/openbsd.rb +1 -1
  103. data/lib/puppet/provider/package/pip.rb +34 -9
  104. data/lib/puppet/provider/package/portage.rb +1 -1
  105. data/lib/puppet/provider/package/rpm.rb +5 -5
  106. data/lib/puppet/provider/package/windows/package.rb +1 -1
  107. data/lib/puppet/provider/package/yum.rb +1 -1
  108. data/lib/puppet/provider/parsedfile.rb +1 -1
  109. data/lib/puppet/provider/service/daemontools.rb +9 -9
  110. data/lib/puppet/provider/service/openbsd.rb +1 -1
  111. data/lib/puppet/provider/service/rcng.rb +2 -2
  112. data/lib/puppet/provider/service/runit.rb +2 -8
  113. data/lib/puppet/provider/service/systemd.rb +10 -10
  114. data/lib/puppet/provider/user/directoryservice.rb +1 -1
  115. data/lib/puppet/provider/user/user_role_add.rb +1 -1
  116. data/lib/puppet/provider/user/useradd.rb +22 -13
  117. data/lib/puppet/provider/user/windows_adsi.rb +4 -5
  118. data/lib/puppet/reference/indirection.rb +2 -2
  119. data/lib/puppet/reference/metaparameter.rb +1 -3
  120. data/lib/puppet/reference/providers.rb +1 -1
  121. data/lib/puppet/reference/type.rb +3 -9
  122. data/lib/puppet/reports.rb +1 -1
  123. data/lib/puppet/resource.rb +1 -1
  124. data/lib/puppet/resource/catalog.rb +1 -1
  125. data/lib/puppet/rest/errors.rb +1 -0
  126. data/lib/puppet/rest/response.rb +1 -0
  127. data/lib/puppet/rest/route.rb +1 -0
  128. data/lib/puppet/rest/routes.rb +3 -0
  129. data/lib/puppet/runtime.rb +25 -0
  130. data/lib/puppet/settings.rb +3 -3
  131. data/lib/puppet/settings/environment_conf.rb +1 -0
  132. data/lib/puppet/ssl/host.rb +1 -1
  133. data/lib/puppet/ssl/oids.rb +1 -1
  134. data/lib/puppet/ssl/state_machine.rb +23 -15
  135. data/lib/puppet/test/test_helper.rb +1 -1
  136. data/lib/puppet/transaction/report.rb +1 -1
  137. data/lib/puppet/trusted_external.rb +13 -0
  138. data/lib/puppet/type.rb +1 -3
  139. data/lib/puppet/type/exec.rb +7 -3
  140. data/lib/puppet/type/file.rb +1 -2
  141. data/lib/puppet/type/file/source.rb +2 -2
  142. data/lib/puppet/type/package.rb +10 -3
  143. data/lib/puppet/type/schedule.rb +1 -1
  144. data/lib/puppet/type/service.rb +1 -1
  145. data/lib/puppet/util.rb +2 -2
  146. data/lib/puppet/util/command_line/trollop.rb +1 -1
  147. data/lib/puppet/util/http_proxy.rb +2 -10
  148. data/lib/puppet/util/log.rb +2 -2
  149. data/lib/puppet/util/log/destinations.rb +2 -2
  150. data/lib/puppet/util/logging.rb +2 -2
  151. data/lib/puppet/util/metric.rb +2 -2
  152. data/lib/puppet/util/platform.rb +15 -4
  153. data/lib/puppet/util/provider_features.rb +2 -4
  154. data/lib/puppet/util/rdoc.rb +1 -1
  155. data/lib/puppet/util/reference.rb +1 -1
  156. data/lib/puppet/util/resource_template.rb +1 -1
  157. data/lib/puppet/util/selinux.rb +3 -1
  158. data/lib/puppet/util/windows/registry.rb +7 -5
  159. data/lib/puppet/vendor.rb +1 -1
  160. data/lib/puppet/vendor/require_vendored.rb +0 -1
  161. data/lib/puppet/version.rb +1 -1
  162. data/lib/puppet/x509/cert_provider.rb +4 -1
  163. data/locales/puppet.pot +279 -203
  164. data/man/man5/puppet.conf.5 +30 -8
  165. data/man/man8/puppet-agent.8 +4 -1
  166. data/man/man8/puppet-apply.8 +1 -1
  167. data/man/man8/puppet-catalog.8 +1 -1
  168. data/man/man8/puppet-config.8 +1 -1
  169. data/man/man8/puppet-describe.8 +1 -1
  170. data/man/man8/puppet-device.8 +1 -1
  171. data/man/man8/puppet-doc.8 +1 -1
  172. data/man/man8/puppet-epp.8 +1 -1
  173. data/man/man8/puppet-facts.8 +1 -1
  174. data/man/man8/puppet-filebucket.8 +1 -1
  175. data/man/man8/puppet-generate.8 +1 -1
  176. data/man/man8/puppet-help.8 +1 -1
  177. data/man/man8/puppet-key.8 +1 -1
  178. data/man/man8/puppet-lookup.8 +1 -1
  179. data/man/man8/puppet-man.8 +1 -1
  180. data/man/man8/puppet-module.8 +1 -1
  181. data/man/man8/puppet-node.8 +1 -1
  182. data/man/man8/puppet-parser.8 +1 -1
  183. data/man/man8/puppet-plugin.8 +1 -1
  184. data/man/man8/puppet-report.8 +1 -1
  185. data/man/man8/puppet-resource.8 +1 -1
  186. data/man/man8/puppet-script.8 +1 -1
  187. data/man/man8/puppet-ssl.8 +1 -1
  188. data/man/man8/puppet-status.8 +1 -1
  189. data/man/man8/puppet.8 +2 -2
  190. data/spec/fixtures/unit/provider/package/dnfmodule/dnf-module-list-installed.txt +11 -0
  191. data/spec/integration/configurer_spec.rb +52 -0
  192. data/spec/lib/puppet/certificate_factory.rb +2 -2
  193. data/spec/spec_helper.rb +24 -0
  194. data/spec/unit/application/device_spec.rb +6 -0
  195. data/spec/unit/application/ssl_spec.rb +4 -7
  196. data/spec/unit/configurer_spec.rb +1 -0
  197. data/spec/unit/context/trusted_information_spec.rb +41 -2
  198. data/spec/unit/http/client_spec.rb +440 -0
  199. data/spec/unit/http/resolver_spec.rb +45 -0
  200. data/spec/unit/http/service/ca_spec.rb +106 -0
  201. data/spec/unit/http/service_spec.rb +32 -0
  202. data/spec/unit/http/session_spec.rb +102 -0
  203. data/spec/unit/indirector/resource/ral_spec.rb +4 -4
  204. data/spec/unit/network/http/connection_spec.rb +119 -145
  205. data/spec/unit/network/http/site_spec.rb +7 -0
  206. data/spec/unit/parser/scope_spec.rb +10 -0
  207. data/spec/unit/pops/loaders/loaders_spec.rb +13 -2
  208. data/spec/unit/pops/loaders/module_loaders_spec.rb +37 -0
  209. data/spec/unit/provider/exec_spec.rb +209 -0
  210. data/spec/unit/provider/package/dnfmodule_spec.rb +186 -0
  211. data/spec/unit/provider/package/dpkg_spec.rb +238 -78
  212. data/spec/unit/provider/package/pip_spec.rb +51 -6
  213. data/spec/unit/provider/service/daemontools_spec.rb +24 -0
  214. data/spec/unit/provider/service/runit_spec.rb +24 -0
  215. data/spec/unit/provider/service/systemd_spec.rb +25 -25
  216. data/spec/unit/provider/user/useradd_spec.rb +46 -0
  217. data/spec/unit/ssl/host_spec.rb +0 -5
  218. data/spec/unit/ssl/state_machine_spec.rb +16 -10
  219. data/spec/unit/type/exec_spec.rb +6 -12
  220. data/spec/unit/type/file_spec.rb +9 -4
  221. data/spec/unit/type/package_spec.rb +5 -0
  222. data/spec/unit/util/execution_spec.rb +16 -0
  223. data/spec/unit/util/http_proxy_spec.rb +79 -27
  224. data/spec/unit/util/log/destinations_spec.rb +7 -3
  225. metadata +45 -22
  226. data/lib/puppet/pops/loader/null_loader.rb +0 -60
  227. data/lib/puppet/vendor/deep_merge/CHANGELOG +0 -45
  228. data/lib/puppet/vendor/deep_merge/Gemfile +0 -3
  229. data/lib/puppet/vendor/deep_merge/LICENSE +0 -21
  230. data/lib/puppet/vendor/deep_merge/PUPPET_README.md +0 -6
  231. data/lib/puppet/vendor/deep_merge/README.md +0 -113
  232. data/lib/puppet/vendor/deep_merge/Rakefile +0 -19
  233. data/lib/puppet/vendor/deep_merge/deep_merge.gemspec +0 -35
  234. data/lib/puppet/vendor/deep_merge/lib/deep_merge.rb +0 -2
  235. data/lib/puppet/vendor/deep_merge/lib/deep_merge/core.rb +0 -210
  236. data/lib/puppet/vendor/deep_merge/lib/deep_merge/deep_merge_hash.rb +0 -28
  237. data/lib/puppet/vendor/deep_merge/lib/deep_merge/rails_compat.rb +0 -27
  238. data/lib/puppet/vendor/deep_merge/test/test_deep_merge.rb +0 -608
  239. data/lib/puppet/vendor/load_deep_merge.rb +0 -1
  240. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +0 -24
  241. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +0 -24
  242. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_post/should_yield_to_the_block.yml +0 -24
@@ -0,0 +1,49 @@
1
+ class Puppet::HTTP::Service::Ca < Puppet::HTTP::Service
2
+ HEADERS = { 'Accept' => 'text/plain' }.freeze
3
+
4
+ def get_certificate(name, ssl_context: nil)
5
+ response = @client.get(
6
+ with_base_url("/certificate/#{name}"),
7
+ headers: HEADERS,
8
+ ssl_context: ssl_context
9
+ )
10
+
11
+ return response.body.to_s if response.success?
12
+
13
+ raise Puppet::HTTP::ResponseError.new(response)
14
+ end
15
+
16
+ def get_certificate_revocation_list(if_modified_since: nil, ssl_context: nil)
17
+ request_headers = if if_modified_since
18
+ h = HEADERS.dup
19
+ h['If-Modified-Since'] = if_modified_since.httpdate
20
+ h
21
+ else
22
+ HEADERS
23
+ end
24
+
25
+ response = @client.get(
26
+ with_base_url("/certificate_revocation_list/ca"),
27
+ headers: request_headers,
28
+ ssl_context: ssl_context
29
+ )
30
+
31
+ return response.body.to_s if response.success?
32
+
33
+ raise Puppet::HTTP::ResponseError.new(response)
34
+ end
35
+
36
+ def put_certificate_request(name, csr, ssl_context: nil)
37
+ response = @client.put(
38
+ with_base_url("/certificate_request/#{name}"),
39
+ headers: HEADERS,
40
+ content_type: 'text/plain',
41
+ body: csr.to_pem,
42
+ ssl_context: ssl_context
43
+ )
44
+
45
+ return response.body.to_s if response.success?
46
+
47
+ raise Puppet::HTTP::ResponseError.new(response)
48
+ end
49
+ end
@@ -0,0 +1,55 @@
1
+ class Puppet::HTTP::Session
2
+ Route = Struct.new(:service_class, :api, :server_setting, :port_setting)
3
+
4
+ ROUTES = {
5
+ ca: Route.new(Puppet::HTTP::Service::Ca, '/puppet-ca/v1', :ca_server, :ca_port),
6
+ }.freeze
7
+
8
+ def initialize(client, resolvers)
9
+ @client = client
10
+ @resolvers = resolvers
11
+ @resolved_services = {}
12
+ end
13
+
14
+ def route_to(name, ssl_context: nil)
15
+ route = ROUTES[name]
16
+ raise ArgumentError, "Unknown service #{name}" unless route
17
+
18
+ cached = @resolved_services[name]
19
+ return cached if cached
20
+
21
+ errors = []
22
+
23
+ @resolvers.each do |resolver|
24
+ Puppet.debug("Resolving service '#{name}' using #{resolver.class}")
25
+ resolver.resolve(self, name) do |service|
26
+ begin
27
+ service.connect(ssl_context: ssl_context)
28
+ @resolved_services[name] = service
29
+ Puppet.debug("Resolved service '#{name}' to #{service.url}")
30
+ return service
31
+ rescue Puppet::HTTP::ConnectionError => e
32
+ errors << e
33
+ Puppet.debug("Connection to #{service.url} failed, trying next route: #{e.message}")
34
+ end
35
+ end
36
+ end
37
+
38
+ errors.each { |e| Puppet.log_exception(e) }
39
+
40
+ raise Puppet::HTTP::RouteError, "No more routes to #{name}"
41
+ end
42
+
43
+ def create_service(name, server = nil, port = nil)
44
+ route = ROUTES[name]
45
+ raise ArgumentError, "Unknown service #{name}" unless route
46
+
47
+ server ||= Puppet[route.server_setting]
48
+ port ||= Puppet[route.port_setting]
49
+ url = URI::HTTPS.build(host: server,
50
+ port: port,
51
+ path: route.api
52
+ ).freeze
53
+ route.service_class.new(@client, url)
54
+ end
55
+ end
@@ -15,7 +15,7 @@ module Puppet::FileBucketFile
15
15
  request.options[:bucket_path] ||= Puppet[:bucketdir]
16
16
  # If filebucket mode is 'list'
17
17
  if request.options[:list_all]
18
- return nil unless ::File.exists?(request.options[:bucket_path])
18
+ return nil unless ::File.exist?(request.options[:bucket_path])
19
19
  return list(request)
20
20
  end
21
21
  checksum, files_original_path = request_to_checksum_and_path(request)
@@ -69,6 +69,8 @@ class Puppet::Indirector::Hiera < Puppet::Indirector::Terminus
69
69
  end
70
70
  end
71
71
 
72
+ public
73
+
72
74
  def self.hiera_config
73
75
  hiera_config = Puppet.settings[:hiera_config]
74
76
  config = {}
@@ -272,7 +272,7 @@ class Puppet::Indirector::Request
272
272
  return
273
273
  end
274
274
 
275
- @server = uri.host if uri.host
275
+ @server = uri.host if uri.host && !uri.host.empty?
276
276
 
277
277
  # If the URI class can look up the scheme, it will provide a port,
278
278
  # otherwise it will default to '0'.
@@ -25,9 +25,7 @@ class Puppet::Resource::Ral < Puppet::Indirector::Code
25
25
  res.to_resource
26
26
  end.find_all do |res|
27
27
  conditions.all? {|property, value| res.to_resource[property].to_s == value.to_s}
28
- end.sort do |a,b|
29
- a.title <=> b.title
30
- end
28
+ end.sort_by(&:title)
31
29
  end
32
30
 
33
31
  def save( request )
@@ -1,7 +1,7 @@
1
1
  module Puppet::Resource::Validator
2
2
  def validate_key(request)
3
3
  type, title = request.key.split('/', 2)
4
- unless type.downcase == request.instance.type.downcase and title == request.instance.title
4
+ unless type.casecmp(request.instance.type).zero? and title == request.instance.title
5
5
  raise Puppet::Indirector::ValidationError, _("Resource instance does not match request key")
6
6
  end
7
7
  end
@@ -97,7 +97,7 @@ class Puppet::Interface
97
97
  if Puppet::Interface::FaceCollection[name, :current]
98
98
  raise Puppet::Error, "Could not find version #{version} of #{name}"
99
99
  else
100
- raise Puppet::Error, "Could not find Puppet Face #{name.to_s}"
100
+ raise Puppet::Error, "Could not find Puppet Face #{name}"
101
101
  end
102
102
  end
103
103
 
@@ -235,4 +235,5 @@ class Puppet::Interface
235
235
  define_method(name, proc)
236
236
  instance_method(name)
237
237
  end
238
+ private_class_method :__add_method
238
239
  end
@@ -318,7 +318,7 @@ class Puppet::Interface
318
318
  when String then
319
319
  input.strip.split(/,/).map do |part|
320
320
  part = part.strip
321
- if part.match(/^\d+$/)
321
+ if part =~ /^\d+$/
322
322
  part.to_i
323
323
  else
324
324
  found = part.split(/-/)
@@ -9,7 +9,6 @@ module Puppet
9
9
  require 'puppet/pops/loader/gem_support'
10
10
  require 'puppet/pops/loader/module_loaders'
11
11
  require 'puppet/pops/loader/dependency_loader'
12
- require 'puppet/pops/loader/null_loader'
13
12
  require 'puppet/pops/loader/static_loader'
14
13
  require 'puppet/pops/loader/runtime3_type_loader'
15
14
  require 'puppet/pops/loader/ruby_function_instantiator'
@@ -121,7 +121,7 @@ module Manager
121
121
 
122
122
  # Now set up autoload any providers that might exist for this type.
123
123
 
124
- klass.providerloader = Puppet::Util::Autoload.new(klass, "puppet/provider/#{klass.name.to_s}")
124
+ klass.providerloader = Puppet::Util::Autoload.new(klass, "puppet/provider/#{klass.name}")
125
125
 
126
126
  # We have to load everything so that we can figure out the default provider.
127
127
  klass.providerloader.loadall(Puppet.lookup(:current_environment))
@@ -237,7 +237,7 @@ class Puppet::Module
237
237
  @metadata = data = read_metadata
238
238
  return if data.empty?
239
239
 
240
- @forge_name = data['name'].gsub('-', '/') if data['name']
240
+ @forge_name = data['name'].tr('-', '/') if data['name']
241
241
 
242
242
  [:source, :author, :version, :license, :dependencies].each do |attr|
243
243
  value = data[attr.to_s]
@@ -76,11 +76,23 @@ class Puppet::Module
76
76
  # Find task's required lib files and retrieve paths for both 'files' and 'implementation:files' metadata keys
77
77
  def self.find_extra_files(metadata, envname = nil)
78
78
  return [] if metadata.nil?
79
+
80
+ files = metadata.fetch('files', [])
81
+ unless files.is_a?(Array)
82
+ msg = _("The 'files' task metadata expects an array, got %{files}.") % {files: files}
83
+ raise InvalidMetadata.new(msg, 'puppet.tasks/invalid-metadata')
84
+ end
85
+ impl_files = metadata.fetch('implementations', []).flat_map do |impl|
86
+ file_array = impl.fetch('files', [])
87
+ unless file_array.is_a?(Array)
88
+ msg = _("The 'files' task metadata expects an array, got %{files}.") % {files: file_array}
89
+ raise InvalidMetadata.new(msg, 'puppet.tasks/invalid-metadata')
90
+ end
91
+ file_array
92
+ end
79
93
 
80
- files = metadata.fetch('files', []) +
81
- metadata.fetch('implementations', []).flat_map { |impl| impl.fetch('files', []) }
82
-
83
- files.uniq.flat_map do |file|
94
+ combined_files = files + impl_files
95
+ combined_files.uniq.flat_map do |file|
84
96
  module_name, mount, endpath = file.split("/", 3)
85
97
  # If there's a mount directory with no trailing slash this will be nil
86
98
  # We want it to be empty to construct a path
@@ -142,6 +154,10 @@ class Puppet::Module
142
154
  end
143
155
 
144
156
  implementations = metadata['implementations'].map do |impl|
157
+ unless impl['requirements'].is_a?(Array) || impl['requirements'].nil?
158
+ msg = _("Task metadata for task %{name} does not specify requirements as an array" % { name: name })
159
+ raise InvalidMetadata.new(msg, 'puppet.tasks/invalid-metadata')
160
+ end
145
161
  path = executables.find { |real_impl| File.basename(real_impl) == impl['name'] }
146
162
  unless path
147
163
  msg = _("Task metadata for task %{name} specifies missing implementation %{implementation}" % { name: name, implementation: impl['name'] })
@@ -306,7 +306,7 @@ module Puppet::ModuleTool
306
306
  @environment.modules_by_path[options[:target_dir]].each do |mod|
307
307
  if mod.has_metadata?
308
308
  metadata = {
309
- :name => mod.forge_name.gsub('/', '-'),
309
+ :name => mod.forge_name.tr('/', '-'),
310
310
  :version => mod.version
311
311
  }
312
312
  next if release[:module] == metadata[:name]
@@ -49,7 +49,7 @@ module Puppet::ModuleTool
49
49
 
50
50
  def find_installed_module
51
51
  @environment.modules_by_path.values.flatten.each do |mod|
52
- mod_name = (mod.forge_name || mod.name).gsub('/', '-')
52
+ mod_name = (mod.forge_name || mod.name).tr('/', '-')
53
53
  if mod_name == @name
54
54
  @unfiltered << {
55
55
  :name => mod_name,
@@ -100,7 +100,7 @@ module Puppet::ModuleTool
100
100
  if mod.has_metadata? && !changes.empty?
101
101
  raise LocalChangesError,
102
102
  :action => :uninstall,
103
- :module_name => (mod.forge_name || mod.name).gsub('/', '-'),
103
+ :module_name => (mod.forge_name || mod.name).tr('/', '-'),
104
104
  :requested_version => @options[:version],
105
105
  :installed_version => mod.version
106
106
  end
@@ -108,7 +108,7 @@ module Puppet::ModuleTool
108
108
 
109
109
  if !@options[:force] && !mod.required_by.empty?
110
110
  raise ModuleIsRequiredError,
111
- :module_name => (mod.forge_name || mod.name).gsub('/', '-'),
111
+ :module_name => (mod.forge_name || mod.name).tr('/', '-'),
112
112
  :required_by => mod.required_by,
113
113
  :requested_version => @options[:version],
114
114
  :installed_version => mod.version
@@ -101,7 +101,7 @@ module Puppet::ModuleTool
101
101
 
102
102
  contents = data.keys.map do |k|
103
103
  value = (Puppet::Util::Json.dump(data[k], :pretty => true) rescue data[k].to_json)
104
- %Q("#{k.to_s}": #{value})
104
+ %Q("#{k}": #{value})
105
105
  end
106
106
 
107
107
  "{\n" + contents.join(",\n").gsub(/^/, ' ') + "\n}\n"
@@ -8,12 +8,12 @@ module Puppet::ModuleTool::Shared
8
8
  @installed = Hash.new { |h,k| h[k] = [] }
9
9
 
10
10
  @environment.modules_by_path.values.flatten.each do |mod|
11
- mod_name = (mod.forge_name || mod.name).gsub('/', '-')
11
+ mod_name = (mod.forge_name || mod.name).tr('/', '-')
12
12
  @installed[mod_name] << mod
13
13
  d = @local["#{mod_name}@#{mod.version}"]
14
14
  (mod.dependencies || []).each do |hash|
15
15
  name, conditions = hash['name'], hash['version_requirement']
16
- name = name.gsub('/', '-')
16
+ name = name.tr('/', '-')
17
17
  d[name] = conditions
18
18
  @conditions[name] << {
19
19
  :module => mod_name,
@@ -34,7 +34,7 @@ module Puppet::ModuleTool::Shared
34
34
  info = forge.remote_dependency_info(author, modname, @options[:version])
35
35
  info.each do |pair|
36
36
  mod_name, releases = pair
37
- mod_name = mod_name.gsub('/', '-')
37
+ mod_name = mod_name.tr('/', '-')
38
38
  releases.each do |rel|
39
39
  semver = SemanticPuppet::Version.parse(rel['version']) rescue SemanticPuppet::Version::MIN
40
40
  @versions[mod_name] << { :vstring => rel['version'], :semver => semver }
@@ -42,7 +42,7 @@ module Puppet::ModuleTool::Shared
42
42
  @urls["#{mod_name}@#{rel['version']}"] = rel['file']
43
43
  d = @remote["#{mod_name}@#{rel['version']}"]
44
44
  (rel['dependencies'] || []).each do |name, conditions|
45
- d[name.gsub('/', '-')] = conditions
45
+ d[name.tr('/', '-')] = conditions
46
46
  end
47
47
  end
48
48
  end
@@ -93,7 +93,7 @@ class Puppet::ModuleTool::Tar::Mini
93
93
  def find_valid_files(tarfile)
94
94
  Archive::Tar::Minitar.open(tarfile).collect do |entry|
95
95
  flag = entry.typeflag
96
- if flag.nil? || flag =~ /[[:digit:]]/ && (0..7).include?(flag.to_i)
96
+ if flag.nil? || flag =~ /[[:digit:]]/ && (0..7).cover?(flag.to_i)
97
97
  entry.full_name
98
98
  else
99
99
  Puppet.debug "Invalid tar flag '#{flag}' will not be extracted: #{entry.name}"
@@ -18,12 +18,8 @@ module Puppet::Network::HTTP
18
18
  require 'puppet/network/http/handler'
19
19
  require 'puppet/network/http/response'
20
20
  require 'puppet/network/http/request'
21
- require 'puppet/network/http/site'
22
- require 'puppet/network/http/session'
23
- require 'puppet/network/http/factory'
24
- require 'puppet/network/http/base_pool'
25
- require 'puppet/network/http/nocache_pool'
26
- require 'puppet/network/http/pool'
27
21
  require 'puppet/network/http/memory_response'
28
22
  require 'puppet/network/http/compression'
23
+
24
+ require 'puppet/http'
29
25
  end
@@ -120,6 +120,17 @@ class Puppet::Network::HTTP::API::IndirectedRoutes
120
120
  [indirection, method, key, params]
121
121
  end
122
122
 
123
+ def self.request_to_uri(request)
124
+ uri, body = request_to_uri_and_body(request)
125
+ "#{uri}?#{body}"
126
+ end
127
+
128
+ def self.request_to_uri_and_body(request)
129
+ url_prefix = IndirectionType.url_prefix_for(request.indirection_name.to_s)
130
+ indirection = request.method == :search ? pluralize(request.indirection_name.to_s) : request.indirection_name.to_s
131
+ ["#{url_prefix}/#{indirection}/#{Puppet::Util.uri_encode(request.key)}", "environment=#{request.environment.name}&#{request.query_string}"]
132
+ end
133
+
123
134
  private
124
135
 
125
136
  # Execute our find.
@@ -255,20 +266,10 @@ class Puppet::Network::HTTP::API::IndirectedRoutes
255
266
  method
256
267
  end
257
268
 
258
- def self.request_to_uri(request)
259
- uri, body = request_to_uri_and_body(request)
260
- "#{uri}?#{body}"
261
- end
262
-
263
- def self.request_to_uri_and_body(request)
264
- url_prefix = IndirectionType.url_prefix_for(request.indirection_name.to_s)
265
- indirection = request.method == :search ? pluralize(request.indirection_name.to_s) : request.indirection_name.to_s
266
- ["#{url_prefix}/#{indirection}/#{Puppet::Util.uri_encode(request.key)}", "environment=#{request.environment.name}&#{request.query_string}"]
267
- end
268
-
269
269
  def self.pluralize(indirection)
270
270
  return(indirection == "status" ? "statuses" : indirection + "s")
271
271
  end
272
+ private_class_method :pluralize
272
273
 
273
274
  def plurality(indirection)
274
275
  # NOTE These specific hooks for paths are ridiculous, but it's a *many*-line
@@ -325,19 +325,17 @@ module Puppet::Network::HTTP
325
325
  rescue => exception
326
326
  elapsed = (Time.now - start).to_f.round(3)
327
327
  uri = [@site.addr, request.path.split('?')[0]].join('/')
328
- eclass = exception.class
329
-
330
- err = case exception
331
- when EOFError
332
- eclass.new(_('request %{uri} interrupted after %{elapsed} seconds') % {uri: uri, elapsed: elapsed})
333
- when Timeout::Error
334
- eclass.new(_('request %{uri} timed out after %{elapsed} seconds') % {uri: uri, elapsed: elapsed})
335
- else
336
- eclass.new(_('request %{uri} failed: %{msg}') % {uri: uri, msg: exception.message})
337
- end
338
328
 
339
- err.set_backtrace(exception.backtrace) unless exception.backtrace.empty?
340
- raise err
329
+ case exception
330
+ when EOFError
331
+ Puppet.log_exception(exception, _('request %{uri} interrupted after %{elapsed} seconds') % {uri: uri, elapsed: elapsed})
332
+ when Timeout::Error
333
+ Puppet.log_exception(exception, _('request %{uri} timed out after %{elapsed} seconds') % {uri: uri, elapsed: elapsed})
334
+ else
335
+ Puppet.log_exception(exception, _('request %{uri} failed: %{msg}') % {uri: uri, msg: exception.message})
336
+ end
337
+
338
+ raise exception
341
339
  end
342
340
 
343
341
  def with_connection(site, &block)
@@ -89,6 +89,8 @@ class Puppet::Network::HTTP::Pool < Puppet::Network::HTTP::BasePool
89
89
  #
90
90
  # @api private
91
91
  def setsockopts(netio)
92
+ return unless netio
93
+
92
94
  socket = netio.io
93
95
  socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
94
96
  end
@@ -8,6 +8,10 @@
8
8
  class Puppet::Network::HTTP::Site
9
9
  attr_reader :scheme, :host, :port
10
10
 
11
+ def self.from_uri(uri)
12
+ self.new(uri.scheme, uri.host, uri.port)
13
+ end
14
+
11
15
  def initialize(scheme, host, port)
12
16
  @scheme = scheme
13
17
  @host = host
@@ -15,7 +19,7 @@ class Puppet::Network::HTTP::Site
15
19
  end
16
20
 
17
21
  def addr
18
- "#{@scheme}://#{@host}:#{@port.to_s}"
22
+ "#{@scheme}://#{@host}:#{@port}"
19
23
  end
20
24
  alias to_s addr
21
25