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
@@ -22,7 +22,8 @@ Puppet::Face.define(:module, '1.0.0') do
22
22
 
23
23
  when_invoked do |path, options|
24
24
  Puppet::ModuleTool.set_option_defaults options
25
- unless root_path = Puppet::ModuleTool.find_module_root(path)
25
+ root_path = Puppet::ModuleTool.find_module_root(path)
26
+ unless root_path
26
27
  raise ArgumentError, _("Could not find a valid module at %{path}") % { path: path.inspect }
27
28
  end
28
29
  Puppet::ModuleTool::Applications::Checksummer.run(root_path, options)
@@ -126,7 +126,8 @@ class Puppet::FileBucket::Dipper
126
126
  end
127
127
 
128
128
  if restore
129
- if newcontents = get_bucket_file(sum)
129
+ newcontents = get_bucket_file(sum)
130
+ if newcontents
130
131
  newsum = newcontents.checksum_data
131
132
  changed = nil
132
133
  if Puppet::FileSystem.exist?(file_handle) and ! Puppet::FileSystem.writable?(file_handle)
@@ -55,7 +55,8 @@ class Puppet::FileServing::Configuration
55
55
  raise(ArgumentError, _("Cannot find file: Invalid mount '%{mount_name}'") % { mount_name: mount_name }) unless mount_name =~ %r{^[-\w]+$}
56
56
  raise(ArgumentError, _("Cannot find file: Invalid relative path '%{path}'") % { path: path }) if path and path.split('/').include?('..')
57
57
 
58
- return nil unless mount = find_mount(mount_name, request.environment)
58
+ mount = find_mount(mount_name, request.environment)
59
+ return nil unless mount
59
60
  if mount.name == "modules" and mount_name != "modules"
60
61
  # yay backward-compatibility
61
62
  path = "#{mount_name}/#{path}"
@@ -148,7 +148,7 @@ class Puppet::FileServing::Fileset
148
148
 
149
149
  result = []
150
150
 
151
- while entry = current_dirs.shift
151
+ while entry = current_dirs.shift #rubocop:disable Lint/AssignmentInCondition
152
152
  if continue_recursion_at?(entry.depth + 1)
153
153
  entry.children.each do |child|
154
154
  result << child.path
@@ -15,13 +15,15 @@ class Puppet::FileServing::HttpMetadata < Puppet::FileServing::Metadata
15
15
  # use a default mtime in case there is no usable HTTP header
16
16
  @checksums[:mtime] = "{mtime}#{Time.now}"
17
17
 
18
- if checksum = http_response['content-md5']
18
+ checksum = http_response['content-md5']
19
+ if checksum
19
20
  # convert base64 digest to hex
20
21
  checksum = checksum.unpack("m0").first.unpack("H*").first
21
22
  @checksums[:md5] = "{md5}#{checksum}"
22
23
  end
23
24
 
24
- if last_modified = http_response['last-modified']
25
+ last_modified = http_response['last-modified']
26
+ if last_modified
25
27
  mtime = DateTime.httpdate(last_modified).to_time
26
28
  @checksums[:mtime] = "{mtime}#{mtime.utc}"
27
29
  end
@@ -127,7 +127,8 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base
127
127
  @owner = data.delete('owner')
128
128
  @group = data.delete('group')
129
129
  @mode = data.delete('mode')
130
- if checksum = data.delete('checksum')
130
+ checksum = data.delete('checksum')
131
+ if checksum
131
132
  @checksum_type = checksum['type']
132
133
  @checksum = checksum['value']
133
134
  end
@@ -60,7 +60,8 @@ class Puppet::FileServing::Mount::File < Puppet::FileServing::Mount
60
60
  end
61
61
 
62
62
  def search(path, request)
63
- return nil unless path = complete_path(path, request.node)
63
+ path = complete_path(path, request.node)
64
+ return nil unless path
64
65
  [path]
65
66
  end
66
67
 
@@ -6,7 +6,8 @@ require 'puppet/file_serving/mount'
6
6
  class Puppet::FileServing::Mount::Locales < Puppet::FileServing::Mount
7
7
  # Return an instance of the appropriate class.
8
8
  def find(relative_path, request)
9
- return nil unless mod = request.environment.modules.find { |m| m.locale(relative_path) }
9
+ mod = request.environment.modules.find { |m| m.locale(relative_path) }
10
+ return nil unless mod
10
11
 
11
12
  path = mod.locale(relative_path)
12
13
 
@@ -7,13 +7,15 @@ class Puppet::FileServing::Mount::Modules < Puppet::FileServing::Mount
7
7
  def find(path, request)
8
8
  raise _("No module specified") if path.to_s.empty?
9
9
  module_name, relative_path = path.split("/", 2)
10
- return nil unless mod = request.environment.module(module_name)
10
+ mod = request.environment.module(module_name)
11
+ return nil unless mod
11
12
 
12
13
  mod.file(relative_path)
13
14
  end
14
15
 
15
16
  def search(path, request)
16
- if result = find(path, request)
17
+ result = find(path, request)
18
+ if result
17
19
  [result]
18
20
  end
19
21
  end
@@ -6,7 +6,8 @@ require 'puppet/file_serving/mount'
6
6
  class Puppet::FileServing::Mount::PluginFacts < Puppet::FileServing::Mount
7
7
  # Return an instance of the appropriate class.
8
8
  def find(relative_path, request)
9
- return nil unless mod = request.environment.modules.find { |m| m.pluginfact(relative_path) }
9
+ mod = request.environment.modules.find { |m| m.pluginfact(relative_path) }
10
+ return nil unless mod
10
11
 
11
12
  path = mod.pluginfact(relative_path)
12
13
 
@@ -6,7 +6,8 @@ require 'puppet/file_serving/mount'
6
6
  class Puppet::FileServing::Mount::Plugins < Puppet::FileServing::Mount
7
7
  # Return an instance of the appropriate class.
8
8
  def find(relative_path, request)
9
- return nil unless mod = request.environment.modules.find { |m| m.plugin(relative_path) }
9
+ mod = request.environment.modules.find { |m| m.plugin(relative_path) }
10
+ return nil unless mod
10
11
 
11
12
  path = mod.plugin(relative_path)
12
13
 
@@ -4,13 +4,15 @@ class Puppet::FileServing::Mount::Tasks < Puppet::FileServing::Mount
4
4
  def find(path, request)
5
5
  raise _("No task specified") if path.to_s.empty?
6
6
  module_name, task_path = path.split("/", 2)
7
- return nil unless mod = request.environment.module(module_name)
7
+ mod = request.environment.module(module_name)
8
+ return nil unless mod
8
9
 
9
10
  mod.task_file(task_path)
10
11
  end
11
12
 
12
13
  def search(path, request)
13
- if result = find(path, request)
14
+ result = find(path, request)
15
+ if result
14
16
  [result]
15
17
  end
16
18
  end
@@ -115,7 +115,8 @@ class Puppet::FileSystem::Uniquefile < DelegateClass(File)
115
115
  end
116
116
 
117
117
  def create_tmpname(basename, *rest)
118
- if opts = try_convert_to_hash(rest[-1])
118
+ opts = try_convert_to_hash(rest[-1])
119
+ if opts
119
120
  opts = opts.dup if rest.pop.equal?(opts)
120
121
  max_try = opts.delete(:max_try)
121
122
  opts = [opts]
@@ -157,7 +158,8 @@ class Puppet::FileSystem::Uniquefile < DelegateClass(File)
157
158
  @@systmpdir
158
159
  else
159
160
  for dir in [ Puppet::Util.get_env('TMPDIR'), Puppet::Util.get_env('TMP'), Puppet::Util.get_env('TEMP'), @@systmpdir, '/tmp']
160
- if dir and stat = File.stat(dir) and stat.directory? and stat.writable?
161
+ stat = File.stat(dir) if dir
162
+ if stat && stat.directory? && stat.writable?
161
163
  tmp = dir
162
164
  break
163
165
  end rescue nil
@@ -124,8 +124,7 @@ Puppet::Functions.create_function(:match) do
124
124
  private
125
125
 
126
126
  def do_match(s, regexp)
127
- if result = regexp.match(s)
128
- result.to_a
129
- end
127
+ result = regexp.match(s)
128
+ result.to_a if result
130
129
  end
131
130
  end
@@ -195,7 +195,8 @@ module Puppet
195
195
  types ||= Puppet::Type.instance_variable_get('@types')
196
196
 
197
197
  # Assume the type follows the naming convention
198
- unless type = types[type_name]
198
+ type = types[type_name]
199
+ unless type
199
200
  Puppet.err _("Custom type '%{type_name}' was not defined in '%{input}'.") % { type_name: type_name, input: input }
200
201
  next
201
202
  end
@@ -104,7 +104,8 @@ class Puppet::Graph::RelationshipGraph < Puppet::Graph::SimpleGraph
104
104
  teardown = options[:teardown] || lambda {}
105
105
  graph_cycle_handler = options[:graph_cycle_handler] || lambda { [] }
106
106
 
107
- if cycles = report_cycles_in_graph
107
+ cycles = report_cycles_in_graph
108
+ if cycles
108
109
  graph_cycle_handler.call(cycles)
109
110
  end
110
111
 
@@ -208,7 +208,7 @@ class Puppet::Graph::SimpleGraph
208
208
 
209
209
  # frame struct is vertex, [path]
210
210
  stack = [[cycle.first, []]]
211
- while frame = stack.shift do
211
+ while frame = stack.shift do #rubocop:disable Lint/AssignmentInCondition
212
212
  if frame[1].member?(frame[0]) then
213
213
  found << frame[1] + [frame[0]]
214
214
  break if found.length >= max_paths
@@ -343,7 +343,8 @@ class Puppet::Graph::SimpleGraph
343
343
 
344
344
  # Find adjacent edges.
345
345
  def adjacent(v, options = {})
346
- return [] unless ns = (options[:direction] == :in) ? @in_to[v] : @out_from[v]
346
+ ns = (options[:direction] == :in) ? @in_to[v] : @out_from[v]
347
+ return [] unless ns
347
348
  (options[:type] == :edges) ? ns.values.flatten : ns.keys
348
349
  end
349
350
 
@@ -18,8 +18,10 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
18
18
  # (possibly) containing facts
19
19
  # @return [Puppet::Node::Facts] facts object corresponding to facts in request
20
20
  def extract_facts_from_request(request)
21
- return unless text_facts = request.options[:facts]
22
- unless format = request.options[:facts_format]
21
+ text_facts = request.options[:facts]
22
+ return unless text_facts
23
+ format = request.options[:facts_format]
24
+ unless format
23
25
  raise ArgumentError, _("Facts but no fact format provided for %{request}") % { request: request.key }
24
26
  end
25
27
 
@@ -199,7 +201,8 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
199
201
  sources.each do |source|
200
202
  source = Puppet::Type.type(:file).attrclass(:source).normalize(source)
201
203
 
202
- if list_of_data = Puppet::FileServing::Metadata.indirection.search(source, options)
204
+ list_of_data = Puppet::FileServing::Metadata.indirection.search(source, options)
205
+ if list_of_data
203
206
  basedir_meta = list_of_data.find {|meta| meta.relative_path == '.'}
204
207
  devfail "FileServing::Metadata search should always return the root search path" if basedir_meta.nil?
205
208
 
@@ -243,7 +246,8 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
243
246
  sources.each do |source|
244
247
  source = Puppet::Type.type(:file).attrclass(:source).normalize(source)
245
248
 
246
- if data = Puppet::FileServing::Metadata.indirection.find(source, options)
249
+ data = Puppet::FileServing::Metadata.indirection.find(source, options)
250
+ if data
247
251
  metadata = data
248
252
  metadata.source = source
249
253
  break
@@ -362,7 +366,8 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
362
366
  # Extract the node from the request, or use the request
363
367
  # to find the node.
364
368
  def node_from_request(facts, request)
365
- if node = request.options[:use_node]
369
+ node = request.options[:use_node]
370
+ if node
366
371
  if request.remote?
367
372
  raise Puppet::Error, _("Invalid option use_node for a remote request")
368
373
  else
@@ -378,7 +383,8 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
378
383
  # node's catalog with only one certificate and a modification to auth.conf
379
384
  # If no key is provided we can only compile the currently connected node.
380
385
  name = request.key || request.node
381
- if node = find_node(name, request.environment, request.options[:transaction_uuid], request.options[:configured_environment], facts)
386
+ node = find_node(name, request.environment, request.options[:transaction_uuid], request.options[:configured_environment], facts)
387
+ if node
382
388
  return node
383
389
  end
384
390
 
@@ -397,7 +403,8 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
397
403
  {"servername" => "fqdn",
398
404
  "serverip" => "ipaddress"
399
405
  }.each do |var, fact|
400
- if value = Facter.value(fact)
406
+ value = Facter.value(fact)
407
+ if value
401
408
  @server_facts[var] = value
402
409
  else
403
410
  Puppet.warning _("Could not retrieve fact %{fact}") % { fact: fact }
@@ -406,7 +413,8 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
406
413
 
407
414
  if @server_facts["servername"].nil?
408
415
  host = Facter.value(:hostname)
409
- if domain = Facter.value(:domain)
416
+ domain = Facter.value(:domain)
417
+ if domain
410
418
  @server_facts["servername"] = [host, domain].join(".")
411
419
  else
412
420
  @server_facts["servername"] = host
@@ -9,7 +9,8 @@ class Puppet::SSL::Certificate::Rest < Puppet::Indirector::REST
9
9
  use_srv_service(:ca)
10
10
 
11
11
  def find(request)
12
- return nil unless result = super
12
+ result = super
13
+ return nil unless result
13
14
  result.name = request.key unless result.name == request.key
14
15
  result
15
16
  end
@@ -112,8 +112,8 @@ class Puppet::Indirector::Face < Puppet::Face
112
112
  EOT
113
113
 
114
114
  when_invoked do |options|
115
- if t = indirection.terminus_class
116
- _("Run mode '%{mode}': %{terminus}") % { mode: Puppet.run_mode.name, terminus: t }
115
+ if indirection.terminus_class
116
+ _("Run mode '%{mode}': %{terminus}") % { mode: Puppet.run_mode.name, terminus: indirection.terminus_class }
117
117
  else
118
118
  _("No default terminus class for run mode '%{mode}'") % { mode: Puppet.run_mode.name }
119
119
  end
@@ -34,7 +34,8 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus
34
34
 
35
35
  # The mount checks to see if the file exists, and returns nil
36
36
  # if not.
37
- return nil unless path = mount.find(relative_path, request)
37
+ path = mount.find(relative_path, request)
38
+ return nil unless path
38
39
  path2instance(request, path)
39
40
  end
40
41
 
@@ -43,7 +44,8 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus
43
44
  def search(request)
44
45
  mount, relative_path = configuration.split_path(request)
45
46
 
46
- unless mount and paths = mount.search(relative_path, request)
47
+ paths = mount.search(relative_path, request) if mount
48
+ unless paths
47
49
  Puppet.info _("Could not find filesystem info for file '%{request}' in environment %{env}") % { request: request.key, env: request.environment }
48
50
  return nil
49
51
  end
@@ -29,7 +29,8 @@ class Puppet::Indirector::Indirection
29
29
  # Find an indirected model by name. This is provided so that Terminus classes
30
30
  # can specifically hook up with the indirections they are associated with.
31
31
  def self.model(name)
32
- return nil unless match = @@indirections.find { |i| i.name == name }
32
+ match = @@indirections.find { |i| i.name == name }
33
+ return nil unless match
33
34
  match.model
34
35
  end
35
36
 
@@ -125,7 +126,8 @@ class Puppet::Indirector::Indirection
125
126
  # Determine the terminus class.
126
127
  def terminus_class
127
128
  unless @terminus_class
128
- if setting = self.terminus_setting
129
+ setting = self.terminus_setting
130
+ if setting
129
131
  self.terminus_class = Puppet.settings[setting]
130
132
  else
131
133
  raise Puppet::DevError, _("No terminus class nor terminus setting was provided for indirection %{name}") % { name: self.name}
@@ -163,7 +165,8 @@ class Puppet::Indirector::Indirection
163
165
 
164
166
  return nil unless cache? && !request.ignore_cache_save?
165
167
 
166
- return nil unless instance = cache.find(request(:find, key, nil, options))
168
+ instance = cache.find(request(:find, key, nil, options))
169
+ return nil unless instance
167
170
 
168
171
  Puppet.info _("Expiring the %{cache} cache of %{instance}") % { cache: self.name, instance: instance.name }
169
172
 
@@ -233,7 +236,8 @@ class Puppet::Indirector::Indirection
233
236
 
234
237
  def find_in_cache(request)
235
238
  # See if our instance is in the cache and up to date.
236
- return nil unless cache? and ! request.ignore_cache? and cached = cache.find(request)
239
+ cached = cache.find(request) if cache? && ! request.ignore_cache?
240
+ return nil unless cached
237
241
  if cached.expired?
238
242
  Puppet.info _("Not using expired %{indirection} for %{request} from cache; expired at %{expiration}") % { indirection: self.name, request: request.key, expiration: cached.expiration }
239
243
  return nil
@@ -266,7 +270,8 @@ class Puppet::Indirector::Indirection
266
270
  request = request(:search, key, nil, options)
267
271
  terminus = prepare(request)
268
272
 
269
- if result = terminus.search(request)
273
+ result = terminus.search(request)
274
+ if result
270
275
  raise Puppet::DevError, _("Search results from terminus %{terminus_name} are not an array") % { terminus_name: terminus.name } unless result.is_a?(Array)
271
276
  result.each do |instance|
272
277
  next unless instance.respond_to? :expiration
@@ -332,7 +337,8 @@ class Puppet::Indirector::Indirection
332
337
  # Create a new terminus instance.
333
338
  def make_terminus(terminus_class)
334
339
  # Load our terminus class.
335
- unless klass = Puppet::Indirector::Terminus.terminus_class(self.name, terminus_class)
340
+ klass = Puppet::Indirector::Terminus.terminus_class(self.name, terminus_class)
341
+ unless klass
336
342
  raise ArgumentError, _("Could not find terminus %{terminus_class} for indirection %{indirection}") % { terminus_class: terminus_class, indirection: self.name }
337
343
  end
338
344
  klass.new
@@ -39,7 +39,8 @@ class Puppet::Node::Exec < Puppet::Indirector::Exec
39
39
  def create_node(name, result, facts = nil)
40
40
  node = Puppet::Node.new(name)
41
41
  [:parameters, :classes, :environment].each do |param|
42
- if value = result[param]
42
+ value = result[param]
43
+ if value
43
44
  node.send(param.to_s + "=", value)
44
45
  end
45
46
  end
@@ -49,7 +49,8 @@ class Puppet::Transaction::Report::Processor < Puppet::Indirector::Code
49
49
  def processors(&blk)
50
50
  return [] if Puppet[:reports] == "none"
51
51
  reports.each do |name|
52
- if mod = Puppet::Reports.report(name)
52
+ mod = Puppet::Reports.report(name)
53
+ if mod
53
54
  yield(mod)
54
55
  else
55
56
  Puppet.warning _("No report named '%{name}'") % { name: name }
@@ -99,8 +99,9 @@ class Puppet::Indirector::Request
99
99
  end
100
100
 
101
101
  def model
102
- raise ArgumentError, _("Could not find indirection '%{indirection}'") % { indirection: indirection_name } unless i = indirection
103
- i.model
102
+ ind = indirection
103
+ raise ArgumentError, _("Could not find indirection '%{indirection}'") % { indirection: indirection_name } unless ind
104
+ ind.model
104
105
  end
105
106
 
106
107
  # Are we trying to interact with multiple resources, or just one?
@@ -169,7 +170,8 @@ class Puppet::Indirector::Request
169
170
  result = options.dup
170
171
 
171
172
  OPTION_ATTRIBUTES.each do |attribute|
172
- if value = send(attribute)
173
+ value = send(attribute)
174
+ if value
173
175
  result[attribute] = value
174
176
  end
175
177
  end
@@ -206,7 +208,8 @@ class Puppet::Indirector::Request
206
208
  self.server = default_server
207
209
  else
208
210
  self.server = Puppet.lookup(:server) do
209
- if primary_server = Puppet.settings[:server_list][0]
211
+ primary_server = Puppet.settings[:server_list][0]
212
+ if primary_server
210
213
  #TRANSLATORS 'server_list' is the name of a setting and should not be translated
211
214
  debug_once _("Selected server from first entry of the `server_list` setting: %{server}") % {server: primary_server[0]}
212
215
  primary_server[0]
@@ -222,7 +225,8 @@ class Puppet::Indirector::Request
222
225
  self.port = default_port
223
226
  else
224
227
  self.port = Puppet.lookup(:serverport) do
225
- if primary_server = Puppet.settings[:server_list][0]
228
+ primary_server = Puppet.settings[:server_list][0]
229
+ if primary_server
226
230
  #TRANSLATORS 'server_list' is the name of a setting and should not be translated
227
231
  debug_once _("Selected port from the first entry of the `server_list` setting: %{port}") % {port: primary_server[1]}
228
232
  primary_server[1]