puppet 6.6.0-x86-mingw32 → 6.7.0-x86-mingw32

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 (254) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +8 -8
  3. data/ext/solaris/smf/puppet.xml +2 -0
  4. data/ext/yaml_nodes.rb +7 -7
  5. data/lib/hiera_puppet.rb +2 -1
  6. data/lib/puppet/application/apply.rb +2 -3
  7. data/lib/puppet/application/doc.rb +2 -1
  8. data/lib/puppet/application/face_base.rb +22 -15
  9. data/lib/puppet/application/script.rb +4 -6
  10. data/lib/puppet/configurer.rb +10 -5
  11. data/lib/puppet/confine_collection.rb +2 -1
  12. data/lib/puppet/daemon.rb +3 -2
  13. data/lib/puppet/defaults.rb +8 -0
  14. data/lib/puppet/environments.rb +9 -7
  15. data/lib/puppet/etc.rb +1 -1
  16. data/lib/puppet/external/pson/pure/parser.rb +2 -1
  17. data/lib/puppet/face/epp.rb +4 -2
  18. data/lib/puppet/face/help.rb +3 -2
  19. data/lib/puppet/face/module/changes.rb +2 -1
  20. data/lib/puppet/file_bucket/dipper.rb +2 -1
  21. data/lib/puppet/file_serving/configuration.rb +2 -1
  22. data/lib/puppet/file_serving/fileset.rb +1 -1
  23. data/lib/puppet/file_serving/http_metadata.rb +4 -2
  24. data/lib/puppet/file_serving/metadata.rb +2 -1
  25. data/lib/puppet/file_serving/mount/file.rb +2 -1
  26. data/lib/puppet/file_serving/mount/locales.rb +2 -1
  27. data/lib/puppet/file_serving/mount/modules.rb +4 -2
  28. data/lib/puppet/file_serving/mount/pluginfacts.rb +2 -1
  29. data/lib/puppet/file_serving/mount/plugins.rb +2 -1
  30. data/lib/puppet/file_serving/mount/tasks.rb +4 -2
  31. data/lib/puppet/file_system/uniquefile.rb +4 -2
  32. data/lib/puppet/functions/match.rb +2 -3
  33. data/lib/puppet/generate/type.rb +2 -1
  34. data/lib/puppet/graph/relationship_graph.rb +2 -1
  35. data/lib/puppet/graph/simple_graph.rb +3 -2
  36. data/lib/puppet/indirector/catalog/compiler.rb +16 -8
  37. data/lib/puppet/indirector/certificate/rest.rb +2 -1
  38. data/lib/puppet/indirector/face.rb +2 -2
  39. data/lib/puppet/indirector/file_server.rb +4 -2
  40. data/lib/puppet/indirector/indirection.rb +12 -6
  41. data/lib/puppet/indirector/node/exec.rb +2 -1
  42. data/lib/puppet/indirector/report/processor.rb +2 -1
  43. data/lib/puppet/indirector/request.rb +9 -5
  44. data/lib/puppet/indirector/ssl_file.rb +10 -8
  45. data/lib/puppet/indirector/terminus.rb +6 -3
  46. data/lib/puppet/info_service.rb +9 -0
  47. data/lib/puppet/info_service/plan_information_service.rb +36 -0
  48. data/lib/puppet/interface.rb +2 -1
  49. data/lib/puppet/interface/action.rb +10 -5
  50. data/lib/puppet/interface/action_manager.rb +2 -1
  51. data/lib/puppet/interface/documentation.rb +10 -7
  52. data/lib/puppet/interface/face_collection.rb +6 -3
  53. data/lib/puppet/interface/option.rb +4 -2
  54. data/lib/puppet/interface/option_manager.rb +4 -2
  55. data/lib/puppet/module.rb +35 -1
  56. data/lib/puppet/module/plan.rb +160 -0
  57. data/lib/puppet/module_tool.rb +2 -1
  58. data/lib/puppet/module_tool/applications/application.rb +2 -1
  59. data/lib/puppet/module_tool/applications/installer.rb +4 -2
  60. data/lib/puppet/module_tool/applications/upgrader.rb +4 -2
  61. data/lib/puppet/module_tool/contents_description.rb +2 -1
  62. data/lib/puppet/module_tool/metadata.rb +2 -3
  63. data/lib/puppet/module_tool/shared_behaviors.rb +2 -1
  64. data/lib/puppet/network/authconfig.rb +4 -2
  65. data/lib/puppet/network/authstore.rb +2 -1
  66. data/lib/puppet/network/formats.rb +2 -1
  67. data/lib/puppet/network/http/api/indirected_routes.rb +6 -4
  68. data/lib/puppet/network/http/handler.rb +2 -1
  69. data/lib/puppet/network/http/request.rb +2 -1
  70. data/lib/puppet/network/http/route.rb +2 -1
  71. data/lib/puppet/network/resolver.rb +3 -2
  72. data/lib/puppet/network/rights.rb +2 -1
  73. data/lib/puppet/node.rb +8 -4
  74. data/lib/puppet/pal/catalog_compiler.rb +8 -1
  75. data/lib/puppet/pal/compiler.rb +2 -1
  76. data/lib/puppet/pal/pal_impl.rb +8 -0
  77. data/lib/puppet/pal/script_compiler.rb +4 -2
  78. data/lib/puppet/parameter.rb +4 -2
  79. data/lib/puppet/parameter/value_collection.rb +8 -8
  80. data/lib/puppet/parser/ast/pops_bridge.rb +2 -1
  81. data/lib/puppet/parser/compiler.rb +10 -5
  82. data/lib/puppet/parser/files.rb +2 -1
  83. data/lib/puppet/parser/functions.rb +2 -1
  84. data/lib/puppet/parser/relationship.rb +2 -1
  85. data/lib/puppet/parser/resource.rb +6 -3
  86. data/lib/puppet/parser/scope.rb +6 -4
  87. data/lib/puppet/parser/templatewrapper.rb +2 -1
  88. data/lib/puppet/parser/type_loader.rb +2 -1
  89. data/lib/puppet/pops/adaptable.rb +2 -5
  90. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +2 -1
  91. data/lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb +2 -1
  92. data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +2 -1
  93. data/lib/puppet/pops/evaluator/runtime3_support.rb +8 -4
  94. data/lib/puppet/pops/loader/base_loader.rb +4 -2
  95. data/lib/puppet/pops/loader/dependency_loader.rb +4 -2
  96. data/lib/puppet/pops/loader/gem_support.rb +4 -2
  97. data/lib/puppet/pops/loader/loader.rb +4 -2
  98. data/lib/puppet/pops/loader/loader_paths.rb +2 -1
  99. data/lib/puppet/pops/loader/static_loader.rb +1 -1
  100. data/lib/puppet/pops/lookup/interpolation.rb +2 -1
  101. data/lib/puppet/pops/model/factory.rb +4 -2
  102. data/lib/puppet/pops/parser/epp_support.rb +2 -1
  103. data/lib/puppet/pops/parser/heredoc_support.rb +2 -1
  104. data/lib/puppet/pops/parser/interpolation_support.rb +10 -5
  105. data/lib/puppet/pops/parser/lexer2.rb +6 -3
  106. data/lib/puppet/pops/parser/locator.rb +2 -1
  107. data/lib/puppet/pops/types/type_calculator.rb +1 -1
  108. data/lib/puppet/pops/types/type_parser.rb +4 -2
  109. data/lib/puppet/pops/validation.rb +2 -1
  110. data/lib/puppet/pops/validation/checker4_0.rb +6 -3
  111. data/lib/puppet/pops/visitor.rb +12 -6
  112. data/lib/puppet/property.rb +19 -16
  113. data/lib/puppet/property/ensure.rb +2 -1
  114. data/lib/puppet/property/keyvalue.rb +2 -1
  115. data/lib/puppet/property/list.rb +2 -1
  116. data/lib/puppet/provider.rb +10 -8
  117. data/lib/puppet/provider/exec.rb +7 -4
  118. data/lib/puppet/provider/file/posix.rb +6 -3
  119. data/lib/puppet/provider/group/groupadd.rb +2 -1
  120. data/lib/puppet/provider/group/ldap.rb +7 -4
  121. data/lib/puppet/provider/group/pw.rb +4 -2
  122. data/lib/puppet/provider/ldap.rb +8 -4
  123. data/lib/puppet/provider/nameservice.rb +8 -5
  124. data/lib/puppet/provider/nameservice/directoryservice.rb +8 -4
  125. data/lib/puppet/provider/network_device.rb +4 -2
  126. data/lib/puppet/provider/package.rb +2 -1
  127. data/lib/puppet/provider/package/aix.rb +4 -2
  128. data/lib/puppet/provider/package/appdmg.rb +4 -2
  129. data/lib/puppet/provider/package/apple.rb +2 -1
  130. data/lib/puppet/provider/package/apt.rb +4 -2
  131. data/lib/puppet/provider/package/blastwave.rb +2 -1
  132. data/lib/puppet/provider/package/dpkg.rb +6 -3
  133. data/lib/puppet/provider/package/fink.rb +2 -1
  134. data/lib/puppet/provider/package/gem.rb +4 -2
  135. data/lib/puppet/provider/package/macports.rb +6 -3
  136. data/lib/puppet/provider/package/nim.rb +8 -4
  137. data/lib/puppet/provider/package/openbsd.rb +14 -8
  138. data/lib/puppet/provider/package/opkg.rb +2 -1
  139. data/lib/puppet/provider/package/pacman.rb +2 -1
  140. data/lib/puppet/provider/package/pip.rb +2 -1
  141. data/lib/puppet/provider/package/pkgdmg.rb +4 -2
  142. data/lib/puppet/provider/package/pkgng.rb +4 -2
  143. data/lib/puppet/provider/package/pkgutil.rb +2 -1
  144. data/lib/puppet/provider/package/portupgrade.rb +2 -1
  145. data/lib/puppet/provider/package/rpm.rb +8 -4
  146. data/lib/puppet/provider/package/windows/package.rb +2 -1
  147. data/lib/puppet/provider/parsedfile.rb +14 -7
  148. data/lib/puppet/provider/service/base.rb +7 -4
  149. data/lib/puppet/provider/service/launchd.rb +4 -2
  150. data/lib/puppet/provider/service/service.rb +2 -1
  151. data/lib/puppet/provider/service/upstart.rb +11 -8
  152. data/lib/puppet/provider/user/directoryservice.rb +2 -1
  153. data/lib/puppet/provider/user/hpux.rb +1 -1
  154. data/lib/puppet/provider/user/ldap.rb +8 -4
  155. data/lib/puppet/provider/user/openbsd.rb +2 -1
  156. data/lib/puppet/provider/user/pw.rb +2 -1
  157. data/lib/puppet/provider/user/user_role_add.rb +4 -2
  158. data/lib/puppet/provider/user/useradd.rb +7 -4
  159. data/lib/puppet/reference/providers.rb +2 -3
  160. data/lib/puppet/reference/type.rb +4 -2
  161. data/lib/puppet/relationship.rb +4 -9
  162. data/lib/puppet/resource.rb +16 -9
  163. data/lib/puppet/resource/capability_finder.rb +12 -8
  164. data/lib/puppet/resource/catalog.rb +36 -40
  165. data/lib/puppet/resource/type.rb +7 -3
  166. data/lib/puppet/resource/type_collection.rb +4 -2
  167. data/lib/puppet/settings.rb +36 -19
  168. data/lib/puppet/settings/base_setting.rb +2 -1
  169. data/lib/puppet/settings/config_file.rb +2 -1
  170. data/lib/puppet/settings/file_setting.rb +2 -1
  171. data/lib/puppet/settings/ini_file.rb +2 -1
  172. data/lib/puppet/ssl/base.rb +2 -1
  173. data/lib/puppet/ssl/host.rb +16 -8
  174. data/lib/puppet/ssl/key.rb +2 -2
  175. data/lib/puppet/ssl/state_machine.rb +22 -3
  176. data/lib/puppet/transaction/event.rb +2 -1
  177. data/lib/puppet/transaction/event_manager.rb +4 -2
  178. data/lib/puppet/transaction/report.rb +10 -10
  179. data/lib/puppet/transaction/resource_harness.rb +4 -2
  180. data/lib/puppet/type.rb +84 -48
  181. data/lib/puppet/type/component.rb +2 -1
  182. data/lib/puppet/type/exec.rb +11 -7
  183. data/lib/puppet/type/file.rb +15 -9
  184. data/lib/puppet/type/file/content.rb +7 -3
  185. data/lib/puppet/type/file/ctime.rb +2 -1
  186. data/lib/puppet/type/file/data_sync.rb +2 -1
  187. data/lib/puppet/type/file/ensure.rb +10 -7
  188. data/lib/puppet/type/file/mode.rb +2 -1
  189. data/lib/puppet/type/file/mtime.rb +2 -1
  190. data/lib/puppet/type/file/selcontext.rb +2 -1
  191. data/lib/puppet/type/file/source.rb +6 -7
  192. data/lib/puppet/type/file/target.rb +2 -1
  193. data/lib/puppet/type/file/type.rb +2 -1
  194. data/lib/puppet/type/package.rb +6 -3
  195. data/lib/puppet/type/resources.rb +2 -1
  196. data/lib/puppet/type/service.rb +2 -1
  197. data/lib/puppet/type/tidy.rb +14 -7
  198. data/lib/puppet/type/user.rb +19 -7
  199. data/lib/puppet/util.rb +6 -3
  200. data/lib/puppet/util/checksums.rb +1 -1
  201. data/lib/puppet/util/classgen.rb +12 -6
  202. data/lib/puppet/util/command_line.rb +8 -4
  203. data/lib/puppet/util/connection.rb +4 -2
  204. data/lib/puppet/util/diff.rb +4 -2
  205. data/lib/puppet/util/execution.rb +4 -2
  206. data/lib/puppet/util/feature.rb +7 -4
  207. data/lib/puppet/util/fileparsing.rb +57 -46
  208. data/lib/puppet/util/filetype.rb +2 -1
  209. data/lib/puppet/util/http_proxy.rb +2 -1
  210. data/lib/puppet/util/instance_loader.rb +2 -1
  211. data/lib/puppet/util/ldap/connection.rb +4 -2
  212. data/lib/puppet/util/ldap/manager.rb +6 -3
  213. data/lib/puppet/util/log.rb +6 -3
  214. data/lib/puppet/util/metric.rb +2 -1
  215. data/lib/puppet/util/posix.rb +4 -2
  216. data/lib/puppet/util/rdoc/code_objects.rb +2 -1
  217. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +4 -2
  218. data/lib/puppet/util/selinux.rb +2 -1
  219. data/lib/puppet/version.rb +2 -5
  220. data/locales/puppet.pot +713 -685
  221. data/man/man5/puppet.conf.5 +9 -2
  222. data/man/man8/puppet-agent.8 +1 -1
  223. data/man/man8/puppet-apply.8 +1 -1
  224. data/man/man8/puppet-catalog.8 +1 -1
  225. data/man/man8/puppet-config.8 +1 -1
  226. data/man/man8/puppet-describe.8 +1 -1
  227. data/man/man8/puppet-device.8 +1 -1
  228. data/man/man8/puppet-doc.8 +1 -1
  229. data/man/man8/puppet-epp.8 +1 -1
  230. data/man/man8/puppet-facts.8 +1 -1
  231. data/man/man8/puppet-filebucket.8 +1 -1
  232. data/man/man8/puppet-generate.8 +1 -1
  233. data/man/man8/puppet-help.8 +1 -1
  234. data/man/man8/puppet-key.8 +1 -1
  235. data/man/man8/puppet-lookup.8 +1 -1
  236. data/man/man8/puppet-man.8 +1 -1
  237. data/man/man8/puppet-module.8 +1 -1
  238. data/man/man8/puppet-node.8 +1 -1
  239. data/man/man8/puppet-parser.8 +1 -1
  240. data/man/man8/puppet-plugin.8 +1 -1
  241. data/man/man8/puppet-report.8 +1 -1
  242. data/man/man8/puppet-resource.8 +1 -1
  243. data/man/man8/puppet-script.8 +1 -1
  244. data/man/man8/puppet-ssl.8 +1 -1
  245. data/man/man8/puppet-status.8 +1 -1
  246. data/man/man8/puppet.8 +2 -2
  247. data/spec/lib/puppet_spec/modules.rb +16 -2
  248. data/spec/unit/indirector/request_spec.rb +5 -6
  249. data/spec/unit/info_service_spec.rb +48 -0
  250. data/spec/unit/module_spec.rb +73 -0
  251. data/spec/unit/plan_spec.rb +65 -0
  252. data/spec/unit/puppet_pal_catalog_spec.rb +12 -0
  253. data/spec/unit/ssl/state_machine_spec.rb +68 -5
  254. metadata +6 -2
@@ -31,7 +31,8 @@ module Puppet
31
31
  # Return the +username+ and +modname+ for a given +full_module_name+, or raise an
32
32
  # ArgumentError if the argument isn't parseable.
33
33
  def self.username_and_modname_from(full_module_name)
34
- if matcher = full_module_name.match(FULL_MODULE_NAME_PATTERN)
34
+ matcher = full_module_name.match(FULL_MODULE_NAME_PATTERN)
35
+ if matcher
35
36
  return matcher.captures
36
37
  else
37
38
  raise ArgumentError, _("Not a valid full name: %{full_module_name}") % { full_module_name: full_module_name }
@@ -68,7 +68,8 @@ module Puppet::ModuleTool
68
68
  end
69
69
 
70
70
  def parse_filename(filename)
71
- if match = /^((.*?)-(.*?))-(\d+\.\d+\.\d+.*?)$/.match(File.basename(filename, '.tar.gz'))
71
+ match = /^((.*?)-(.*?))-(\d+\.\d+\.\d+.*?)$/.match(File.basename(filename, '.tar.gz'))
72
+ if match
72
73
  module_name, author, shortname, version = match.captures
73
74
  else
74
75
  raise ArgumentError, _("Could not parse filename to obtain the username, module name and version. (%{release_name})") % { release_name: @release_name }
@@ -60,7 +60,8 @@ module Puppet::ModuleTool
60
60
  results = { :action => :install, :module_name => name, :module_version => version }
61
61
 
62
62
  begin
63
- if installed_module = installed_modules[name]
63
+ installed_module = installed_modules[name]
64
+ if installed_module
64
65
  unless forced?
65
66
  if Puppet::Module.parse_range(version).include? installed_module.version
66
67
  results[:result] = :noop
@@ -136,7 +137,8 @@ module Puppet::ModuleTool
136
137
  unless forced?
137
138
  # Check for module name conflicts.
138
139
  releases.each do |rel|
139
- if installed_module = installed_modules_source.by_name[rel.name.split('-').last]
140
+ installed_module = installed_modules_source.by_name[rel.name.split('-').last]
141
+ if installed_module
140
142
  next if installed_module.has_metadata? && installed_module.forge_name.tr('/', '-') == rel.name
141
143
 
142
144
  if rel.name != name
@@ -144,7 +144,8 @@ module Puppet::ModuleTool
144
144
  end
145
145
 
146
146
  releases.each do |rel|
147
- if mod = installed_modules_source.by_name[rel.name.split('-').last]
147
+ mod = installed_modules_source.by_name[rel.name.split('-').last]
148
+ if mod
148
149
  next if mod.has_metadata? && mod.forge_name.tr('/', '-') == rel.name
149
150
 
150
151
  if rel.name != name
@@ -189,7 +190,8 @@ module Puppet::ModuleTool
189
190
 
190
191
  Puppet.notice _('Upgrading -- do not interrupt ...')
191
192
  releases.each do |release|
192
- if installed = installed_modules[release.name]
193
+ installed = installed_modules[release.name]
194
+ if installed
193
195
  release.install(Pathname.new(installed.mod.modulepath))
194
196
  else
195
197
  release.install(dir)
@@ -43,7 +43,8 @@ module Puppet::ModuleTool
43
43
  end
44
44
 
45
45
  type_names.each do |name|
46
- if type = Puppet::Type.type(name.to_sym)
46
+ type = Puppet::Type.type(name.to_sym)
47
+ if type
47
48
  type_hash = {:name => name, :doc => type.doc}
48
49
  type_hash[:properties] = attr_doc(type, :property)
49
50
  type_hash[:parameters] = attr_doc(type, :param)
@@ -66,9 +66,8 @@ module Puppet::ModuleTool
66
66
  validate_name(name)
67
67
  validate_version_range(version_requirement) if version_requirement
68
68
 
69
- if dup = @data['dependencies'].find { |d| d.full_module_name == name && d.version_requirement != version_requirement }
70
- raise ArgumentError, _("Dependency conflict for %{module_name}: Dependency %{name} was given conflicting version requirements %{version_requirement} and %{dup_version}. Verify that there are no duplicates in the metadata.json.") % { module_name: full_module_name, name: name, version_requirement: version_requirement, dup_version: dup.version_requirement }
71
- end
69
+ dup = @data['dependencies'].find { |d| d.full_module_name == name && d.version_requirement != version_requirement }
70
+ raise ArgumentError, _("Dependency conflict for %{module_name}: Dependency %{name} was given conflicting version requirements %{version_requirement} and %{dup_version}. Verify that there are no duplicates in the metadata.json.") % { module_name: full_module_name, name: name, version_requirement: version_requirement, dup_version: dup.version_requirement } if dup
72
71
 
73
72
  dep = Dependency.new(name, version_requirement, repository)
74
73
  @data['dependencies'].add(dep)
@@ -111,7 +111,8 @@ module Puppet::ModuleTool::Shared
111
111
  valid_versions = versions.select { |x| x[:semver].special == '' }
112
112
  valid_versions = versions if valid_versions.empty?
113
113
 
114
- unless version = valid_versions.last
114
+ version = valid_versions.last
115
+ unless version
115
116
  req_module = @module_name
116
117
  req_versions = @versions["#{@module_name}"].map { |v| v[:semver] }
117
118
  raise NoVersionsSatisfyError,
@@ -54,7 +54,8 @@ module Puppet
54
54
  right = @rights.newright(acl[:acl])
55
55
  right.allow(acl[:allow] || "*")
56
56
 
57
- if method = acl[:method]
57
+ method = acl[:method]
58
+ if method
58
59
  method = [method] unless method.is_a?(Array)
59
60
  method.each { |m| right.restrict_method(m) }
60
61
  end
@@ -65,7 +66,8 @@ module Puppet
65
66
  # raise an Puppet::Network::AuthorizedError if the request
66
67
  # is denied.
67
68
  def check_authorization(method, path, params)
68
- if authorization_failure_exception = @rights.is_request_forbidden_and_why?(method, path, params)
69
+ authorization_failure_exception = @rights.is_request_forbidden_and_why?(method, path, params)
70
+ if authorization_failure_exception
69
71
  Puppet.warning(_("Denying access: %{authorization_failure_exception}") % { authorization_failure_exception: authorization_failure_exception })
70
72
  raise authorization_failure_exception
71
73
  end
@@ -29,7 +29,8 @@ module Puppet
29
29
  # yay insecure overrides
30
30
  return true if globalallow?
31
31
 
32
- if decl = declarations.find { |d| d.match?(name, ip) }
32
+ decl = declarations.find { |d| d.match?(name, ip) }
33
+ if decl
33
34
  return decl.result
34
35
  end
35
36
 
@@ -105,7 +105,8 @@ Puppet::Network::FormatHandler.create_serialized_formats(:pson, :weight => 10, :
105
105
  # If they pass class information, we want to ignore it.
106
106
  # This is required for compatibility with Puppet 3.x
107
107
  def data_to_instance(klass, data)
108
- if data.is_a?(Hash) and d = data['data']
108
+ d = data['data'] if data.is_a?(Hash)
109
+ if d
109
110
  data = d
110
111
  end
111
112
  return data if data.is_a?(klass)
@@ -124,7 +124,8 @@ class Puppet::Network::HTTP::API::IndirectedRoutes
124
124
 
125
125
  # Execute our find.
126
126
  def do_find(indirection, key, params, request, response)
127
- unless result = indirection.find(key, params)
127
+ result = indirection.find(key, params)
128
+ unless result
128
129
  raise Puppet::Network::HTTP::Error::HTTPNotFoundError.new(_("Could not find %{value0} %{key}") % { value0: indirection.name, key: key }, Puppet::Network::HTTP::Issues::RESOURCE_NOT_FOUND)
129
130
  end
130
131
 
@@ -245,10 +246,11 @@ class Puppet::Network::HTTP::API::IndirectedRoutes
245
246
  raise Puppet::Network::HTTP::Error::HTTPMethodNotAllowedError.new(
246
247
  _("No support for http method %{http_method}") % { http_method: http_method }) unless METHOD_MAP[http_method]
247
248
 
248
- unless method = METHOD_MAP[http_method][plurality(indirection)]
249
- raise Puppet::Network::HTTP::Error::HTTPBadRequestError.new(
249
+ method = METHOD_MAP[http_method][plurality(indirection)]
250
+ unless method
251
+ raise Puppet::Network::HTTP::Error::HTTPBadRequestError.new(
250
252
  _("No support for plurality %{indirection} for %{http_method} operations") % { indirection: plurality(indirection), http_method: http_method })
251
- end
253
+ end
252
254
 
253
255
  method
254
256
  end
@@ -105,7 +105,8 @@ module Puppet::Network::HTTP::Handler
105
105
  end
106
106
 
107
107
  def find_route_or_raise(request)
108
- if route = @routes.find { |r| r.matches?(request) }
108
+ route = @routes.find { |r| r.matches?(request) }
109
+ if route
109
110
  return route
110
111
  else
111
112
  raise Puppet::Network::HTTP::Error::HTTPNotFoundError.new(
@@ -20,7 +20,8 @@ Puppet::Network::HTTP::Request = Struct.new(:headers, :params, :method, :path, :
20
20
  end
21
21
 
22
22
  def formatter
23
- if header = headers['content-type']
23
+ header = headers['content-type']
24
+ if header
24
25
  header.gsub!(/\s*;.*$/,'') # strip any charset
25
26
  format = Puppet::Network::FormatHandler.mime(header)
26
27
 
@@ -83,7 +83,8 @@ class Puppet::Network::HTTP::Route
83
83
  end
84
84
 
85
85
  subrequest = request.route_into(match(request.routing_path).to_s)
86
- if chained_route = @chained.find { |route| route.matches?(subrequest) }
86
+ chained_route = @chained.find { |route| route.matches?(subrequest) }
87
+ if chained_route
87
88
  chained_route.process(subrequest, response)
88
89
  end
89
90
  end
@@ -71,7 +71,7 @@ module Puppet::Network
71
71
  each_srv_record(domain, :puppet, &block)
72
72
  else
73
73
  each_priority(records) do |recs|
74
- while next_rr = recs.delete(find_weighted_server(recs))
74
+ while next_rr = recs.delete(find_weighted_server(recs)) #rubocop:disable Lint/AssignmentInCondition
75
75
  Puppet.debug "Yielding next server of #{next_rr.target.to_s}:#{next_rr.port}"
76
76
  yield next_rr.target.to_s, next_rr.port
77
77
  end
@@ -125,7 +125,8 @@ module Puppet::Network
125
125
  # @return [Boolean] true if the entry has expired, false otherwise.
126
126
  # Always returns true if the record had no TTL.
127
127
  def expired?(service_name)
128
- if entry = @record_cache[service_name]
128
+ entry = @record_cache[service_name]
129
+ if entry
129
130
  return Time.now > (entry.resolution_time + entry.ttl)
130
131
  else
131
132
  return true
@@ -39,7 +39,8 @@ class Rights
39
39
  # an acl can return :dunno, which means "I'm not qualified to answer your question,
40
40
  # please ask someone else". This is used when for instance an acl matches, but not for the
41
41
  # current rest method, where we might think some other acl might be more specific.
42
- if match = acl.match?(name)
42
+ match = acl.match?(name)
43
+ if match
43
44
  args[:match] = match
44
45
  if (res = acl.allowed?(args[:node], args[:ip], args)) != :dunno
45
46
  # return early if we're allowed
@@ -61,7 +61,8 @@ class Puppet::Node
61
61
  if @environment
62
62
  @environment
63
63
  else
64
- if env = parameters[ENVIRONMENT]
64
+ env = parameters[ENVIRONMENT]
65
+ if env
65
66
  self.environment = env
66
67
  elsif environment_name
67
68
  self.environment = environment_name
@@ -101,7 +102,8 @@ class Puppet::Node
101
102
  raise ArgumentError, _("Node names cannot be nil") unless name
102
103
  @name = name
103
104
 
104
- if classes = options[:classes]
105
+ classes = options[:classes]
106
+ if classes
105
107
  if classes.is_a?(String)
106
108
  @classes = [classes]
107
109
  else
@@ -117,7 +119,8 @@ class Puppet::Node
117
119
 
118
120
  @server_facts = {}
119
121
 
120
- if env = options[:environment]
122
+ env = options[:environment]
123
+ if env
121
124
  self.environment = env
122
125
  end
123
126
 
@@ -187,7 +190,8 @@ class Puppet::Node
187
190
  names += split_name(name) if name.include?(".")
188
191
 
189
192
  # First, get the fqdn
190
- unless fqdn = parameters["fqdn"]
193
+ fqdn = parameters["fqdn"]
194
+ unless fqdn
191
195
  if parameters["hostname"] and parameters["domain"]
192
196
  fqdn = parameters["hostname"] + "." + parameters["domain"]
193
197
  else
@@ -27,7 +27,7 @@ module Pal
27
27
  # @example Get resulting catalog as pretty printed Json
28
28
  # Puppet::Pal.in_environment(...) do |pal|
29
29
  # pal.with_catalog_compiler(...) do |compiler|
30
- # compiler.with_json_encoding {| encoder | encoder.encode
30
+ # compiler.with_json_encoding { |encoder| encoder.encode }
31
31
  # end
32
32
  # end
33
33
  #
@@ -37,6 +37,13 @@ module Pal
37
37
  yield JsonCatalogEncoder.new(catalog, pretty: pretty, exclude_virtual: exclude_virtual)
38
38
  end
39
39
 
40
+ # Returns a hash representation of the compiled catalog.
41
+ #
42
+ # @api public
43
+ def catalog_data_hash
44
+ catalog.to_data_hash
45
+ end
46
+
40
47
  # Evaluates an AST obtained from `parse_string` or `parse_file` in topscope.
41
48
  # If the ast is a `Puppet::Pops::Model::Program` (what is returned from the `parse` methods, any definitions
42
49
  # in the program (that is, any function, plan, etc. that is defined will be made available for use).
@@ -41,7 +41,8 @@ module Pal
41
41
  #
42
42
  def function_signature(function_name)
43
43
  loader = internal_compiler.loaders.private_environment_loader
44
- if func = loader.load(:function, function_name)
44
+ func = loader.load(:function, function_name)
45
+ if func
45
46
  return FunctionSignature.new(func.class)
46
47
  end
47
48
  # Could not find function
@@ -176,6 +176,10 @@ module Pal
176
176
  end
177
177
  end
178
178
 
179
+ # We need to make sure to set these back when we're done
180
+ previous_tasks_value = Puppet[:tasks]
181
+ previous_code_value = Puppet[:code]
182
+
179
183
  Puppet[:tasks] = false
180
184
  # After the assertions, if code_string is non nil - it has the highest precedence
181
185
  Puppet[:code] = code_string unless code_string.nil?
@@ -183,6 +187,10 @@ module Pal
183
187
  # If manifest_file is nil, the #main method will use the env configured manifest
184
188
  # to do things in the block while a Script Compiler is in effect
185
189
  main(manifest_file, facts, variables, :catalog, &block)
190
+ ensure
191
+ # Clean up after ourselves
192
+ Puppet[:tasks] = previous_tasks_value
193
+ Puppet[:code] = previous_code_value
186
194
  end
187
195
 
188
196
  # Defines the context in which to perform puppet operations (evaluation, etc)
@@ -8,7 +8,8 @@ module Pal
8
8
  #
9
9
  def plan_signature(plan_name)
10
10
  loader = internal_compiler.loaders.private_environment_loader
11
- if func = loader.load(:plan, plan_name)
11
+ func = loader.load(:plan, plan_name)
12
+ if func
12
13
  return PlanSignature.new(func)
13
14
  end
14
15
  # Could not find plan
@@ -40,7 +41,8 @@ module Pal
40
41
  #
41
42
  def task_signature(task_name)
42
43
  loader = internal_compiler.loaders.private_environment_loader
43
- if task = loader.load(:task, task_name)
44
+ task = loader.load(:task, task_name)
45
+ if task
44
46
  return TaskSignature.new(task)
45
47
  end
46
48
  # Could not find task
@@ -110,11 +110,13 @@ class Puppet::Parameter
110
110
 
111
111
  unless defined?(@addeddocvals)
112
112
  @doc = Puppet::Util::Docs.scrub(@doc)
113
- if vals = value_collection.doc
113
+ vals = value_collection.doc
114
+ if vals
114
115
  @doc << "\n\n#{vals}"
115
116
  end
116
117
 
117
- if features = self.required_features
118
+ features = self.required_features
119
+ if features
118
120
  @doc << "\n\nRequires features #{features.flatten.collect { |f| f.to_s }.join(" ")}."
119
121
  end
120
122
  @addeddocvals = true
@@ -18,9 +18,8 @@ class Puppet::Parameter::ValueCollection
18
18
  #
19
19
  def aliasvalue(name, other)
20
20
  other = other.to_sym
21
- unless value = match?(other)
22
- raise Puppet::DevError, _("Cannot alias nonexistent value %{value}") % { value: other }
23
- end
21
+ value = match?(other)
22
+ raise Puppet::DevError, _("Cannot alias nonexistent value %{value}") % { value: other } unless value
24
23
 
25
24
  value.alias(name)
26
25
  end
@@ -35,7 +34,8 @@ class Puppet::Parameter::ValueCollection
35
34
  unless values.empty?
36
35
  @doc << "Valid values are "
37
36
  @doc << @strings.collect do |value|
38
- if aliases = value.aliases and ! aliases.empty?
37
+ aliases = value.aliases
38
+ if aliases && ! aliases.empty?
39
39
  "`#{value.name}` (also called `#{aliases.join(", ")}`)"
40
40
  else
41
41
  "`#{value.name}`"
@@ -81,9 +81,8 @@ class Puppet::Parameter::ValueCollection
81
81
  #
82
82
  def match?(test_value)
83
83
  # First look for normal values
84
- if value = @strings.find { |v| v.match?(test_value) }
85
- return value
86
- end
84
+ value = @strings.find { |v| v.match?(test_value) }
85
+ return value if value
87
86
 
88
87
  # Then look for a regex match
89
88
  @regexes.find { |v| v.match?(test_value) }
@@ -100,7 +99,8 @@ class Puppet::Parameter::ValueCollection
100
99
  def munge(value)
101
100
  return value if empty?
102
101
 
103
- if instance = match?(value)
102
+ instance = match?(value)
103
+ if instance
104
104
  if instance.regex?
105
105
  return value
106
106
  else
@@ -176,7 +176,8 @@ class Puppet::Parser::AST::PopsBridge
176
176
  # reused and we may reenter without a scope (which is fine). A debug message is then output in case
177
177
  # there is the need to track down the odd corner case. See {#obtain_scope}.
178
178
  #
179
- if scope = obtain_scope
179
+ scope = obtain_scope
180
+ if scope
180
181
  typed_parameters.each do |p|
181
182
  result[p.name] = @@evaluator.evaluate(scope, p.type_expr)
182
183
  end
@@ -61,7 +61,8 @@ class Puppet::Parser::Compiler
61
61
  # Store a resource override.
62
62
  def add_override(override)
63
63
  # If possible, merge the override in immediately.
64
- if resource = @catalog.resource(override.ref)
64
+ resource = @catalog.resource(override.ref)
65
+ if resource
65
66
  resource.merge(override)
66
67
  else
67
68
  # Otherwise, store the override for later; these
@@ -493,7 +494,8 @@ class Puppet::Parser::Compiler
493
494
  # Now see if we can find the node.
494
495
  astnode = nil
495
496
  @node.names.each do |name|
496
- break if astnode = krt.node(name.to_s.downcase)
497
+ astnode = krt.node(name.to_s.downcase)
498
+ break if astnode
497
499
  end
498
500
 
499
501
  unless (astnode ||= krt.node("default"))
@@ -627,7 +629,8 @@ class Puppet::Parser::Compiler
627
629
 
628
630
  resources.each do |resource|
629
631
  # Add in any resource overrides.
630
- if overrides = resource_overrides(resource)
632
+ overrides = resource_overrides(resource)
633
+ if overrides
631
634
  overrides.each do |over|
632
635
  resource.merge(over)
633
636
  end
@@ -645,7 +648,8 @@ class Puppet::Parser::Compiler
645
648
  protected :finish
646
649
 
647
650
  def add_resource_metaparams
648
- unless main = catalog.resource(:class, :main)
651
+ main = catalog.resource(:class, :main)
652
+ unless main
649
653
  #TRANSLATORS "main" is a function name and should not be translated
650
654
  raise _("Couldn't find main")
651
655
  end
@@ -655,7 +659,8 @@ class Puppet::Parser::Compiler
655
659
  end
656
660
  data = {}
657
661
  catalog.walk(main, :out) do |source, target|
658
- if source_data = data[source] || metaparams_as_data(source, names)
662
+ source_data = data[source] || metaparams_as_data(source, names)
663
+ if source_data
659
664
  # only store anything in the data hash if we've actually got
660
665
  # data
661
666
  data[source] ||= source_data