chef 12.9.41-universal-mingw32 → 12.10.24-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +52 -13
  3. data/README.md +145 -0
  4. data/Rakefile +4 -14
  5. data/VERSION +1 -1
  6. data/acceptance/.gitignore +0 -1
  7. data/acceptance/Gemfile +2 -2
  8. data/acceptance/Gemfile.lock +235 -0
  9. data/acceptance/fips/.kitchen.yml +5 -1
  10. data/acceptance/fips/test/integration/{fips → fips-integration}/serverspec/Gemfile +0 -0
  11. data/acceptance/fips/test/integration/fips-integration/serverspec/fips-integration_spec.rb +51 -0
  12. data/acceptance/fips/test/integration/fips-unit-functional/serverspec/Gemfile +3 -0
  13. data/acceptance/fips/test/integration/fips-unit-functional/serverspec/fips-unit-functional_spec.rb +56 -0
  14. data/{chef-windows.gemspec → chef-universal-mingw32.gemspec} +0 -0
  15. data/chef.gemspec +0 -6
  16. data/{lib → lib-backcompat}/chef/chef_fs/file_system/already_exists_error.rb +0 -0
  17. data/{lib → lib-backcompat}/chef/chef_fs/file_system/cookbook_frozen_error.rb +0 -0
  18. data/{lib → lib-backcompat}/chef/chef_fs/file_system/default_environment_cannot_be_modified_error.rb +0 -0
  19. data/{lib → lib-backcompat}/chef/chef_fs/file_system/file_system_error.rb +0 -0
  20. data/{lib → lib-backcompat}/chef/chef_fs/file_system/must_delete_recursively_error.rb +0 -0
  21. data/{lib → lib-backcompat}/chef/chef_fs/file_system/not_found_error.rb +0 -0
  22. data/{lib → lib-backcompat}/chef/chef_fs/file_system/operation_failed_error.rb +0 -0
  23. data/{lib → lib-backcompat}/chef/chef_fs/file_system/operation_not_allowed_error.rb +0 -0
  24. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_acls_dir.rb +5 -0
  25. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_client_keys_dir.rb +5 -0
  26. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_entry.rb +6 -0
  27. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_policies_dir.rb +5 -0
  28. data/{lib → lib-backcompat}/chef/chef_fs/file_system/repository/file_system_root_dir.rb +1 -0
  29. data/lib/chef/chef_fs/file_system/repository/acl.rb +38 -0
  30. data/lib/chef/chef_fs/file_system/repository/{chef_repository_file_system_acls_dir.rb → acls_dir.rb} +14 -5
  31. data/lib/chef/chef_fs/file_system/repository/acls_sub_dir.rb +42 -0
  32. data/lib/chef/chef_fs/file_system/repository/base_file.rb +120 -0
  33. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  34. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +36 -32
  35. data/lib/chef/chef_fs/file_system/repository/client.rb +38 -0
  36. data/lib/chef/chef_fs/file_system/repository/client_key.rb +38 -0
  37. data/lib/chef/chef_fs/file_system/repository/{chef_repository_file_system_client_keys_dir.rb → client_keys_dir.rb} +9 -5
  38. data/lib/chef/chef_fs/file_system/repository/client_keys_sub_dir.rb +42 -0
  39. data/lib/chef/chef_fs/file_system/repository/clients_dir.rb +40 -0
  40. data/lib/chef/chef_fs/file_system/repository/container.rb +38 -0
  41. data/lib/chef/chef_fs/file_system/repository/containers_dir.rb +41 -0
  42. data/lib/chef/chef_fs/file_system/repository/cookbooks_dir.rb +0 -1
  43. data/lib/chef/chef_fs/file_system/repository/data_bag_item.rb +3 -79
  44. data/lib/chef/chef_fs/file_system/repository/directory.rb +15 -2
  45. data/lib/chef/chef_fs/file_system/repository/environment.rb +38 -0
  46. data/lib/chef/chef_fs/file_system/repository/environments_dir.rb +41 -0
  47. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +66 -30
  48. data/lib/chef/chef_fs/file_system/repository/group.rb +38 -0
  49. data/lib/chef/chef_fs/file_system/repository/groups_dir.rb +41 -0
  50. data/lib/chef/chef_fs/file_system/repository/node.rb +38 -0
  51. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +41 -0
  52. data/lib/chef/chef_fs/file_system/repository/{chef_repository_file_system_policies_dir.rb → policies_dir.rb} +9 -5
  53. data/lib/chef/chef_fs/file_system/repository/policy.rb +38 -0
  54. data/lib/chef/chef_fs/file_system/repository/policy_group.rb +38 -0
  55. data/lib/chef/chef_fs/file_system/repository/policy_groups_dir.rb +41 -0
  56. data/lib/chef/chef_fs/file_system/repository/role.rb +38 -0
  57. data/lib/chef/chef_fs/file_system/repository/roles_dir.rb +41 -0
  58. data/lib/chef/chef_fs/file_system/repository/user.rb +38 -0
  59. data/lib/chef/chef_fs/file_system/repository/users_dir.rb +41 -0
  60. data/lib/chef/dsl/declare_resource.rb +182 -7
  61. data/lib/chef/http/json_input.rb +2 -2
  62. data/lib/chef/knife.rb +1 -1
  63. data/lib/chef/mixin/shell_out.rb +10 -21
  64. data/lib/chef/property.rb +9 -2
  65. data/lib/chef/provider.rb +8 -7
  66. data/lib/chef/provider/apt_repository.rb +8 -6
  67. data/lib/chef/provider/directory.rb +15 -1
  68. data/lib/chef/provider/env/windows.rb +1 -1
  69. data/lib/chef/provider/mdadm.rb +1 -0
  70. data/lib/chef/provider/package/easy_install.rb +2 -0
  71. data/lib/chef/provider/package/rubygems.rb +4 -1
  72. data/lib/chef/provider/package/windows.rb +1 -1
  73. data/lib/chef/recipe.rb +1 -2
  74. data/lib/chef/resource/apt_repository.rb +6 -6
  75. data/lib/chef/resource/mdadm.rb +9 -0
  76. data/lib/chef/resource_collection.rb +5 -0
  77. data/lib/chef/resource_collection/resource_list.rb +10 -0
  78. data/lib/chef/resource_collection/resource_set.rb +14 -11
  79. data/lib/chef/version.rb +1 -1
  80. data/spec/functional/resource/git_spec.rb +1 -3
  81. data/spec/functional/resource/group_spec.rb +5 -5
  82. data/spec/functional/tiny_server_spec.rb +1 -1
  83. data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
  84. data/spec/functional/win32/registry_spec.rb +3 -3
  85. data/spec/integration/solo/solo_spec.rb +2 -2
  86. data/spec/support/shared/functional/securable_resource.rb +1 -1
  87. data/spec/support/shared/unit/provider/file.rb +3 -3
  88. data/spec/support/shared/unit/windows_script_resource.rb +1 -1
  89. data/spec/unit/application/apply_spec.rb +1 -0
  90. data/spec/unit/chef_fs/file_system/repository/base_file_spec.rb +128 -0
  91. data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +174 -0
  92. data/spec/unit/cookbook/metadata_spec.rb +1 -1
  93. data/spec/unit/dsl/declare_resource_spec.rb +335 -0
  94. data/spec/unit/knife/bootstrap_spec.rb +2 -2
  95. data/spec/unit/mixin/shell_out_spec.rb +4 -0
  96. data/spec/unit/node/attribute_spec.rb +1 -1
  97. data/spec/unit/node/immutable_collections_spec.rb +2 -2
  98. data/spec/unit/node_map_spec.rb +1 -1
  99. data/spec/unit/property/validation_spec.rb +23 -7
  100. data/spec/unit/provider/apt_repository_spec.rb +5 -0
  101. data/spec/unit/provider/apt_update_spec.rb +1 -0
  102. data/spec/unit/provider/directory_spec.rb +0 -7
  103. data/spec/unit/provider/file/content_spec.rb +1 -1
  104. data/spec/unit/provider/mdadm_spec.rb +9 -0
  105. data/spec/unit/provider/package/easy_install_spec.rb +6 -0
  106. data/spec/unit/provider/package/rubygems_spec.rb +8 -4
  107. data/spec/unit/provider/package/yum_spec.rb +1 -1
  108. data/spec/unit/provider/powershell_script_spec.rb +1 -1
  109. data/spec/unit/provider/user/dscl_spec.rb +6 -6
  110. data/spec/unit/recipe_spec.rb +1 -0
  111. data/spec/unit/resource/apt_repository_spec.rb +4 -0
  112. data/spec/unit/resource/file/verification_spec.rb +1 -1
  113. data/spec/unit/resource/file_spec.rb +2 -2
  114. data/spec/unit/resource/mdadm_spec.rb +7 -2
  115. data/spec/unit/resource_collection_spec.rb +30 -0
  116. data/spec/unit/resource_spec.rb +1 -1
  117. data/tasks/bin/bundle-platform +15 -0
  118. data/tasks/bin/bundle-platform.bat +2 -0
  119. data/tasks/bin/create-override-gemfile +110 -0
  120. data/tasks/bin/run_chef_tests +17 -0
  121. data/tasks/bin/run_external_test +47 -0
  122. data/tasks/bundle.rb +97 -0
  123. data/tasks/bundle_util.rb +94 -0
  124. data/tasks/changelog.rb +12 -0
  125. data/tasks/dependencies.rb +147 -0
  126. data/tasks/gemfile_util.rb +390 -0
  127. data/tasks/maintainers.rb +2 -1
  128. data/tasks/rspec.rb +2 -1
  129. metadata +61 -83
  130. data/acceptance/fips/test/integration/fips/serverspec/fips_spec.rb +0 -39
  131. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_entry.rb +0 -83
  132. data/tasks/external_tests.rb +0 -64
@@ -33,7 +33,7 @@ class Chef
33
33
 
34
34
  def handle_request(method, url, headers = {}, data = false)
35
35
  if data && should_encode_as_json?(headers)
36
- headers.delete_if { |key, _value| key.downcase == "content-type" }
36
+ headers.delete_if { |key, _value| key.casecmp("content-type").zero? }
37
37
  headers["Content-Type"] = "application/json"
38
38
  json_opts = {}
39
39
  json_opts[:validate_utf8] = opts[:validate_utf8] if opts.has_key?(:validate_utf8)
@@ -64,7 +64,7 @@ class Chef
64
64
  # ruby/Net::HTTP don't enforce capitalized headers (it normalizes them
65
65
  # for you before sending the request), so we have to account for all
66
66
  # the variations we might find
67
- requested_content_type = headers.find { |k, v| k.downcase == "content-type" }
67
+ requested_content_type = headers.find { |k, v| k.casecmp("content-type").zero? }
68
68
  requested_content_type.nil? || requested_content_type.last.include?("json")
69
69
  end
70
70
 
@@ -145,7 +145,7 @@ class Chef
145
145
  end
146
146
 
147
147
  def self.subcommand_class_from(args)
148
- if args.size == 1 && args[0].strip.downcase == "rehash"
148
+ if args.size == 1 && args[0].strip.casecmp("rehash").zero?
149
149
  # To prevent issues with the rehash file not pointing to the correct plugins,
150
150
  # we always use the glob loader when regenerating the rehash file
151
151
  @subcommand_loader = Chef::Knife::SubcommandLoader.gem_glob_loader(chef_config_dir)
@@ -28,26 +28,15 @@ class Chef
28
28
 
29
29
  # we use 'en_US.UTF-8' by default because we parse localized strings in English as an API and
30
30
  # generally must support UTF-8 unicode.
31
- def shell_out(*command_args)
32
- args = command_args.dup
33
- if args.last.is_a?(Hash)
34
- options = args.pop.dup
35
- env_key = options.has_key?(:env) ? :env : :environment
36
- options[env_key] ||= {}
37
- options[env_key] = options[env_key].dup
38
- options[env_key]["LC_ALL"] ||= Chef::Config[:internal_locale] unless options[env_key].has_key?("LC_ALL")
39
- options[env_key]["LANGUAGE"] ||= Chef::Config[:internal_locale] unless options[env_key].has_key?("LANGUAGE")
40
- options[env_key]["LANG"] ||= Chef::Config[:internal_locale] unless options[env_key].has_key?("LANG")
41
- args << options
42
- else
43
- args << { :environment => {
44
- "LC_ALL" => Chef::Config[:internal_locale],
45
- "LANGUAGE" => Chef::Config[:internal_locale],
46
- "LANG" => Chef::Config[:internal_locale],
47
- } }
48
- end
49
-
50
- shell_out_command(*args)
31
+ def shell_out(*args, **options)
32
+ options = options.dup
33
+ env_key = options.has_key?(:env) ? :env : :environment
34
+ options[env_key] = {
35
+ "LC_ALL" => Chef::Config[:internal_locale],
36
+ "LANGUAGE" => Chef::Config[:internal_locale],
37
+ "LANG" => Chef::Config[:internal_locale],
38
+ }.update(options[env_key] || {})
39
+ shell_out_command(*args, **options)
51
40
  end
52
41
 
53
42
  # call shell_out (using en_US.UTF-8) and raise errors
@@ -99,7 +88,7 @@ class Chef
99
88
  end
100
89
 
101
90
  def deprecate_option(old_option, new_option)
102
- Chef::Log.logger.warn "DEPRECATION: Chef::Mixin::ShellOut option :#{old_option} is deprecated. Use :#{new_option}"
91
+ Chef.log_deprecation "DEPRECATION: Chef::Mixin::ShellOut option :#{old_option} is deprecated. Use :#{new_option}"
103
92
  end
104
93
 
105
94
  def io_for_live_stream
@@ -72,6 +72,9 @@ class Chef
72
72
  # property defaults to the same value as `name`. Equivalent to
73
73
  # `default: lazy { name }`, except that #property_is_set? will
74
74
  # return `true` if the property is set *or* if `name` is set.
75
+ # @option options [Boolean] :nillable `true` opt-in to Chef-13 style behavior where
76
+ # attempting to set a nil value will really set a nil value instead of issuing
77
+ # a warning and operating like a getter
75
78
  # @option options [Object] :default The value this property
76
79
  # will return if the user does not set one. If this is `lazy`, it will
77
80
  # be run in the context of the instance (and able to access other
@@ -233,7 +236,7 @@ class Chef
233
236
  #
234
237
  def validation_options
235
238
  @validation_options ||= options.reject { |k, v|
236
- [:declared_in, :name, :instance_variable_name, :desired_state, :identity, :default, :name_property, :coerce, :required].include?(k)
239
+ [:declared_in, :name, :instance_variable_name, :desired_state, :identity, :default, :name_property, :coerce, :required, :nillable].include?(k)
237
240
  }
238
241
  end
239
242
 
@@ -262,7 +265,7 @@ class Chef
262
265
  return get(resource)
263
266
  end
264
267
 
265
- if value.nil?
268
+ if value.nil? && !nillable?
266
269
  # In Chef 12, value(nil) does a *get* instead of a set, so we
267
270
  # warn if the value would have been changed. In Chef 13, it will be
268
271
  # equivalent to value = nil.
@@ -670,5 +673,9 @@ class Chef
670
673
 
671
674
  result
672
675
  end
676
+
677
+ def nillable?
678
+ !!options[:nillable]
679
+ end
673
680
  end
674
681
  end
@@ -32,6 +32,14 @@ class Chef
32
32
  class Provider
33
33
  require "chef/mixin/why_run"
34
34
  require "chef/mixin/provides"
35
+
36
+ attr_accessor :new_resource
37
+ attr_accessor :current_resource
38
+ attr_accessor :run_context
39
+
40
+ attr_reader :recipe_name
41
+ attr_reader :cookbook_name
42
+
35
43
  include Chef::Mixin::WhyRun
36
44
  extend Chef::Mixin::Provides
37
45
 
@@ -43,13 +51,6 @@ class Chef
43
51
  true
44
52
  end
45
53
 
46
- attr_accessor :new_resource
47
- attr_accessor :current_resource
48
- attr_accessor :run_context
49
-
50
- attr_reader :recipe_name
51
- attr_reader :cookbook_name
52
-
53
54
  #--
54
55
  # TODO: this should be a reader, and the action should be passed in the
55
56
  # constructor; however, many/most subclasses override the constructor so
@@ -239,13 +239,15 @@ class Chef
239
239
 
240
240
  uri = '"' + uri + '"' unless uri.start_with?("'", '"')
241
241
  components = Array(components).join(" ")
242
- options = ""
243
- options << "arch=#{arch} " if arch
242
+ options = []
243
+ options << "arch=#{arch}" if arch
244
244
  options << "trusted=yes" if trusted
245
- options = "[#{options}]" unless options.empty?
246
- info = "#{options} #{uri} #{distribution} #{components}\n".lstrip
247
- repo = "deb #{info}"
248
- repo << "deb-src #{info}" if add_src
245
+ optstr = unless options.empty?
246
+ "[" + options.join(" ") + "]"
247
+ end
248
+ info = [ optstr, uri, distribution, components ].compact.join(" ")
249
+ repo = "deb #{info}\n"
250
+ repo << "deb-src #{info}\n" if add_src
249
251
  repo
250
252
  end
251
253
  end
@@ -50,7 +50,21 @@ class Chef
50
50
  # Make sure the parent dir exists, or else fail.
51
51
  # for why run, print a message explaining the potential error.
52
52
  parent_directory = ::File.dirname(@new_resource.path)
53
- a.assertion { @new_resource.recursive || ::File.directory?(parent_directory) }
53
+ a.assertion do
54
+ if @new_resource.recursive
55
+ does_parent_exist = lambda do |base_dir|
56
+ base_dir = ::File.dirname(base_dir)
57
+ if ::File.exist?(base_dir)
58
+ ::File.directory?(base_dir)
59
+ else
60
+ does_parent_exist.call(base_dir)
61
+ end
62
+ end
63
+ does_parent_exist.call(@new_resource.path)
64
+ else
65
+ ::File.directory?(parent_directory)
66
+ end
67
+ end
54
68
  a.failure_message(Chef::Exceptions::EnclosingDirectoryDoesNotExist, "Parent directory #{parent_directory} does not exist, cannot create #{@new_resource.path}")
55
69
  a.whyrun("Assuming directory #{parent_directory} would have been created")
56
70
  end
@@ -36,7 +36,7 @@ class Chef
36
36
  obj.variablevalue = @new_resource.value
37
37
  obj.put_
38
38
  value = @new_resource.value
39
- value = expand_path(value) if @new_resource.key_name.upcase == "PATH"
39
+ value = expand_path(value) if @new_resource.key_name.casecmp("PATH").zero?
40
40
  ENV[@new_resource.key_name] = value
41
41
  broadcast_env_change
42
42
  end
@@ -51,6 +51,7 @@ class Chef
51
51
  command << " --chunk=#{@new_resource.chunk}" unless @new_resource.level == 1
52
52
  command << " --metadata=#{@new_resource.metadata}"
53
53
  command << " --bitmap=#{@new_resource.bitmap}" if @new_resource.bitmap
54
+ command << " --layout=#{@new_resource.layout}" if @new_resource.layout
54
55
  command << " --raid-devices #{@new_resource.devices.length} #{@new_resource.devices.join(" ")}"
55
56
  Chef::Log.debug("#{@new_resource} mdadm command: #{command}")
56
57
  shell_out!(command)
@@ -112,6 +112,7 @@ class Chef
112
112
  end
113
113
 
114
114
  def install_package(name, version)
115
+ Chef.log_deprecation("The easy_install package provider is deprecated and will be removed in Chef 13.")
115
116
  run_command(:command => "#{easy_install_binary_path}#{expand_options(@new_resource.options)} \"#{name}==#{version}\"")
116
117
  end
117
118
 
@@ -120,6 +121,7 @@ class Chef
120
121
  end
121
122
 
122
123
  def remove_package(name, version)
124
+ Chef.log_deprecation("The easy_install package provider is deprecated and will be removed in Chef 13.")
123
125
  run_command(:command => "#{easy_install_binary_path }#{expand_options(@new_resource.options)} -m #{name}")
124
126
  end
125
127
 
@@ -517,7 +517,9 @@ class Chef
517
517
  install_via_gem_command(name, version)
518
518
  end
519
519
  elsif @new_resource.gem_binary.nil?
520
- @gem_env.install(@new_resource.source)
520
+ # domain is used by Gem::DependencyInstaller rather than by Chef code
521
+ # domain can be :local, :remote or :both
522
+ @gem_env.install(@new_resource.source, domain: :local)
521
523
  else
522
524
  install_via_gem_command(name, version)
523
525
  end
@@ -531,6 +533,7 @@ class Chef
531
533
  def install_via_gem_command(name, version)
532
534
  if @new_resource.source =~ /\.gem$/i
533
535
  name = @new_resource.source
536
+ src = " --local" unless source_is_remote?
534
537
  elsif @new_resource.clear_sources
535
538
  src = " --clear-sources"
536
539
  src << (@new_resource.source && " --source=#{@new_resource.source}" || "")
@@ -260,7 +260,7 @@ class Chef
260
260
  if source_location.nil?
261
261
  inferred_registry_type == :msi
262
262
  else
263
- ::File.extname(source_location).downcase == ".msi"
263
+ ::File.extname(source_location).casecmp(".msi").zero?
264
264
  end
265
265
  end
266
266
  end
@@ -34,14 +34,13 @@ class Chef
34
34
  # == Chef::Recipe
35
35
  # A Recipe object is the context in which Chef recipes are evaluated.
36
36
  class Recipe
37
+ attr_accessor :cookbook_name, :recipe_name, :recipe, :params, :run_context
37
38
 
38
39
  include Chef::DSL::Recipe
39
40
 
40
41
  include Chef::Mixin::FromFile
41
42
  include Chef::Mixin::Deprecation
42
43
 
43
- attr_accessor :cookbook_name, :recipe_name, :recipe, :params, :run_context
44
-
45
44
  # Parses a potentially fully-qualified recipe name into its
46
45
  # cookbook name and recipe short name.
47
46
  #
@@ -26,17 +26,17 @@ class Chef
26
26
 
27
27
  property :repo_name, String, name_property: true
28
28
  property :uri, String
29
- property :distribution, String, default: lazy { node["lsb"]["codename"] }
29
+ property :distribution, [ String, nil, false ], default: lazy { node["lsb"]["codename"] }, nillable: true, coerce: proc { |x| x ? x : nil }
30
30
  property :components, Array, default: []
31
- property :arch, [String, nil], default: nil
31
+ property :arch, [String, nil, false], default: nil, nillable: true, coerce: proc { |x| x ? x : nil }
32
32
  property :trusted, [TrueClass, FalseClass], default: false
33
33
  # whether or not to add the repository as a source repo, too
34
34
  property :deb_src, [TrueClass, FalseClass], default: false
35
- property :keyserver, [String, nil], default: "keyserver.ubuntu.com"
36
- property :key, [String, nil], default: nil
37
- property :key_proxy, [String, nil], default: nil
35
+ property :keyserver, [String, nil, false], default: "keyserver.ubuntu.com", nillable: true, coerce: proc { |x| x ? x : nil }
36
+ property :key, [String, nil, false], default: nil, nillable: true, coerce: proc { |x| x ? x : nil }
37
+ property :key_proxy, [String, nil, false], default: nil, nillable: true, coerce: proc { |x| x ? x : nil }
38
38
 
39
- property :cookbook, [String, nil], default: nil, desired_state: false
39
+ property :cookbook, [String, nil, false], default: nil, desired_state: false, nillable: true, coerce: proc { |x| x ? x : nil }
40
40
  property :cache_rebuild, [TrueClass, FalseClass], default: true, desired_state: false
41
41
  property :sensitive, [TrueClass, FalseClass], default: false, desired_state: false
42
42
 
@@ -40,6 +40,7 @@ class Chef
40
40
  @metadata = "0.90"
41
41
  @bitmap = nil
42
42
  @raid_device = name
43
+ @layout = nil
43
44
  end
44
45
 
45
46
  def chunk(arg = nil)
@@ -98,6 +99,14 @@ class Chef
98
99
  )
99
100
  end
100
101
 
102
+ def layout(arg = nil)
103
+ set_or_return(
104
+ :layout,
105
+ arg,
106
+ :kind_of => [ String ]
107
+ )
108
+ end
109
+
101
110
  end
102
111
  end
103
112
  end
@@ -59,6 +59,11 @@ class Chef
59
59
  end
60
60
  end
61
61
 
62
+ def delete(key)
63
+ resource_list.delete(key)
64
+ resource_set.delete(key)
65
+ end
66
+
62
67
  # @deprecated
63
68
  def []=(index, resource)
64
69
  Chef::Log.warn("`[]=` is deprecated, use `insert` (which only inserts at the end)")
@@ -67,6 +67,16 @@ class Chef
67
67
  end
68
68
  end
69
69
 
70
+ def delete(key)
71
+ raise ArgumentError, "Must pass a Chef::Resource or String to delete" unless key.is_a?(String) || key.is_a?(Chef::Resource)
72
+ key = key.to_s
73
+ ret = @resources.reject! { |r| r.to_s == key }
74
+ if ret.nil?
75
+ raise Chef::Exceptions::ResourceNotFound, "Cannot find a resource matching #{key} (did you define it first?)"
76
+ end
77
+ ret
78
+ end
79
+
70
80
  # @deprecated - can be removed when it is removed from resource_collection.rb
71
81
  def []=(index, resource)
72
82
  @resources[index] = resource
@@ -49,18 +49,22 @@ class Chef
49
49
  end
50
50
 
51
51
  def lookup(key)
52
- case
53
- when key.kind_of?(String)
54
- lookup_by = key
55
- when key.kind_of?(Chef::Resource)
56
- lookup_by = create_key(key.resource_name, key.name)
57
- else
58
- raise ArgumentError, "Must pass a Chef::Resource or String to lookup"
52
+ raise ArgumentError, "Must pass a Chef::Resource or String to lookup" unless key.is_a?(String) || key.is_a?(Chef::Resource)
53
+ key = key.to_s
54
+ res = @resources_by_key[key]
55
+ unless res
56
+ raise Chef::Exceptions::ResourceNotFound, "Cannot find a resource matching #{key} (did you define it first?)"
59
57
  end
58
+ res
59
+ end
60
60
 
61
- res = @resources_by_key[lookup_by]
62
- unless res
63
- raise Chef::Exceptions::ResourceNotFound, "Cannot find a resource matching #{lookup_by} (did you define it first?)"
61
+ def delete(key)
62
+ raise ArgumentError, "Must pass a Chef::Resource or String to delete" unless key.is_a?(String) || key.is_a?(Chef::Resource)
63
+ key = key.to_s
64
+ res = @resources_by_key.delete(key)
65
+
66
+ if res == @resources_by_key.default
67
+ raise Chef::Exceptions::ResourceNotFound, "Cannot find a resource matching #{key} (did you define it first?)"
64
68
  end
65
69
  res
66
70
  end
@@ -164,7 +168,6 @@ class Chef
164
168
  end
165
169
  return results
166
170
  end
167
-
168
171
  end
169
172
  end
170
173
  end
@@ -21,7 +21,7 @@
21
21
 
22
22
  class Chef
23
23
  CHEF_ROOT = File.expand_path("../..", __FILE__)
24
- VERSION = "12.9.41"
24
+ VERSION = "12.10.24"
25
25
  end
26
26
 
27
27
  #
@@ -83,10 +83,8 @@ E
83
83
  after(:each) do
84
84
  Chef::Config[:file_cache_path] = @old_file_cache_path
85
85
  FileUtils.remove_entry_secure deploy_directory if File.exist?(deploy_directory)
86
+ FileUtils.remove_entry_secure base_dir_path
86
87
  FileUtils.remove_entry_secure file_cache_path
87
- end
88
-
89
- after(:all) do
90
88
  FileUtils.remove_entry_secure origin_repo_dir
91
89
  end
92
90
 
@@ -81,7 +81,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
81
81
 
82
82
  if user && domain != "."
83
83
  computer_name = ENV["computername"]
84
- domain.downcase != computer_name.downcase
84
+ !domain.casecmp(computer_name.downcase).zero?
85
85
  end
86
86
  end
87
87
 
@@ -269,12 +269,12 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
269
269
  describe "when removing members" do
270
270
  it "does not raise an error for a non well-formed domain name" do
271
271
  group_resource.excluded_members [invalid_domain_user_name]
272
- expect { group_resource.run_action(tested_action) }.to_not raise_error Chef::Exceptions::Win32APIError
272
+ expect { group_resource.run_action(tested_action) }.to_not raise_error
273
273
  end
274
274
 
275
275
  it "does not raise an error for a nonexistent domain" do
276
276
  group_resource.excluded_members [nonexistent_domain_user_name]
277
- expect { group_resource.run_action(tested_action) }.to_not raise_error Chef::Exceptions::Win32APIError
277
+ expect { group_resource.run_action(tested_action) }.to_not raise_error
278
278
  end
279
279
  end
280
280
  end
@@ -368,7 +368,7 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
368
368
 
369
369
  describe "when there is no group" do
370
370
  it "should raise an error" do
371
- expect { group_resource.run_action(:modify) }.to raise_error
371
+ expect { group_resource.run_action(:modify) }.to raise_error(Chef::Exceptions::Group)
372
372
  end
373
373
  end
374
374
 
@@ -401,7 +401,7 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
401
401
  end
402
402
 
403
403
  it "raises an error on modify" do
404
- expect { group_resource.run_action(:modify) }.to raise_error
404
+ expect { group_resource.run_action(:modify) }.to raise_error(Chef::Exceptions::Group)
405
405
  end
406
406
 
407
407
  it "does not raise an error on manage" do