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
@@ -511,7 +511,8 @@ class Type
511
511
 
512
512
  raise Puppet::DevError, _("Class %{class_name} already has a property named %{property}") % { class_name: self.name, property: name } if @validproperties.include?(name)
513
513
 
514
- if parent = options[:parent]
514
+ parent = options[:parent]
515
+ if parent
515
516
  options.delete(:parent)
516
517
  else
517
518
  parent = Puppet::Property
@@ -644,11 +645,13 @@ class Type
644
645
  name = name.intern
645
646
  fail("Invalid parameter #{name}(#{name.inspect})") unless self.class.validattr?(name)
646
647
 
647
- if name == :name && nv = name_var
648
- name = nv
648
+ if name == :name
649
+ nv = name_var
650
+ name = nv if nv
649
651
  end
650
652
 
651
- if obj = @parameters[name]
653
+ obj = @parameters[name]
654
+ if obj
652
655
  # Note that if this is a property, then the value is the "should" value,
653
656
  # not the current value.
654
657
  obj.value
@@ -667,8 +670,9 @@ class Type
667
670
 
668
671
  fail("no parameter named '#{name}'") unless self.class.validattr?(name)
669
672
 
670
- if name == :name && nv = name_var
671
- name = nv
673
+ if name == :name
674
+ nv = name_var
675
+ name = nv if nv
672
676
  end
673
677
  raise Puppet::Error.new("Got nil value for #{name}") if value.nil?
674
678
 
@@ -745,8 +749,12 @@ class Type
745
749
  # @return [Object, nil] Returns the 'should' (wanted state) value for a specified property, or nil if the
746
750
  # given attribute name is not a property (i.e. if it is a parameter, meta-parameter, or does not exist).
747
751
  def should(name)
748
- name = name.intern
749
- (prop = @parameters[name] and prop.is_a?(Puppet::Property)) ? prop.should : nil
752
+ prop = @parameters[name.intern]
753
+ if prop && prop.is_a?(Puppet::Property)
754
+ prop.should
755
+ else
756
+ nil
757
+ end
750
758
  end
751
759
 
752
760
  # Registers an attribute to this resource type instance.
@@ -768,7 +776,8 @@ class Type
768
776
  name = klass.name
769
777
  end
770
778
 
771
- unless klass = self.class.attrclass(name)
779
+ klass = self.class.attrclass(name)
780
+ unless klass
772
781
  raise Puppet::Error, "Resource type #{self.class.name} does not support parameter #{name}"
773
782
  end
774
783
 
@@ -819,7 +828,12 @@ class Type
819
828
  # this one should probably go away at some point. - Does this mean it should be deprecated ?
820
829
  # @return [Puppet::Property] the property with the given name, or nil if not a property or does not exist.
821
830
  def property(name)
822
- (obj = @parameters[name.intern] and obj.is_a?(Puppet::Property)) ? obj : nil
831
+ obj = @parameters[name.intern]
832
+ if obj && obj.is_a?(Puppet::Property)
833
+ obj
834
+ else
835
+ nil
836
+ end
823
837
  end
824
838
 
825
839
  # @todo comment says "For any parameters or properties that have defaults and have not yet been
@@ -831,14 +845,17 @@ class Type
831
845
  # @return [void]
832
846
  #
833
847
  def set_default(attr)
834
- return unless klass = self.class.attrclass(attr)
848
+ klass = self.class.attrclass(attr)
849
+ return unless klass
835
850
  # TODO this is not a necessary check, as we define a class level attr_reader
836
851
  return unless klass.method_defined?(:default)
837
852
  return if @parameters.include?(klass.name)
838
853
 
839
- return unless parameter = newattr(klass.name)
854
+ parameter = newattr(klass.name)
855
+ return unless parameter
840
856
 
841
- if value = parameter.default and ! value.nil?
857
+ value = parameter.default
858
+ if value and ! value.nil?
842
859
  parameter.value = value
843
860
  else
844
861
  @parameters.delete(parameter.name)
@@ -880,7 +897,12 @@ class Type
880
897
  def value(name)
881
898
  name = name.intern
882
899
 
883
- (obj = @parameters[name] and obj.respond_to?(:value)) ? obj.value : nil
900
+ obj = @parameters[name]
901
+ if obj && obj.respond_to?(:value)
902
+ obj.value
903
+ else
904
+ nil
905
+ end
884
906
  end
885
907
 
886
908
  # @todo What is this used for? Needs a better explanation.
@@ -1023,7 +1045,8 @@ class Type
1023
1045
  def insync?(is)
1024
1046
  insync = true
1025
1047
 
1026
- if property = @parameters[:ensure]
1048
+ property = @parameters[:ensure]
1049
+ if property
1027
1050
  unless is.include? property
1028
1051
  #TRANSLATORS 'is' is a variable name and should not be translated
1029
1052
  raise Puppet::DevError, _("The 'is' value is not in the 'is' array for '%{name}'") % { name: property.name }
@@ -1073,7 +1096,12 @@ class Type
1073
1096
  # Provide the name, so we know we'll always refer to a real thing
1074
1097
  result[:name] = self[:name] unless self[:name] == title
1075
1098
 
1076
- if ensure_prop = property(:ensure) or (self.class.needs_ensure_retrieved and self.class.validattr?(:ensure) and ensure_prop = newattr(:ensure))
1099
+ ensure_prop = property(:ensure)
1100
+ if !ensure_prop && self.class.needs_ensure_retrieved && self.class.validattr?(:ensure)
1101
+ ensure_prop = newattr(:ensure)
1102
+ end
1103
+
1104
+ if ensure_prop
1077
1105
  result[:ensure] = ensure_state = ensure_prop.retrieve
1078
1106
  else
1079
1107
  ensure_state = nil
@@ -1171,7 +1199,8 @@ class Type
1171
1199
  provider.instances.collect do |instance|
1172
1200
  # We always want to use the "first" provider instance we find, unless the resource
1173
1201
  # is already managed and has a different provider set
1174
- if other = provider_instances[instance.name]
1202
+ other = provider_instances[instance.name]
1203
+ if other
1175
1204
  Puppet.debug "%s %s found in both %s and %s; skipping the %s version" %
1176
1205
  [self.name.to_s.capitalize, instance.name, other.class.name, instance.class.name, instance.class.name]
1177
1206
  next
@@ -1219,7 +1248,8 @@ class Type
1219
1248
  resource = Puppet::Resource.new(self, title)
1220
1249
  resource.catalog = hash.delete(:catalog)
1221
1250
 
1222
- if sensitive = hash.delete(:sensitive_parameters)
1251
+ sensitive = hash.delete(:sensitive_parameters)
1252
+ if sensitive
1223
1253
  resource.sensitive_parameters = sensitive
1224
1254
  end
1225
1255
 
@@ -1236,7 +1266,8 @@ class Type
1236
1266
  #
1237
1267
  # @api private
1238
1268
  def pathbuilder
1239
- if p = parent
1269
+ p = parent
1270
+ if p
1240
1271
  [p.pathbuilder, self.ref].flatten
1241
1272
  else
1242
1273
  [self.ref]
@@ -1425,7 +1456,8 @@ class Type
1425
1456
  raise(ArgumentError, _("Cannot add aliases without a catalog")) unless @resource.catalog
1426
1457
 
1427
1458
  aliases.each do |other|
1428
- if obj = @resource.catalog.resource(@resource.class.name, other)
1459
+ obj = @resource.catalog.resource(@resource.class.name, other)
1460
+ if obj
1429
1461
  unless obj.object_id == @resource.object_id
1430
1462
  self.fail("#{@resource.title} can not create alias #{other}: object already exists")
1431
1463
  end
@@ -1526,7 +1558,8 @@ class Type
1526
1558
 
1527
1559
  # Either of the two retrieval attempts could have returned
1528
1560
  # nil.
1529
- unless related_resource = reference.resolve
1561
+ related_resource = reference.resolve
1562
+ unless related_resource
1530
1563
  self.fail "Could not retrieve dependency '#{reference}' of #{@resource.ref}"
1531
1564
  end
1532
1565
 
@@ -1540,7 +1573,8 @@ class Type
1540
1573
  target = related_resource
1541
1574
  end
1542
1575
 
1543
- if method = self.class.callback
1576
+ method = self.class.callback
1577
+ if method
1544
1578
  subargs = {
1545
1579
  :event => self.class.events,
1546
1580
  :callback => method
@@ -1851,12 +1885,14 @@ end
1851
1885
  Puppet.debug "Reloading #{name} #{self.name} provider"
1852
1886
  end
1853
1887
 
1854
- parent = if pname = options[:parent]
1888
+ pname = options[:parent]
1889
+ parent = if pname
1855
1890
  options.delete(:parent)
1856
1891
  if pname.is_a? Class
1857
1892
  pname
1858
1893
  else
1859
- if provider = self.provider(pname)
1894
+ provider = self.provider(pname)
1895
+ if provider
1860
1896
  provider
1861
1897
  else
1862
1898
  raise Puppet::DevError, _("Could not find parent provider %{parent} of %{name}") % { parent: pname, name: name }
@@ -2015,10 +2051,13 @@ end
2015
2051
  if name.is_a?(Puppet::Provider)
2016
2052
  @provider = name
2017
2053
  @provider.resource = self
2018
- elsif klass = self.class.provider(name)
2019
- @provider = klass.new(self)
2020
2054
  else
2021
- raise ArgumentError, _("Could not find %{name} provider of %{provider}") % { name: name, provider: self.class.name }
2055
+ klass = self.class.provider(name)
2056
+ if klass
2057
+ @provider = klass.new(self)
2058
+ else
2059
+ raise ArgumentError, _("Could not find %{name} provider of %{provider}") % { name: name, provider: self.class.name }
2060
+ end
2022
2061
  end
2023
2062
  end
2024
2063
 
@@ -2146,8 +2185,9 @@ end
2146
2185
  next unless Puppet::Type.type(type)
2147
2186
 
2148
2187
  # Retrieve the list of names from the block.
2149
- next unless list = self.instance_eval(&block)
2150
- list = [list] unless list.is_a?(Array)
2188
+ list = self.instance_eval(&block)
2189
+ next unless list
2190
+ list = Array(list)
2151
2191
 
2152
2192
  # Collect the current prereqs
2153
2193
  list.each { |dep|
@@ -2156,9 +2196,8 @@ end
2156
2196
  # Support them passing objects directly, to save some effort.
2157
2197
  unless dep.is_a?(Puppet::Type)
2158
2198
  # Skip autorelation that we aren't managing
2159
- unless dep = rel_catalog.resource(type, dep)
2160
- next
2161
- end
2199
+ dep = rel_catalog.resource(type, dep)
2200
+ next unless dep
2162
2201
  end
2163
2202
 
2164
2203
  if [:require, :subscribe].include?(rel_type)
@@ -2194,9 +2233,8 @@ end
2194
2233
  def builddepends
2195
2234
  # Handle the requires
2196
2235
  self.class.relationship_params.collect do |klass|
2197
- if param = @parameters[klass.name]
2198
- param.to_edges
2199
- end
2236
+ param = @parameters[klass.name]
2237
+ param.to_edges if param
2200
2238
  end.flatten.reject { |r| r.nil? }
2201
2239
  end
2202
2240
 
@@ -2386,9 +2424,8 @@ end
2386
2424
 
2387
2425
  [:file, :line, :catalog, :exported, :virtual].each do |getter|
2388
2426
  setter = getter.to_s + "="
2389
- if val = resource.send(getter)
2390
- self.send(setter, val)
2391
- end
2427
+ val = resource.send(getter)
2428
+ self.send(setter, val) if val
2392
2429
  end
2393
2430
 
2394
2431
  merge_tags_from(resource)
@@ -2536,9 +2573,8 @@ end
2536
2573
  # Make sure all of our relationships are valid. Again, must be done
2537
2574
  # when the entire catalog is instantiated.
2538
2575
  self.class.relationship_params.collect do |klass|
2539
- if param = @parameters[klass.name]
2540
- param.validate_relationship
2541
- end
2576
+ param = @parameters[klass.name]
2577
+ param.validate_relationship if param
2542
2578
  end.flatten.reject { |r| r.nil? }
2543
2579
  end
2544
2580
 
@@ -2560,13 +2596,13 @@ end
2560
2596
  # resource.
2561
2597
  def parent
2562
2598
  return nil unless catalog
2563
-
2564
- @parent ||=
2565
- if parents = catalog.adjacent(self, :direction => :in)
2566
- parents.shift
2567
- else
2568
- nil
2569
- end
2599
+ return @parent if @parent
2600
+ parents = catalog.adjacent(self, :direction => :in)
2601
+ @parent = if parents
2602
+ parents.shift
2603
+ else
2604
+ nil
2605
+ end
2570
2606
  end
2571
2607
 
2572
2608
  # Returns a reference to this as a string in "Type[name]" format.
@@ -38,7 +38,8 @@ Puppet::Type.newtype(:component) do
38
38
  else
39
39
  myname = reference.to_s
40
40
  end
41
- if p = self.parent
41
+ p = self.parent
42
+ if p
42
43
  return [p.pathbuilder, myname]
43
44
  else
44
45
  return [myname]
@@ -50,7 +50,7 @@ module Puppet
50
50
  it becomes doubly important to make sure the run conditions are restricted.
51
51
 
52
52
  **Autorequires:** If Puppet is managing an exec's cwd or the executable
53
- file used in an exec's command, the exec resource will autorequire those
53
+ file used in an exec's command, the exec resource autorequires those
54
54
  files. If Puppet is managing the user that an exec should run as, the
55
55
  exec resource will autorequire that user."
56
56
 
@@ -141,7 +141,8 @@ module Puppet
141
141
  self.fail Puppet::Error, _("Command exceeded timeout"), $!
142
142
  end
143
143
 
144
- if log = @resource[:logoutput]
144
+ log = @resource[:logoutput]
145
+ if log
145
146
  case log
146
147
  when :true
147
148
  log = @resource[:loglevel]
@@ -435,7 +436,7 @@ module Puppet
435
436
  `grep` determines it's already there.
436
437
 
437
438
  Note that this test command runs with the same `provider`, `path`,
438
- `user`, and `group` as the main command. If the `path` isn't set, you
439
+ `user`, `cwd`, and `group` as the main command. If the `path` isn't set, you
439
440
  must fully qualify the command's name.
440
441
 
441
442
  This parameter can also take an array of commands. For example:
@@ -487,7 +488,7 @@ module Puppet
487
488
  This would run `logrotate` only if that test returns true.
488
489
 
489
490
  Note that this test command runs with the same `provider`, `path`,
490
- `user`, and `group` as the main command. If the `path` isn't set, you
491
+ `user`, `cwd`, and `group` as the main command. If the `path` isn't set, you
491
492
  must fully qualify the command's name.
492
493
 
493
494
  This parameter can also take an array of commands. For example:
@@ -548,7 +549,8 @@ module Puppet
548
549
  }
549
550
 
550
551
  [:onlyif, :unless].each { |param|
551
- next unless tmp = self[param]
552
+ tmp = self[param]
553
+ next unless tmp
552
554
 
553
555
  tmp = [tmp] unless tmp.is_a? Array
554
556
 
@@ -570,7 +572,8 @@ module Puppet
570
572
 
571
573
  autorequire(:user) do
572
574
  # Autorequire users if they are specified by name
573
- if user = self[:user] and user !~ /^\d+$/
575
+ user = self[:user]
576
+ if user !~ /^\d+$/
574
577
  user
575
578
  end
576
579
  end
@@ -616,7 +619,8 @@ module Puppet
616
619
  # Run the command, or optionally run a separately-specified command.
617
620
  def refresh
618
621
  if self.check_all_attributes(true)
619
- if cmd = self[:refresh]
622
+ cmd = self[:refresh]
623
+ if cmd
620
624
  provider.run(cmd)
621
625
  else
622
626
  self.property(:returns).sync
@@ -361,7 +361,8 @@ Puppet::Type.newtype(:file) do
361
361
  if !path.root?
362
362
  # Start at our parent, to avoid autorequiring ourself
363
363
  parents = path.parent.enum_for(:ascend)
364
- if found = parents.find { |p| catalog.resource(:file, p.to_s) }
364
+ found = parents.find { |p| catalog.resource(:file, p.to_s) }
365
+ if found
365
366
  req << found.to_s
366
367
  end
367
368
  end
@@ -375,7 +376,8 @@ Puppet::Type.newtype(:file) do
375
376
  autorequire(type) do
376
377
  if @parameters.include?(property)
377
378
  # The user/group property automatically converts to IDs
378
- next unless should = @parameters[property].shouldorig
379
+ should = @parameters[property].shouldorig
380
+ next unless should
379
381
  val = should[0]
380
382
  if val.is_a?(Integer) or val =~ /^\d+$/
381
383
  nil
@@ -458,7 +460,8 @@ Puppet::Type.newtype(:file) do
458
460
  fail _("Can not find filebucket for backups without a catalog")
459
461
  end
460
462
 
461
- unless catalog and filebucket = catalog.resource(:filebucket, backup) or backup == "puppet"
463
+ filebucket = catalog.resource(:filebucket, backup) if catalog
464
+ if !catalog || (!filebucket && backup != 'puppet')
462
465
  fail _("Could not find filebucket %{backup} specified in backup") % { backup: backup }
463
466
  end
464
467
 
@@ -569,7 +572,8 @@ Puppet::Type.newtype(:file) do
569
572
  def pathbuilder
570
573
  # We specifically need to call the method here, so it looks
571
574
  # up our parent in the catalog graph.
572
- if parent = parent()
575
+ parent = parent()
576
+ if parent
573
577
  # We only need to behave specially when our parent is also
574
578
  # a file
575
579
  if parent.is_a?(self.class)
@@ -692,14 +696,16 @@ Puppet::Type.newtype(:file) do
692
696
  total = self[:source].collect do |source|
693
697
  # For each inlined file resource, the catalog contains a hash mapping
694
698
  # source path to lists of metadata returned by a server-side search.
695
- if recursive_metadata = catalog.recursive_metadata[title]
699
+ recursive_metadata = catalog.recursive_metadata[title]
700
+ if recursive_metadata
696
701
  result = recursive_metadata[source]
697
702
  else
698
703
  result = perform_recursion(source)
699
704
  end
700
705
 
701
706
  next unless result
702
- return [] if top = result.find { |r| r.relative_path == "." } and top.ftype != "directory"
707
+ top = result.find { |r| r.relative_path == "." }
708
+ return [] if top && top.ftype != "directory"
703
709
  result.each do |data|
704
710
  if data.relative_path == '.'
705
711
  data.source = source
@@ -823,12 +829,12 @@ Puppet::Type.newtype(:file) do
823
829
  return true if self[:ensure] == :file
824
830
 
825
831
  # I.e., it's set to something like "directory"
826
- return false if e = self[:ensure] and e != :present
832
+ return false if self[:ensure] && self[:ensure] != :present
827
833
 
828
834
  # The user doesn't really care, apparently
829
835
  if self[:ensure] == :present
830
- return true unless s = stat
831
- return(s.ftype == "file" ? true : false)
836
+ return true unless stat
837
+ return(stat.ftype == "file" ? true : false)
832
838
  end
833
839
 
834
840
  # If we've gotten here, then :ensure isn't set
@@ -71,7 +71,9 @@ module Puppet
71
71
  # Checksums need to invert how changes are printed.
72
72
  def change_to_s(currentvalue, newvalue)
73
73
  # Our "new" checksum value is provided by the source.
74
- if source = resource.parameter(:source) and tmp = source.checksum
74
+ source = resource.parameter(:source)
75
+ tmp = source.checksum if source
76
+ if tmp
75
77
  newvalue = tmp
76
78
  end
77
79
  if currentvalue == :absent
@@ -107,7 +109,8 @@ module Puppet
107
109
  def property_matches?(current, desired)
108
110
  # If checksum_value is specified, it overrides comparing the content field.
109
111
  checksum_type = resource.parameter(:checksum).value
110
- if checksum_value = resource.parameter(:checksum_value)
112
+ checksum_value = resource.parameter(:checksum_value)
113
+ if checksum_value
111
114
  desired = "{#{checksum_type}}#{checksum_value.value}"
112
115
  end
113
116
 
@@ -161,7 +164,8 @@ module Puppet
161
164
  end
162
165
 
163
166
  def read_file_from_filebucket
164
- raise "Could not get filebucket from file" unless dipper = resource.bucket
167
+ dipper = resource.bucket
168
+ raise "Could not get filebucket from file" unless dipper
165
169
  sum = should.sub(/\{\w+\}/, '')
166
170
 
167
171
  dipper.getfile(sum)