chef 12.9.38 → 12.9.41

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
  4. data/lib/chef/chef_fs/command_line.rb +1 -2
  5. data/lib/chef/chef_fs/file_system.rb +1 -3
  6. data/lib/chef/chef_fs/file_system/already_exists_error.rb +2 -10
  7. data/lib/chef/chef_fs/file_system/base_fs_object.rb +1 -1
  8. data/lib/chef/chef_fs/file_system/chef_server/acl_dir.rb +1 -1
  9. data/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb +1 -3
  10. data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +1 -1
  11. data/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb +1 -2
  12. data/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb +1 -2
  13. data/lib/chef/chef_fs/file_system/chef_server/environments_dir.rb +1 -2
  14. data/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb +1 -1
  15. data/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb +1 -3
  16. data/lib/chef/chef_fs/file_system/chef_server/policy_groups_dir.rb +1 -1
  17. data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +1 -1
  18. data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +1 -2
  19. data/lib/chef/chef_fs/file_system/cookbook_frozen_error.rb +2 -10
  20. data/lib/chef/chef_fs/file_system/default_environment_cannot_be_modified_error.rb +2 -14
  21. data/lib/chef/chef_fs/file_system/exceptions.rb +98 -0
  22. data/lib/chef/chef_fs/file_system/file_system_error.rb +2 -26
  23. data/lib/chef/chef_fs/file_system/must_delete_recursively_error.rb +2 -10
  24. data/lib/chef/chef_fs/file_system/nonexistent_fs_object.rb +1 -1
  25. data/lib/chef/chef_fs/file_system/not_found_error.rb +2 -10
  26. data/lib/chef/chef_fs/file_system/operation_failed_error.rb +2 -24
  27. data/lib/chef/chef_fs/file_system/operation_not_allowed_error.rb +2 -28
  28. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +1 -1
  29. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  30. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_entry.rb +1 -1
  31. data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
  32. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -3
  33. data/lib/chef/dsl/core.rb +7 -5
  34. data/lib/chef/knife/show.rb +1 -1
  35. data/lib/chef/mixin/notifying_block.rb +53 -0
  36. data/lib/chef/provider/group.rb +7 -0
  37. data/lib/chef/provider/group/windows.rb +19 -6
  38. data/lib/chef/version.rb +1 -1
  39. data/spec/functional/resource/group_spec.rb +4 -4
  40. data/spec/integration/recipes/notifying_block_spec.rb +111 -0
  41. data/spec/unit/provider/group/windows_spec.rb +9 -1
  42. metadata +8 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a3ac4ddf35d84243c1bc31c4f5ec01d99e684b2
4
- data.tar.gz: ba7c45fd6ece09421f4c322c9a3273514cc61172
3
+ metadata.gz: f930659fc8f0413f464d687e747daef788684715
4
+ data.tar.gz: db7f21240e101ec0b50a37f96c6b5d556c9890de
5
5
  SHA512:
6
- metadata.gz: 5fb2ad9b1cceb5c41cc4f6325b7c6ccdb2fcc6e6c5a8cfc516fb4c6dc77462ffdca4e9ce66cb60d164b791ecb5b800a5d67d4037df2ac48f02e9bc3a83be9247
7
- data.tar.gz: ccdb5799bd2bb26231864adfa72be8c63eb850ba3c61284ea8bd4eb25c32cb0081f76fd40240932a6121351512f8177f71eceb8bda1b9f321f18fad72d5238f9
6
+ metadata.gz: c92e90df62da0f90ae4262a04a81e12df2d34289942d02152ae67689657eba41456f8a5d8a751683aa8b46af34a88ce57ee728da415152813df92493aebb9329
7
+ data.tar.gz: eb2c3be9b98d532dbd199abf24c2a5933df23149b7432382f7387b4eeb1e14c30ab5af11e48d5f0548a982169f50280300836f4cd6f43a76109707708a469d43
data/VERSION CHANGED
@@ -1 +1 @@
1
- 12.9.38
1
+ 12.9.41
@@ -22,7 +22,7 @@ require "chef_zero/data_store/data_already_exists_error"
22
22
  require "chef_zero/data_store/data_not_found_error"
23
23
  require "chef/chef_fs/file_pattern"
24
24
  require "chef/chef_fs/file_system"
25
- require "chef/chef_fs/file_system/not_found_error"
25
+ require "chef/chef_fs/file_system/exceptions"
26
26
  require "chef/chef_fs/file_system/memory/memory_root"
27
27
  require "fileutils"
28
28
 
@@ -17,8 +17,7 @@
17
17
  #
18
18
 
19
19
  require "chef/chef_fs/file_system"
20
- require "chef/chef_fs/file_system/operation_failed_error"
21
- require "chef/chef_fs/file_system/operation_not_allowed_error"
20
+ require "chef/chef_fs/file_system/exceptions"
22
21
  require "chef/util/diff"
23
22
 
24
23
  class Chef
@@ -17,9 +17,7 @@
17
17
  #
18
18
 
19
19
  require "chef/chef_fs/path_utils"
20
- require "chef/chef_fs/file_system/default_environment_cannot_be_modified_error"
21
- require "chef/chef_fs/file_system/operation_failed_error"
22
- require "chef/chef_fs/file_system/operation_not_allowed_error"
20
+ require "chef/chef_fs/file_system/exceptions"
23
21
  require "chef/chef_fs/parallelizer"
24
22
 
25
23
  class Chef
@@ -16,13 +16,5 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "chef/chef_fs/file_system/operation_failed_error"
20
-
21
- class Chef
22
- module ChefFS
23
- module FileSystem
24
- class AlreadyExistsError < OperationFailedError
25
- end
26
- end
27
- end
28
- end
19
+ require "chef/chef_fs/file_system/exceptions"
20
+ Chef.log_deprecation "Individual ChefFS error files are deprecated. Please require 'chef/chef_fs/file_system/exceptions' rather than 'chef/chef_fs/file_system/#{File.basename(__FILE__, ".rb")}'."
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require "chef/chef_fs/path_utils"
20
- require "chef/chef_fs/file_system/operation_not_allowed_error"
20
+ require "chef/chef_fs/file_system/exceptions"
21
21
 
22
22
  class Chef
23
23
  module ChefFS
@@ -18,7 +18,7 @@
18
18
 
19
19
  require "chef/chef_fs/file_system/base_fs_dir"
20
20
  require "chef/chef_fs/file_system/chef_server/acl_entry"
21
- require "chef/chef_fs/file_system/operation_not_allowed_error"
21
+ require "chef/chef_fs/file_system/exceptions"
22
22
 
23
23
  class Chef
24
24
  module ChefFS
@@ -17,9 +17,7 @@
17
17
  #
18
18
 
19
19
  require "chef/chef_fs/file_system/chef_server/rest_list_entry"
20
- require "chef/chef_fs/file_system/not_found_error"
21
- require "chef/chef_fs/file_system/operation_not_allowed_error"
22
- require "chef/chef_fs/file_system/operation_failed_error"
20
+ require "chef/chef_fs/file_system/exceptions"
23
21
 
24
22
  class Chef
25
23
  module ChefFS
@@ -20,7 +20,7 @@ require "chef/chef_fs/command_line"
20
20
  require "chef/chef_fs/file_system/chef_server/rest_list_dir"
21
21
  require "chef/chef_fs/file_system/chef_server/cookbook_subdir"
22
22
  require "chef/chef_fs/file_system/chef_server/cookbook_file"
23
- require "chef/chef_fs/file_system/not_found_error"
23
+ require "chef/chef_fs/file_system/exceptions"
24
24
  require "chef/cookbook_version"
25
25
  require "chef/cookbook_uploader"
26
26
 
@@ -18,8 +18,7 @@
18
18
 
19
19
  require "chef/chef_fs/file_system/chef_server/rest_list_dir"
20
20
  require "chef/chef_fs/file_system/chef_server/cookbook_dir"
21
- require "chef/chef_fs/file_system/operation_failed_error"
22
- require "chef/chef_fs/file_system/cookbook_frozen_error"
21
+ require "chef/chef_fs/file_system/exceptions"
23
22
  require "chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir"
24
23
  require "chef/mixin/file_class"
25
24
 
@@ -17,8 +17,7 @@
17
17
  #
18
18
 
19
19
  require "chef/chef_fs/file_system/chef_server/rest_list_dir"
20
- require "chef/chef_fs/file_system/not_found_error"
21
- require "chef/chef_fs/file_system/must_delete_recursively_error"
20
+ require "chef/chef_fs/file_system/exceptions"
22
21
  require "chef/chef_fs/data_handler/data_bag_item_data_handler"
23
22
 
24
23
  class Chef
@@ -18,8 +18,7 @@
18
18
 
19
19
  require "chef/chef_fs/file_system/base_fs_dir"
20
20
  require "chef/chef_fs/file_system/chef_server/rest_list_entry"
21
- require "chef/chef_fs/file_system/not_found_error"
22
- require "chef/chef_fs/file_system/default_environment_cannot_be_modified_error"
21
+ require "chef/chef_fs/file_system/exceptions"
23
22
 
24
23
  class Chef
25
24
  module ChefFS
@@ -18,7 +18,7 @@
18
18
 
19
19
  require "chef/chef_fs/file_system/base_fs_dir"
20
20
  require "chef/chef_fs/file_system/chef_server/rest_list_entry"
21
- require "chef/chef_fs/file_system/not_found_error"
21
+ require "chef/chef_fs/file_system/exceptions"
22
22
  require "chef/chef_fs/data_handler/node_data_handler"
23
23
 
24
24
  class Chef
@@ -16,9 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "chef/chef_fs/file_system/already_exists_error"
20
- require "chef/chef_fs/file_system/not_found_error"
21
- require "chef/chef_fs/file_system/operation_failed_error"
19
+ require "chef/chef_fs/file_system/exceptions"
22
20
 
23
21
  class Chef
24
22
  module ChefFS
@@ -18,7 +18,7 @@
18
18
 
19
19
  require "chef/chef_fs/file_system/base_fs_dir"
20
20
  require "chef/chef_fs/file_system/chef_server/rest_list_entry"
21
- require "chef/chef_fs/file_system/not_found_error"
21
+ require "chef/chef_fs/file_system/exceptions"
22
22
  require "chef/chef_fs/file_system/chef_server/policy_group_entry"
23
23
 
24
24
  class Chef
@@ -18,7 +18,7 @@
18
18
 
19
19
  require "chef/chef_fs/file_system/base_fs_dir"
20
20
  require "chef/chef_fs/file_system/chef_server/rest_list_entry"
21
- require "chef/chef_fs/file_system/not_found_error"
21
+ require "chef/chef_fs/file_system/exceptions"
22
22
 
23
23
  class Chef
24
24
  module ChefFS
@@ -17,8 +17,7 @@
17
17
  #
18
18
 
19
19
  require "chef/chef_fs/file_system/base_fs_object"
20
- require "chef/chef_fs/file_system/not_found_error"
21
- require "chef/chef_fs/file_system/operation_failed_error"
20
+ require "chef/chef_fs/file_system/exceptions"
22
21
  require "chef/role"
23
22
  require "chef/node"
24
23
  require "chef/json_compat"
@@ -16,13 +16,5 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "chef/chef_fs/file_system/already_exists_error"
20
-
21
- class Chef
22
- module ChefFS
23
- module FileSystem
24
- class CookbookFrozenError < AlreadyExistsError
25
- end
26
- end
27
- end
28
- end
19
+ require "chef/chef_fs/file_system/exceptions"
20
+ Chef.log_deprecation "Individual ChefFS error files are deprecated. Please require 'chef/chef_fs/file_system/exceptions' rather than 'chef/chef_fs/file_system/#{File.basename(__FILE__, ".rb")}'."
@@ -16,17 +16,5 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "chef/chef_fs/file_system/operation_not_allowed_error"
20
-
21
- class Chef
22
- module ChefFS
23
- module FileSystem
24
- class DefaultEnvironmentCannotBeModifiedError < OperationNotAllowedError
25
- def reason
26
- result = super
27
- result + " (default environment cannot be modified)"
28
- end
29
- end
30
- end
31
- end
32
- end
19
+ require "chef/chef_fs/file_system/exceptions"
20
+ Chef.log_deprecation "Individual ChefFS error files are deprecated. Please require 'chef/chef_fs/file_system/exceptions' rather than 'chef/chef_fs/file_system/#{File.basename(__FILE__, ".rb")}'."
@@ -0,0 +1,98 @@
1
+ #
2
+ # Author:: Thom May (<thom@chef.io>)
3
+ # Copyright:: Copyright 2012-2016, Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ class Chef
20
+ module ChefFS
21
+ module FileSystem
22
+ class FileSystemError < StandardError
23
+ # @param entry The entry which had an issue.
24
+ # @param cause The wrapped exception (if any).
25
+ # @param reason A string describing why this exception happened.
26
+ def initialize(entry, cause = nil, reason = nil)
27
+ super(reason)
28
+ @entry = entry
29
+ @cause = cause
30
+ @reason = reason
31
+ end
32
+
33
+ # The entry which had an issue.
34
+ attr_reader :entry
35
+
36
+ # The wrapped exception (if any).
37
+ attr_reader :cause
38
+
39
+ # A string describing why this exception happened.
40
+ attr_reader :reason
41
+ end
42
+
43
+ class MustDeleteRecursivelyError < FileSystemError; end
44
+
45
+ class NotFoundError < FileSystemError; end
46
+
47
+ class OperationFailedError < FileSystemError
48
+ def initialize(operation, entry, cause = nil, reason = nil)
49
+ super(entry, cause, reason)
50
+ @operation = operation
51
+ end
52
+
53
+ def message
54
+ if cause && cause.is_a?(Net::HTTPExceptions) && cause.response.code == "400"
55
+ "#{super} cause: #{cause.response.body}"
56
+ else
57
+ super
58
+ end
59
+ end
60
+
61
+ attr_reader :operation
62
+ end
63
+
64
+ class OperationNotAllowedError < FileSystemError
65
+ def initialize(operation, entry, cause = nil, reason = nil)
66
+ reason ||=
67
+ case operation
68
+ when :delete
69
+ "cannot be deleted"
70
+ when :write
71
+ "cannot be updated"
72
+ when :create_child
73
+ "cannot have a child created under it"
74
+ when :read
75
+ "cannot be read"
76
+ end
77
+ super(entry, cause, reason)
78
+ @operation = operation
79
+ end
80
+
81
+ attr_reader :operation
82
+ attr_reader :entry
83
+ end
84
+
85
+ class AlreadyExistsError < OperationFailedError; end
86
+
87
+ class CookbookFrozenError < AlreadyExistsError; end
88
+
89
+ class DefaultEnvironmentCannotBeModifiedError < OperationNotAllowedError
90
+ def reason
91
+ result = super
92
+ result + " (default environment cannot be modified)"
93
+ end
94
+ end
95
+
96
+ end
97
+ end
98
+ end
@@ -16,29 +16,5 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- class Chef
20
- module ChefFS
21
- module FileSystem
22
- class FileSystemError < StandardError
23
- # @param entry The entry which had an issue.
24
- # @param cause The wrapped exception (if any).
25
- # @param reason A string describing why this exception happened.
26
- def initialize(entry, cause = nil, reason = nil)
27
- super(reason)
28
- @entry = entry
29
- @cause = cause
30
- @reason = reason
31
- end
32
-
33
- # The entry which had an issue.
34
- attr_reader :entry
35
-
36
- # The wrapped exception (if any).
37
- attr_reader :cause
38
-
39
- # A string describing why this exception happened.
40
- attr_reader :reason
41
- end
42
- end
43
- end
44
- end
19
+ require "chef/chef_fs/file_system/exceptions"
20
+ Chef.log_deprecation "Individual ChefFS error files are deprecated. Please require 'chef/chef_fs/file_system/exceptions' rather than 'chef/chef_fs/file_system/#{File.basename(__FILE__, ".rb")}'."
@@ -16,13 +16,5 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "chef/chef_fs/file_system/file_system_error"
20
-
21
- class Chef
22
- module ChefFS
23
- module FileSystem
24
- class MustDeleteRecursivelyError < FileSystemError
25
- end
26
- end
27
- end
28
- end
19
+ require "chef/chef_fs/file_system/exceptions"
20
+ Chef.log_deprecation "Individual ChefFS error files are deprecated. Please require 'chef/chef_fs/file_system/exceptions' rather than 'chef/chef_fs/file_system/#{File.basename(__FILE__, ".rb")}'."
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require "chef/chef_fs/file_system/base_fs_object"
20
- require "chef/chef_fs/file_system/not_found_error"
20
+ require "chef/chef_fs/file_system/exceptions"
21
21
 
22
22
  class Chef
23
23
  module ChefFS
@@ -16,13 +16,5 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "chef/chef_fs/file_system/file_system_error"
20
-
21
- class Chef
22
- module ChefFS
23
- module FileSystem
24
- class NotFoundError < FileSystemError
25
- end
26
- end
27
- end
28
- end
19
+ require "chef/chef_fs/file_system/exceptions"
20
+ Chef.log_deprecation "Individual ChefFS error files are deprecated. Please require 'chef/chef_fs/file_system/exceptions' rather than 'chef/chef_fs/file_system/#{File.basename(__FILE__, ".rb")}'."
@@ -16,27 +16,5 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "chef/chef_fs/file_system/file_system_error"
20
-
21
- class Chef
22
- module ChefFS
23
- module FileSystem
24
- class OperationFailedError < FileSystemError
25
- def initialize(operation, entry, cause = nil, reason = nil)
26
- super(entry, cause, reason)
27
- @operation = operation
28
- end
29
-
30
- def message
31
- if cause && cause.is_a?(Net::HTTPExceptions) && cause.response.code == "400"
32
- "#{super} cause: #{cause.response.body}"
33
- else
34
- super
35
- end
36
- end
37
-
38
- attr_reader :operation
39
- end
40
- end
41
- end
42
- end
19
+ require "chef/chef_fs/file_system/exceptions"
20
+ Chef.log_deprecation "Individual ChefFS error files are deprecated. Please require 'chef/chef_fs/file_system/exceptions' rather than 'chef/chef_fs/file_system/#{File.basename(__FILE__, ".rb")}'."
@@ -16,31 +16,5 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "chef/chef_fs/file_system/file_system_error"
20
-
21
- class Chef
22
- module ChefFS
23
- module FileSystem
24
- class OperationNotAllowedError < FileSystemError
25
- def initialize(operation, entry, cause = nil, reason = nil)
26
- reason ||=
27
- case operation
28
- when :delete
29
- "cannot be deleted"
30
- when :write
31
- "cannot be updated"
32
- when :create_child
33
- "cannot have a child created under it"
34
- when :read
35
- "cannot be read"
36
- end
37
- super(entry, cause, reason)
38
- @operation = operation
39
- end
40
-
41
- attr_reader :operation
42
- attr_reader :entry
43
- end
44
- end
45
- end
46
- end
19
+ require "chef/chef_fs/file_system/exceptions"
20
+ Chef.log_deprecation "Individual ChefFS error files are deprecated. Please require 'chef/chef_fs/file_system/exceptions' rather than 'chef/chef_fs/file_system/#{File.basename(__FILE__, ".rb")}'."
@@ -19,7 +19,7 @@
19
19
  require "chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry"
20
20
  require "chef/chef_fs/file_system/chef_server/cookbook_dir"
21
21
  require "chef/chef_fs/file_system/chef_server/versioned_cookbook_dir"
22
- require "chef/chef_fs/file_system/not_found_error"
22
+ require "chef/chef_fs/file_system/exceptions"
23
23
  require "chef/cookbook/cookbook_version_loader"
24
24
 
25
25
  class Chef
@@ -18,7 +18,7 @@
18
18
 
19
19
  require "chef/chef_fs/file_system/repository/chef_repository_file_system_entry"
20
20
  require "chef/chef_fs/file_system/repository/cookbooks_dir"
21
- require "chef/chef_fs/file_system/not_found_error"
21
+ require "chef/chef_fs/file_system/exceptions"
22
22
 
23
23
  class Chef
24
24
  module ChefFS
@@ -18,7 +18,7 @@
18
18
  #
19
19
 
20
20
  require "chef/chef_fs/file_system/repository/file_system_entry"
21
- require "chef/chef_fs/file_system/not_found_error"
21
+ require "chef/chef_fs/file_system/exceptions"
22
22
 
23
23
  class Chef
24
24
  module ChefFS
@@ -54,7 +54,7 @@ class Chef
54
54
  possible_child.dir? == is_dir && possible_child.name_valid?
55
55
  end
56
56
 
57
- # Public API callied by chef_fs/file_system
57
+ # Public API called by chef_fs/file_system
58
58
  def dir?
59
59
  true
60
60
  end
@@ -18,9 +18,7 @@
18
18
 
19
19
  require "chef/chef_fs/file_system/base_fs_dir"
20
20
  require "chef/chef_fs/file_system/chef_server/rest_list_dir"
21
- require "chef/chef_fs/file_system/already_exists_error"
22
- require "chef/chef_fs/file_system/must_delete_recursively_error"
23
- require "chef/chef_fs/file_system/not_found_error"
21
+ require "chef/chef_fs/file_system/exceptions"
24
22
  require "chef/chef_fs/path_utils"
25
23
  require "fileutils"
26
24
 
@@ -17,15 +17,16 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require "chef/mixin/shell_out"
21
- require "chef/mixin/powershell_out"
22
20
  require "chef/dsl/declare_resource"
21
+ require "chef/mixin/notifying_block"
22
+ require "chef/mixin/powershell_out"
23
+ require "chef/mixin/shell_out"
23
24
 
24
25
  class Chef
25
26
  module DSL
26
27
  # This is the "Core DSL" with various bits of Sugar that are mixed into core providers as well
27
28
  # as user LWRPs. This module deliberately does not mixin the Resources or Defintions DSL bits
28
- # so that cookbooks are not injeting random things into the samespace of core providers.
29
+ # so that cookbooks are not injeting random things into the namespace of core providers.
29
30
  #
30
31
  # - If you are writing cookbooks: you have come to the wrong place, please inject things into
31
32
  # Chef::DSL::Recipe instead.
@@ -34,9 +35,10 @@ class Chef
34
35
  # into here.
35
36
  #
36
37
  module Core
37
- include Chef::Mixin::ShellOut
38
- include Chef::Mixin::PowershellOut
39
38
  include Chef::DSL::DeclareResource
39
+ include Chef::Mixin::NotifyingBlock
40
+ include Chef::Mixin::PowershellOut
41
+ include Chef::Mixin::ShellOut
40
42
  end
41
43
  end
42
44
  end
@@ -9,7 +9,7 @@ class Chef
9
9
 
10
10
  deps do
11
11
  require "chef/chef_fs/file_system"
12
- require "chef/chef_fs/file_system/not_found_error"
12
+ require "chef/chef_fs/file_system/exceptions"
13
13
  end
14
14
 
15
15
  option :local,
@@ -0,0 +1,53 @@
1
+ #--
2
+ # Author:: Lamont Granquist <lamont@chef.io>
3
+ # Copyright:: Copyright 2010-2016, Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ class Chef
19
+ module Mixin
20
+ module NotifyingBlock
21
+
22
+ def notifying_block(&block)
23
+ begin
24
+ subcontext = subcontext_block(&block)
25
+ Chef::Runner.new(subcontext).converge
26
+ ensure
27
+ # recipes don't have a new_resource
28
+ if respond_to?(:new_resource)
29
+ if subcontext && subcontext.resource_collection.any?(&:updated?)
30
+ new_resource.updated_by_last_action(true)
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ def subcontext_block(parent_context = nil, &block)
37
+ parent_context ||= @run_context
38
+ sub_run_context = parent_context.create_child
39
+
40
+ begin
41
+ outer_run_context = @run_context
42
+ @run_context = sub_run_context
43
+ instance_eval(&block)
44
+ ensure
45
+ @run_context = outer_run_context
46
+ end
47
+
48
+ sub_run_context
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -94,6 +94,7 @@ class Chef
94
94
  missing_members = []
95
95
  @new_resource.members.each do |member|
96
96
  next if has_current_group_member?(member)
97
+ validate_member!(member)
97
98
  missing_members << member
98
99
  end
99
100
  if missing_members.length > 0
@@ -122,6 +123,12 @@ class Chef
122
123
  @current_resource.members.include?(member)
123
124
  end
124
125
 
126
+ def validate_member!(member)
127
+ # Sub-classes can do any validation if needed
128
+ # and raise an error if validation fails
129
+ true
130
+ end
131
+
125
132
  def action_create
126
133
  case @group_exists
127
134
  when false
@@ -61,7 +61,7 @@ class Chef
61
61
  if @new_resource.append
62
62
  members_to_be_added = [ ]
63
63
  @new_resource.members.each do |member|
64
- members_to_be_added << member if ! has_current_group_member?(member)
64
+ members_to_be_added << member if ! has_current_group_member?(member) && validate_member!(member)
65
65
  end
66
66
 
67
67
  # local_add_members will raise ERROR_MEMBER_IN_ALIAS if a
@@ -70,7 +70,7 @@ class Chef
70
70
 
71
71
  members_to_be_removed = [ ]
72
72
  @new_resource.excluded_members.each do |member|
73
- member_sid = local_group_name_to_sid(member)
73
+ member_sid = lookup_account_name(member)
74
74
  members_to_be_removed << member if has_current_group_member?(member)
75
75
  end
76
76
  @net_group.local_delete_members(members_to_be_removed) unless members_to_be_removed.empty?
@@ -80,7 +80,7 @@ class Chef
80
80
  end
81
81
 
82
82
  def has_current_group_member?(member)
83
- member_sid = local_group_name_to_sid(member)
83
+ member_sid = lookup_account_name(member)
84
84
  @current_resource.members.include?(member_sid)
85
85
  end
86
86
 
@@ -88,10 +88,23 @@ class Chef
88
88
  @net_group.local_delete
89
89
  end
90
90
 
91
- def local_group_name_to_sid(group_name)
92
- locally_qualified_name = group_name.include?("\\") ? group_name : "#{ENV['COMPUTERNAME']}\\#{group_name}"
93
- Chef::ReservedNames::Win32::Security.lookup_account_name(locally_qualified_name)[1].to_s
91
+ def locally_qualified_name(account_name)
92
+ account_name.include?("\\") ? account_name : "#{ENV['COMPUTERNAME']}\\#{account_name}"
94
93
  end
94
+
95
+ def validate_member!(member)
96
+ Chef::ReservedNames::Win32::Security.lookup_account_name(locally_qualified_name(member))[1].to_s
97
+ end
98
+
99
+ def lookup_account_name(account_name)
100
+ begin
101
+ Chef::ReservedNames::Win32::Security.lookup_account_name(locally_qualified_name(account_name))[1].to_s
102
+ rescue Chef::Exceptions::Win32APIError
103
+ Chef::Log.warn("SID for '#{locally_qualified_name(account_name)}' could not be found")
104
+ ""
105
+ end
106
+ end
107
+
95
108
  end
96
109
  end
97
110
  end
@@ -21,7 +21,7 @@
21
21
 
22
22
  class Chef
23
23
  CHEF_ROOT = File.expand_path("../..", __FILE__)
24
- VERSION = "12.9.38"
24
+ VERSION = "12.9.41"
25
25
  end
26
26
 
27
27
  #
@@ -267,14 +267,14 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
267
267
  end
268
268
 
269
269
  describe "when removing members" do
270
- it "raises an error for a non well-formed domain name" do
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 raise_error Chef::Exceptions::Win32APIError
272
+ expect { group_resource.run_action(tested_action) }.to_not raise_error Chef::Exceptions::Win32APIError
273
273
  end
274
274
 
275
- it "raises an error for a nonexistent domain" do
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 raise_error Chef::Exceptions::Win32APIError
277
+ expect { group_resource.run_action(tested_action) }.to_not raise_error Chef::Exceptions::Win32APIError
278
278
  end
279
279
  end
280
280
  end
@@ -0,0 +1,111 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@chef.io>)
3
+ # Copyright:: Copyright 2013-2016, Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ require "support/shared/integration/integration_helper"
19
+ require "chef/mixin/shell_out"
20
+
21
+ describe "notifying_block" do
22
+ include IntegrationSupport
23
+ include Chef::Mixin::ShellOut
24
+
25
+ let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
26
+ let(:chef_client) { "ruby '#{chef_dir}/chef-client' --minimal-ohai" }
27
+
28
+ when_the_repository "notifying_block test one" do
29
+ before do
30
+ directory "cookbooks/x" do
31
+ file "recipes/default.rb", <<-EOM
32
+ notifying_block do
33
+ log "gamma" do
34
+ action :nothing
35
+ end
36
+ log "alpha" do
37
+ notifies :write, "log[gamma]", :delayed
38
+ end
39
+ log "beta" do
40
+ notifies :write, "log[gamma]", :delayed
41
+ end
42
+ end
43
+ log "delta"
44
+ EOM
45
+ end
46
+ file "config/client.rb", <<-EOM
47
+ local_mode true
48
+ cookbook_path "#{path_to('cookbooks')}"
49
+ log_level :warn
50
+ EOM
51
+ end
52
+
53
+ # implicitly tests -
54
+ # 1. notifying block opens up a subcontext
55
+ # 2. delayed notifications are de-dup'd in the subcontext
56
+ # 3. delayed notifications (to resources inside the subcontext) are run at the end of the subcontext
57
+ it "should run alpha, beta, gamma, and delta in that order" do
58
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
59
+ expect(result.stdout).to match(/\* log\[alpha\] action write\s+\* log\[beta\] action write\s+\* log\[gamma\] action write\s+Converging 1 resources\s+\* log\[delta\] action write/)
60
+ result.error!
61
+ end
62
+ end
63
+
64
+ when_the_repository "notifying_block test two" do
65
+ before do
66
+ directory "cookbooks/x" do
67
+ file "resources/nb_test.rb", <<-EOM
68
+ default_action :run
69
+ provides :nb_test
70
+ resource_name :nb_test
71
+
72
+ action :run do
73
+ notifying_block do
74
+ log "foo" do
75
+ notifies :write, 'log[bar]', :delayed
76
+ end
77
+ end
78
+ end
79
+ EOM
80
+ file "recipes/default.rb", <<-EOM
81
+ log "bar" do
82
+ action :nothing
83
+ end
84
+ log "baz" do
85
+ action :nothing
86
+ end
87
+
88
+ nb_test "testing" do
89
+ notifies :write, 'log[baz]', :delayed
90
+ end
91
+
92
+ log "quux"
93
+ EOM
94
+ end
95
+ file "config/client.rb", <<-EOM
96
+ local_mode true
97
+ cookbook_path "#{path_to('cookbooks')}"
98
+ log_level :warn
99
+ EOM
100
+ end
101
+
102
+ # implicitly tests -
103
+ # 1. notifying block will correctly update wrapping new_resource updated_by_last_action status
104
+ # 2. delayed notifications from a subcontext inside a resource will notify resources in their outer run_context
105
+ it "should run foo, quux, bar, and baz in that order" do
106
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
107
+ expect(result.stdout).to match(/\* log\[foo\] action write\s+\* log\[quux\] action write\s+\* log\[bar\] action write\s+\* log\[baz\] action write/)
108
+ result.error!
109
+ end
110
+ end
111
+ end
@@ -51,11 +51,13 @@ describe Chef::Provider::Group::Windows do
51
51
  @new_resource.members([ "us" ])
52
52
  @current_resource = Chef::Resource::Group.new("staff")
53
53
  @current_resource.members %w{all your base}
54
+ @new_resource.excluded_members %w{all}
54
55
 
55
56
  allow(Chef::Util::Windows::NetGroup).to receive(:new).and_return(@net_group)
56
57
  allow(@net_group).to receive(:local_add_members)
57
58
  allow(@net_group).to receive(:local_set_members)
58
- allow(@provider).to receive(:local_group_name_to_sid)
59
+ allow(@provider).to receive(:lookup_account_name)
60
+ allow(@provider).to receive(:validate_member!).and_return(true)
59
61
  @provider.current_resource = @current_resource
60
62
  end
61
63
 
@@ -71,6 +73,12 @@ describe Chef::Provider::Group::Windows do
71
73
  @provider.manage_group
72
74
  end
73
75
 
76
+ it "should call @net_group.local_delete_members" do
77
+ allow(@new_resource).to receive(:append).and_return(true)
78
+ allow(@provider).to receive(:lookup_account_name).with("all").and_return("all")
79
+ expect(@net_group).to receive(:local_delete_members).with(@new_resource.excluded_members)
80
+ @provider.manage_group
81
+ end
74
82
  end
75
83
 
76
84
  describe "remove_group" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.9.38
4
+ version: 12.9.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-13 00:00:00.000000000 Z
11
+ date: 2016-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 12.9.38
19
+ version: 12.9.41
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 12.9.38
26
+ version: 12.9.41
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mixlib-cli
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -783,6 +783,7 @@ files:
783
783
  - lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb
784
784
  - lib/chef/chef_fs/file_system/cookbook_frozen_error.rb
785
785
  - lib/chef/chef_fs/file_system/default_environment_cannot_be_modified_error.rb
786
+ - lib/chef/chef_fs/file_system/exceptions.rb
786
787
  - lib/chef/chef_fs/file_system/file_system_error.rb
787
788
  - lib/chef/chef_fs/file_system/memory/memory_dir.rb
788
789
  - lib/chef/chef_fs/file_system/memory/memory_file.rb
@@ -1101,6 +1102,7 @@ files:
1101
1102
  - lib/chef/mixin/language_include_attribute.rb
1102
1103
  - lib/chef/mixin/language_include_recipe.rb
1103
1104
  - lib/chef/mixin/lazy_module_include.rb
1105
+ - lib/chef/mixin/notifying_block.rb
1104
1106
  - lib/chef/mixin/params_validate.rb
1105
1107
  - lib/chef/mixin/path_sanity.rb
1106
1108
  - lib/chef/mixin/powershell_out.rb
@@ -1872,6 +1874,7 @@ files:
1872
1874
  - spec/integration/recipes/lwrp_spec.rb
1873
1875
  - spec/integration/recipes/noop_resource_spec.rb
1874
1876
  - spec/integration/recipes/notifies_spec.rb
1877
+ - spec/integration/recipes/notifying_block_spec.rb
1875
1878
  - spec/integration/recipes/provider_choice.rb
1876
1879
  - spec/integration/recipes/recipe_dsl_spec.rb
1877
1880
  - spec/integration/recipes/remote_directory.rb
@@ -2438,7 +2441,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
2438
2441
  version: '0'
2439
2442
  requirements: []
2440
2443
  rubyforge_project:
2441
- rubygems_version: 2.6.3
2444
+ rubygems_version: 2.5.2
2442
2445
  signing_key:
2443
2446
  specification_version: 4
2444
2447
  summary: A systems integration framework, built to bring the benefits of configuration