puppet 6.4.4-universal-darwin → 6.4.5-universal-darwin

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 (221) hide show
  1. checksums.yaml +4 -4
  2. data/CODEOWNERS +1 -1
  3. data/Gemfile +4 -4
  4. data/Gemfile.lock +38 -32
  5. data/ext/build_defaults.yaml +1 -0
  6. data/ext/cert_inspector +3 -3
  7. data/ext/puppet-test +2 -2
  8. data/ext/regexp_nodes/regexp_nodes.rb +4 -4
  9. data/ext/windows/service/daemon.rb +38 -8
  10. data/install.rb +6 -6
  11. data/lib/puppet/application.rb +1 -1
  12. data/lib/puppet/application/apply.rb +2 -2
  13. data/lib/puppet/application/describe.rb +3 -9
  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 +4 -1
  18. data/lib/puppet/configurer.rb +86 -30
  19. data/lib/puppet/configurer/downloader.rb +2 -6
  20. data/lib/puppet/defaults.rb +32 -6
  21. data/lib/puppet/error.rb +9 -1
  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/functions/camelcase.rb +2 -2
  33. data/lib/puppet/functions/epp.rb +4 -4
  34. data/lib/puppet/functions/find_file.rb +9 -9
  35. data/lib/puppet/functions/inline_epp.rb +5 -5
  36. data/lib/puppet/gettext/module_translations.rb +1 -1
  37. data/lib/puppet/graph/rb_tree_map.rb +2 -2
  38. data/lib/puppet/graph/simple_graph.rb +4 -3
  39. data/lib/puppet/indirector/file_bucket_file/file.rb +1 -1
  40. data/lib/puppet/indirector/hiera.rb +2 -0
  41. data/lib/puppet/indirector/resource/ral.rb +1 -3
  42. data/lib/puppet/indirector/resource/validator.rb +1 -1
  43. data/lib/puppet/interface.rb +2 -1
  44. data/lib/puppet/loaders.rb +0 -1
  45. data/lib/puppet/metatype/manager.rb +1 -1
  46. data/lib/puppet/module.rb +1 -1
  47. data/lib/puppet/module/task.rb +20 -4
  48. data/lib/puppet/module_tool/applications/installer.rb +1 -1
  49. data/lib/puppet/module_tool/applications/uninstaller.rb +3 -3
  50. data/lib/puppet/module_tool/metadata.rb +1 -1
  51. data/lib/puppet/module_tool/shared_behaviors.rb +4 -4
  52. data/lib/puppet/module_tool/tar/mini.rb +1 -1
  53. data/lib/puppet/network/http/api/indirected_routes.rb +12 -11
  54. data/lib/puppet/network/http/connection.rb +10 -12
  55. data/lib/puppet/network/http/pool.rb +2 -0
  56. data/lib/puppet/network/http/site.rb +1 -1
  57. data/lib/puppet/network/resolver.rb +2 -2
  58. data/lib/puppet/node/environment.rb +4 -2
  59. data/lib/puppet/pal/pal_impl.rb +2 -2
  60. data/lib/puppet/parser/ast.rb +1 -1
  61. data/lib/puppet/parser/ast/resourceparam.rb +1 -1
  62. data/lib/puppet/parser/functions.rb +1 -1
  63. data/lib/puppet/parser/functions/epp.rb +3 -3
  64. data/lib/puppet/parser/functions/inline_epp.rb +5 -5
  65. data/lib/puppet/parser/scope.rb +8 -7
  66. data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +1 -1
  67. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +1 -1
  68. data/lib/puppet/pops/evaluator/external_syntax_support.rb +3 -2
  69. data/lib/puppet/pops/evaluator/runtime3_support.rb +4 -4
  70. data/lib/puppet/pops/loader/task_instantiator.rb +4 -0
  71. data/lib/puppet/pops/loaders.rb +1 -1
  72. data/lib/puppet/pops/lookup/hiera_config.rb +1 -0
  73. data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
  74. data/lib/puppet/pops/merge_strategy.rb +22 -18
  75. data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
  76. data/lib/puppet/pops/parser/interpolation_support.rb +4 -4
  77. data/lib/puppet/pops/parser/locator.rb +1 -1
  78. data/lib/puppet/pops/parser/pn_parser.rb +17 -16
  79. data/lib/puppet/pops/puppet_stack.rb +51 -49
  80. data/lib/puppet/pops/types/p_sensitive_type.rb +1 -1
  81. data/lib/puppet/pops/types/string_converter.rb +10 -10
  82. data/lib/puppet/pops/types/types.rb +3 -3
  83. data/lib/puppet/property.rb +1 -1
  84. data/lib/puppet/property/ensure.rb +1 -1
  85. data/lib/puppet/provider/exec.rb +6 -2
  86. data/lib/puppet/provider/nameservice/directoryservice.rb +1 -1
  87. data/lib/puppet/provider/nameservice/pw.rb +2 -2
  88. data/lib/puppet/provider/package/apt.rb +5 -1
  89. data/lib/puppet/provider/package/dnfmodule.rb +87 -0
  90. data/lib/puppet/provider/package/dpkg.rb +34 -18
  91. data/lib/puppet/provider/package/openbsd.rb +1 -1
  92. data/lib/puppet/provider/package/pip.rb +34 -9
  93. data/lib/puppet/provider/package/portage.rb +4 -4
  94. data/lib/puppet/provider/package/rpm.rb +5 -5
  95. data/lib/puppet/provider/package/windows/package.rb +1 -1
  96. data/lib/puppet/provider/package/yum.rb +1 -1
  97. data/lib/puppet/provider/package_targetable.rb +5 -4
  98. data/lib/puppet/provider/parsedfile.rb +1 -1
  99. data/lib/puppet/provider/service/daemontools.rb +9 -9
  100. data/lib/puppet/provider/service/openbsd.rb +1 -1
  101. data/lib/puppet/provider/service/rcng.rb +2 -2
  102. data/lib/puppet/provider/service/runit.rb +2 -8
  103. data/lib/puppet/provider/service/systemd.rb +9 -9
  104. data/lib/puppet/provider/user/directoryservice.rb +1 -1
  105. data/lib/puppet/provider/user/hpux.rb +1 -1
  106. data/lib/puppet/provider/user/user_role_add.rb +1 -1
  107. data/lib/puppet/provider/user/useradd.rb +22 -13
  108. data/lib/puppet/provider/user/windows_adsi.rb +4 -5
  109. data/lib/puppet/reference/indirection.rb +2 -2
  110. data/lib/puppet/reference/metaparameter.rb +1 -3
  111. data/lib/puppet/reference/providers.rb +1 -3
  112. data/lib/puppet/reference/type.rb +3 -9
  113. data/lib/puppet/reports.rb +1 -1
  114. data/lib/puppet/resource.rb +1 -1
  115. data/lib/puppet/resource/catalog.rb +1 -1
  116. data/lib/puppet/settings.rb +3 -3
  117. data/lib/puppet/settings/environment_conf.rb +1 -0
  118. data/lib/puppet/ssl/host.rb +1 -1
  119. data/lib/puppet/ssl/oids.rb +1 -1
  120. data/lib/puppet/transaction.rb +33 -11
  121. data/lib/puppet/transaction/report.rb +1 -1
  122. data/lib/puppet/type.rb +2 -4
  123. data/lib/puppet/type/exec.rb +7 -3
  124. data/lib/puppet/type/file.rb +1 -2
  125. data/lib/puppet/type/file/data_sync.rb +5 -1
  126. data/lib/puppet/type/group.rb +4 -2
  127. data/lib/puppet/type/notify.rb +3 -2
  128. data/lib/puppet/type/package.rb +10 -3
  129. data/lib/puppet/type/schedule.rb +1 -1
  130. data/lib/puppet/type/service.rb +1 -1
  131. data/lib/puppet/type/user.rb +4 -2
  132. data/lib/puppet/util.rb +35 -12
  133. data/lib/puppet/util/command_line/trollop.rb +1 -1
  134. data/lib/puppet/util/http_proxy.rb +8 -14
  135. data/lib/puppet/util/log.rb +2 -2
  136. data/lib/puppet/util/log/destinations.rb +2 -2
  137. data/lib/puppet/util/logging.rb +32 -20
  138. data/lib/puppet/util/metric.rb +2 -2
  139. data/lib/puppet/util/provider_features.rb +2 -4
  140. data/lib/puppet/util/rdoc.rb +1 -1
  141. data/lib/puppet/util/reference.rb +1 -1
  142. data/lib/puppet/util/resource_template.rb +1 -1
  143. data/lib/puppet/util/selinux.rb +3 -1
  144. data/lib/puppet/util/windows/adsi.rb +48 -18
  145. data/lib/puppet/util/windows/registry.rb +7 -5
  146. data/lib/puppet/vendor.rb +1 -1
  147. data/lib/puppet/version.rb +1 -1
  148. data/lib/puppet/x509/cert_provider.rb +13 -6
  149. data/locales/puppet.pot +199 -159
  150. data/man/man5/puppet.conf.5 +35 -5
  151. data/man/man8/puppet-agent.8 +1 -1
  152. data/man/man8/puppet-apply.8 +1 -1
  153. data/man/man8/puppet-catalog.8 +1 -1
  154. data/man/man8/puppet-config.8 +1 -1
  155. data/man/man8/puppet-describe.8 +1 -1
  156. data/man/man8/puppet-device.8 +1 -1
  157. data/man/man8/puppet-doc.8 +1 -1
  158. data/man/man8/puppet-epp.8 +1 -1
  159. data/man/man8/puppet-facts.8 +1 -1
  160. data/man/man8/puppet-filebucket.8 +1 -1
  161. data/man/man8/puppet-generate.8 +1 -1
  162. data/man/man8/puppet-help.8 +1 -1
  163. data/man/man8/puppet-key.8 +1 -1
  164. data/man/man8/puppet-lookup.8 +1 -1
  165. data/man/man8/puppet-man.8 +1 -1
  166. data/man/man8/puppet-module.8 +1 -1
  167. data/man/man8/puppet-node.8 +1 -1
  168. data/man/man8/puppet-parser.8 +1 -1
  169. data/man/man8/puppet-plugin.8 +1 -1
  170. data/man/man8/puppet-report.8 +1 -1
  171. data/man/man8/puppet-resource.8 +1 -1
  172. data/man/man8/puppet-script.8 +1 -1
  173. data/man/man8/puppet-ssl.8 +1 -1
  174. data/man/man8/puppet-status.8 +1 -1
  175. data/man/man8/puppet.8 +2 -2
  176. data/spec/fixtures/unit/provider/package/dnfmodule/dnf-module-list-installed.txt +11 -0
  177. data/spec/integration/configurer_spec.rb +52 -0
  178. data/spec/integration/type/notify_spec.rb +46 -0
  179. data/spec/lib/puppet/certificate_factory.rb +2 -2
  180. data/spec/spec_helper.rb +28 -0
  181. data/spec/unit/application/ssl_spec.rb +4 -7
  182. data/spec/unit/configurer_spec.rb +394 -398
  183. data/spec/unit/defaults_spec.rb +4 -4
  184. data/spec/unit/forge/forge_spec.rb +1 -3
  185. data/spec/unit/forge/repository_spec.rb +1 -3
  186. data/spec/unit/indirector/resource/ral_spec.rb +4 -4
  187. data/spec/unit/network/http/connection_spec.rb +119 -145
  188. data/spec/unit/parser/scope_spec.rb +10 -0
  189. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +8 -3
  190. data/spec/unit/pops/loaders/module_loaders_spec.rb +37 -0
  191. data/spec/unit/provider/exec_spec.rb +209 -0
  192. data/spec/unit/provider/package/dnfmodule_spec.rb +186 -0
  193. data/spec/unit/provider/package/dpkg_spec.rb +238 -78
  194. data/spec/unit/provider/package/pip_spec.rb +51 -6
  195. data/spec/unit/provider/package/portage_spec.rb +4 -4
  196. data/spec/unit/provider/package_targetable_spec.rb +60 -0
  197. data/spec/unit/provider/service/daemontools_spec.rb +24 -0
  198. data/spec/unit/provider/service/runit_spec.rb +24 -0
  199. data/spec/unit/provider/service/systemd_spec.rb +25 -25
  200. data/spec/unit/provider/user/hpux_spec.rb +2 -2
  201. data/spec/unit/provider/user/useradd_spec.rb +46 -0
  202. data/spec/unit/ssl/host_spec.rb +0 -5
  203. data/spec/unit/ssl/state_machine_spec.rb +0 -6
  204. data/spec/unit/transaction_spec.rb +46 -0
  205. data/spec/unit/type/exec_spec.rb +6 -12
  206. data/spec/unit/type/file/content_spec.rb +9 -3
  207. data/spec/unit/type/file_spec.rb +9 -4
  208. data/spec/unit/type/package_spec.rb +5 -0
  209. data/spec/unit/util/execution_spec.rb +16 -0
  210. data/spec/unit/util/http_proxy_spec.rb +118 -27
  211. data/spec/unit/util/log/destinations_spec.rb +7 -3
  212. data/spec/unit/util/log_spec.rb +0 -138
  213. data/spec/unit/util/logging_spec.rb +200 -0
  214. data/spec/unit/util/windows/adsi_spec.rb +51 -0
  215. data/spec/unit/x509/cert_provider_spec.rb +24 -4
  216. data/tasks/manpages.rake +1 -0
  217. metadata +12 -10
  218. data/lib/puppet/pops/loader/null_loader.rb +0 -60
  219. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +0 -24
  220. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +0 -24
  221. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_post/should_yield_to_the_block.yml +0 -24
@@ -61,6 +61,6 @@ class Puppet::FileSystem::MemoryFile
61
61
  end
62
62
 
63
63
  def inspect
64
- "<Puppet::FileSystem::MemoryFile:#{to_s}>"
64
+ "<Puppet::FileSystem::MemoryFile:#{self}>"
65
65
  end
66
66
  end
@@ -14,11 +14,12 @@ class Puppet::FileSystem::Posix < Puppet::FileSystem::FileImpl
14
14
  bsize = stream_blksize(this, stream)
15
15
  sa = "".force_encoding('ASCII-8BIT')
16
16
  sb = "".force_encoding('ASCII-8BIT')
17
- begin
17
+ loop do
18
18
  this.read(bsize, sa)
19
19
  stream.read(bsize, sb)
20
20
  return true if sa.empty? && sb.empty?
21
- end while sa == sb
21
+ break if sa != sb
22
+ end
22
23
  false
23
24
  end
24
25
  end
@@ -58,7 +58,7 @@ class Puppet::Forge < SemanticPuppet::Dependency::Source
58
58
  matches = []
59
59
  uri = "/v3/modules?query=#{term}"
60
60
  if Puppet[:module_groups]
61
- uri += "&module_groups=#{Puppet[:module_groups].gsub('+', ' ')}"
61
+ uri += "&module_groups=#{Puppet[:module_groups].tr('+', ' ')}"
62
62
  end
63
63
 
64
64
  while uri
@@ -94,7 +94,7 @@ class Puppet::Forge < SemanticPuppet::Dependency::Source
94
94
  name = input.tr('/', '-')
95
95
  uri = "/v3/releases?module=#{name}&sort_by=version&exclude_fields=#{MODULE_RELEASE_EXCLUSIONS}"
96
96
  if Puppet[:module_groups]
97
- uri += "&module_groups=#{Puppet[:module_groups].gsub('+', ' ')}"
97
+ uri += "&module_groups=#{Puppet[:module_groups].tr('+', ' ')}"
98
98
  end
99
99
  releases = []
100
100
 
@@ -239,6 +239,6 @@ class Puppet::Forge < SemanticPuppet::Dependency::Source
239
239
  def decode_uri(uri)
240
240
  return if uri.nil?
241
241
 
242
- URI.decode(uri.gsub('+', ' '))
242
+ URI.decode(uri.tr('+', ' '))
243
243
  end
244
244
  end
@@ -624,8 +624,7 @@ module Puppet::Functions
624
624
  # Get location to use in case of error - this produces ruby filename and where call to 'type' occurred
625
625
  # but strips off the rest of the internal "where" as it is not meaningful to user.
626
626
  #
627
- rb_location = caller[0]
628
-
627
+ rb_location = caller(1, 1).first
629
628
  begin
630
629
  result = parser.parse_string("type #{assignment_string}", nil)
631
630
  rescue StandardError => e
@@ -23,8 +23,8 @@
23
23
  #
24
24
  # @example Camelcase of strings in an Array
25
25
  # ```puppet
26
- # ['abc_def', 'bcd_xyz'].capitalize()
27
- # capitalize(['abc_def', 'bcd_xyz'])
26
+ # ['abc_def', 'bcd_xyz'].camelcase()
27
+ # camelcase(['abc_def', 'bcd_xyz'])
28
28
  # ```
29
29
  # Would both result in `['AbcDef', 'BcdXyz']`
30
30
  #
@@ -6,12 +6,12 @@
6
6
  # The first argument to this function should be a `<MODULE NAME>/<TEMPLATE FILE>`
7
7
  # reference, which loads `<TEMPLATE FILE>` from `<MODULE NAME>`'s `templates`
8
8
  # directory. In most cases, the last argument is optional; if used, it should be a
9
- # [hash](/puppet/latest/reference/lang_data_hash.html) that contains parameters to
9
+ # [hash](https://puppet.com/docs/puppet/latest/lang_data_hash.html) that contains parameters to
10
10
  # pass to the template.
11
11
  #
12
- # - See the [template](/puppet/latest/reference/lang_template.html) documentation
13
- # for general template usage information.
14
- # - See the [EPP syntax](/puppet/latest/reference/lang_template_epp.html)
12
+ # - See the [template](https://puppet.com/docs/puppet/latest/lang_template.html)
13
+ # documentation for general template usage information.
14
+ # - See the [EPP syntax](https://puppet.com/docs/puppet/latest/lang_template_epp.html)
15
15
  # documentation for examples of EPP.
16
16
  #
17
17
  # For example, to call the apache module's `templates/vhost/_docroot.epp`
@@ -1,19 +1,19 @@
1
1
  # Finds an existing file from a module and returns its path.
2
2
  #
3
- # The argument to this function should be a String as a `<MODULE NAME>/<FILE>`
4
- # reference, which will search for `<FILE>` relative to a module's `files`
3
+ # This function accepts an argument that is a String as a `<MODULE NAME>/<FILE>`
4
+ # reference, which searches for `<FILE>` relative to a module's `files`
5
5
  # directory. (For example, the reference `mysql/mysqltuner.pl` will search for the
6
6
  # file `<MODULES DIRECTORY>/mysql/files/mysqltuner.pl`.)
7
7
  #
8
8
  # This function can also accept:
9
- #
10
- # * An absolute String path, which will check for the existence of a file from anywhere on disk.
11
- # * Multiple String arguments, which will return the path of the **first** file
12
- # found, skipping non existing files.
13
- # * An array of string paths, which will return the path of the **first** file
14
- # found from the given paths in the array, skipping non existing files.
15
9
  #
16
- # The function returns `undef` if none of the given paths were found
10
+ # * An absolute String path, which checks for the existence of a file from anywhere on disk.
11
+ # * Multiple String arguments, which returns the path of the **first** file
12
+ # found, skipping nonexistent files.
13
+ # * An array of string paths, which returns the path of the **first** file
14
+ # found from the given paths in the array, skipping nonexistent files.
15
+ #
16
+ # The function returns `undef` if none of the given paths were found.
17
17
  #
18
18
  # @since 4.8.0
19
19
  #
@@ -5,12 +5,12 @@
5
5
  #
6
6
  # The first argument to this function should be a string containing an EPP
7
7
  # template. In most cases, the last argument is optional; if used, it should be a
8
- # [hash](/puppet/latest/reference/lang_data_hash.html) that contains parameters to
8
+ # [hash](https://puppet.com/docs/puppet/latest/lang_data_hash.html) that contains parameters to
9
9
  # pass to the template.
10
10
  #
11
- # - See the [template](/puppet/latest/reference/lang_template.html) documentation
12
- # for general template usage information.
13
- # - See the [EPP syntax](/puppet/latest/reference/lang_template_epp.html)
11
+ # - See the [template](https://puppet.com/docs/puppet/latest/lang_template.html)
12
+ # documentation for general template usage information.
13
+ # - See the [EPP syntax](https://puppet.com/docs/puppet/latest/lang_template_epp.html)
14
14
  # documentation for examples of EPP.
15
15
  #
16
16
  # For example, to evaluate an inline EPP template and pass it the `docroot` and
@@ -28,7 +28,7 @@
28
28
  # `inline_epp` function fails to pass any required parameter.
29
29
  #
30
30
  # An inline EPP template should be written as a single-quoted string or
31
- # [heredoc](/puppet/latest/reference/lang_data_string.html#heredocs).
31
+ # [heredoc](https://puppet.com/docs/puppet/latest/lang_data_string.html#heredocs).
32
32
  # A double-quoted string is subject to expression interpolation before the string
33
33
  # is parsed as an EPP template.
34
34
  #
@@ -11,7 +11,7 @@ module Puppet::ModuleTranslations
11
11
  modules.each do |mod|
12
12
  next unless mod.forge_name && mod.has_translations?(Puppet::GettextConfig.current_locale)
13
13
 
14
- module_name = mod.forge_name.gsub('/', '-')
14
+ module_name = mod.forge_name.tr('/', '-')
15
15
  if Puppet::GettextConfig.load_translations(module_name, mod.locale_directory, :po)
16
16
  Puppet.debug "Loaded translations for #{module_name}."
17
17
  elsif Puppet::GettextConfig.gettext_loaded?
@@ -213,8 +213,8 @@ class Puppet::Graph::RbTreeMap
213
213
  :color => @color,
214
214
  }
215
215
  }
216
- h.merge!(:left => left.to_hash) if @left
217
- h.merge!(:right => right.to_hash) if @right
216
+ h[:left] = left.to_hash if @left
217
+ h[:right] = right.to_hash if @right
218
218
  h
219
219
  end
220
220
 
@@ -133,11 +133,12 @@ class Puppet::Graph::SimpleGraph
133
133
  else
134
134
  if s[:lowlink][vertex] == s[:index][vertex] then
135
135
  this_scc = []
136
- begin
136
+ loop do
137
137
  top = s[:stack].pop
138
138
  s[:seen][top] = false
139
139
  this_scc << top
140
- end until top == vertex
140
+ break if top == vertex
141
+ end
141
142
  s[:scc] << this_scc
142
143
  end
143
144
  recur.pop # done with this node, finally.
@@ -437,7 +438,7 @@ class Puppet::Graph::SimpleGraph
437
438
  # rdot.rb. If an edge or vertex label is a kind of Hash then the keys
438
439
  # which match +dot+ properties will be used as well.
439
440
  def to_dot_graph(params = {})
440
- params['name'] ||= self.class.name.gsub(/:/,'_')
441
+ params['name'] ||= self.class.name.tr(':','_')
441
442
  fontsize = params['fontsize'] ? params['fontsize'] : '8'
442
443
  graph = (directed? ? DOT::DOTDigraph : DOT::DOTSubgraph).new(params)
443
444
  edge_klass = directed? ? DOT::DOTDirectedEdge : DOT::DOTEdge
@@ -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 = {}
@@ -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
@@ -96,7 +96,7 @@ class Puppet::Interface
96
96
  if Puppet::Interface::FaceCollection[name, :current]
97
97
  raise Puppet::Error, "Could not find version #{version} of #{name}"
98
98
  else
99
- raise Puppet::Error, "Could not find Puppet Face #{name.to_s}"
99
+ raise Puppet::Error, "Could not find Puppet Face #{name}"
100
100
  end
101
101
  end
102
102
 
@@ -234,4 +234,5 @@ class Puppet::Interface
234
234
  define_method(name, proc)
235
235
  instance_method(name)
236
236
  end
237
+ private_class_method :__add_method
237
238
  end
@@ -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))
@@ -203,7 +203,7 @@ class Puppet::Module
203
203
  @metadata = data = read_metadata
204
204
  return if data.empty?
205
205
 
206
- @forge_name = data['name'].gsub('-', '/') if data['name']
206
+ @forge_name = data['name'].tr('-', '/') if data['name']
207
207
 
208
208
  [:source, :author, :version, :license, :dependencies].each do |attr|
209
209
  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'] })
@@ -303,7 +303,7 @@ module Puppet::ModuleTool
303
303
  @environment.modules_by_path[options[:target_dir]].each do |mod|
304
304
  if mod.has_metadata?
305
305
  metadata = {
306
- :name => mod.forge_name.gsub('/', '-'),
306
+ :name => mod.forge_name.tr('/', '-'),
307
307
  :version => mod.version
308
308
  }
309
309
  next if release[:module] == metadata[:name]
@@ -52,7 +52,7 @@ module Puppet::ModuleTool
52
52
 
53
53
  def find_installed_module
54
54
  @environment.modules_by_path.values.flatten.each do |mod|
55
- mod_name = (mod.forge_name || mod.name).gsub('/', '-')
55
+ mod_name = (mod.forge_name || mod.name).tr('/', '-')
56
56
  if mod_name == @name
57
57
  @unfiltered << {
58
58
  :name => mod_name,
@@ -101,7 +101,7 @@ module Puppet::ModuleTool
101
101
  if mod.has_metadata? && !changes.empty?
102
102
  raise LocalChangesError,
103
103
  :action => :uninstall,
104
- :module_name => (mod.forge_name || mod.name).gsub('/', '-'),
104
+ :module_name => (mod.forge_name || mod.name).tr('/', '-'),
105
105
  :requested_version => @options[:version],
106
106
  :installed_version => mod.version
107
107
  end
@@ -109,7 +109,7 @@ module Puppet::ModuleTool
109
109
 
110
110
  if !@options[:force] && !mod.required_by.empty?
111
111
  raise ModuleIsRequiredError,
112
- :module_name => (mod.forge_name || mod.name).gsub('/', '-'),
112
+ :module_name => (mod.forge_name || mod.name).tr('/', '-'),
113
113
  :required_by => mod.required_by,
114
114
  :requested_version => @options[:version],
115
115
  :installed_version => mod.version
@@ -102,7 +102,7 @@ module Puppet::ModuleTool
102
102
 
103
103
  contents = data.keys.map do |k|
104
104
  value = (Puppet::Util::Json.dump(data[k], :pretty => true) rescue data[k].to_json)
105
- %Q("#{k.to_s}": #{value})
105
+ %Q("#{k}": #{value})
106
106
  end
107
107
 
108
108
  "{\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}"
@@ -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.
@@ -253,20 +264,10 @@ class Puppet::Network::HTTP::API::IndirectedRoutes
253
264
  method
254
265
  end
255
266
 
256
- def self.request_to_uri(request)
257
- uri, body = request_to_uri_and_body(request)
258
- "#{uri}?#{body}"
259
- end
260
-
261
- def self.request_to_uri_and_body(request)
262
- url_prefix = IndirectionType.url_prefix_for(request.indirection_name.to_s)
263
- indirection = request.method == :search ? pluralize(request.indirection_name.to_s) : request.indirection_name.to_s
264
- ["#{url_prefix}/#{indirection}/#{Puppet::Util.uri_encode(request.key)}", "environment=#{request.environment.name}&#{request.query_string}"]
265
- end
266
-
267
267
  def self.pluralize(indirection)
268
268
  return(indirection == "status" ? "statuses" : indirection + "s")
269
269
  end
270
+ private_class_method :pluralize
270
271
 
271
272
  def plurality(indirection)
272
273
  # 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)