chef 12.16.42 → 12.17.44

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -1
  3. data/README.md +20 -5
  4. data/Rakefile +17 -0
  5. data/VERSION +1 -1
  6. data/acceptance/Gemfile.lock +32 -23
  7. data/distro/common/markdown/man1/knife-configure.mkd +3 -2
  8. data/lib-backcompat/chef/chef_fs/file_system/already_exists_error.rb +1 -1
  9. data/lib-backcompat/chef/chef_fs/file_system/cookbook_frozen_error.rb +1 -1
  10. data/lib-backcompat/chef/chef_fs/file_system/default_environment_cannot_be_modified_error.rb +1 -1
  11. data/lib-backcompat/chef/chef_fs/file_system/file_system_error.rb +1 -1
  12. data/lib-backcompat/chef/chef_fs/file_system/must_delete_recursively_error.rb +1 -1
  13. data/lib-backcompat/chef/chef_fs/file_system/not_found_error.rb +1 -1
  14. data/lib-backcompat/chef/chef_fs/file_system/operation_failed_error.rb +1 -1
  15. data/lib-backcompat/chef/chef_fs/file_system/operation_not_allowed_error.rb +1 -1
  16. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_entry.rb +1 -1
  17. data/lib-backcompat/chef/chef_fs/file_system/repository/file_system_root_dir.rb +1 -1
  18. data/lib/chef/api_client.rb +1 -1
  19. data/lib/chef/application.rb +1 -1
  20. data/lib/chef/application/exit_code.rb +3 -3
  21. data/lib/chef/chef_class.rb +15 -5
  22. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +12 -1
  23. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +19 -0
  24. data/lib/chef/client.rb +1 -0
  25. data/lib/chef/cookbook/metadata.rb +2 -2
  26. data/lib/chef/cookbook_version.rb +4 -4
  27. data/lib/chef/data_bag.rb +1 -1
  28. data/lib/chef/data_bag_item.rb +1 -1
  29. data/lib/chef/data_collector.rb +20 -13
  30. data/lib/chef/data_collector/messages.rb +0 -1
  31. data/lib/chef/data_collector/messages/helpers.rb +2 -2
  32. data/lib/chef/decorator/unchain.rb +2 -2
  33. data/lib/chef/deprecated.rb +190 -0
  34. data/lib/chef/deprecation/provider/remote_directory.rb +1 -1
  35. data/lib/chef/deprecation/warnings.rb +3 -4
  36. data/lib/chef/dsl/method_missing.rb +2 -2
  37. data/lib/chef/dsl/resources.rb +2 -2
  38. data/lib/chef/environment.rb +1 -1
  39. data/lib/chef/exceptions.rb +1 -1
  40. data/lib/chef/formatters/base.rb +11 -1
  41. data/lib/chef/formatters/doc.rb +13 -4
  42. data/lib/chef/key.rb +1 -1
  43. data/lib/chef/knife/client_delete.rb +12 -9
  44. data/lib/chef/knife/configure.rb +1 -1
  45. data/lib/chef/knife/core/bootstrap_context.rb +25 -1
  46. data/lib/chef/knife/core/subcommand_loader.rb +3 -3
  47. data/lib/chef/knife/core/ui.rb +1 -1
  48. data/lib/chef/knife/node_delete.rb +6 -6
  49. data/lib/chef/log.rb +1 -1
  50. data/lib/chef/mixin/deprecation.rb +4 -10
  51. data/lib/chef/mixin/powershell_type_coercions.rb +19 -19
  52. data/lib/chef/mixin/shell_out.rb +1 -1
  53. data/lib/chef/node.rb +2 -2
  54. data/lib/chef/node/attribute.rb +3 -4
  55. data/lib/chef/node/common_api.rb +1 -1
  56. data/lib/chef/node/mixin/state_tracking.rb +5 -2
  57. data/lib/chef/node_map.rb +2 -2
  58. data/lib/chef/org.rb +1 -1
  59. data/lib/chef/platform/rebooter.rb +3 -1
  60. data/lib/chef/policy_builder/expand_node_object.rb +1 -1
  61. data/lib/chef/property.rb +5 -5
  62. data/lib/chef/provider.rb +4 -4
  63. data/lib/chef/provider/launchd.rb +1 -1
  64. data/lib/chef/provider/link.rb +6 -0
  65. data/lib/chef/provider/mount.rb +2 -0
  66. data/lib/chef/provider/mount/mount.rb +1 -1
  67. data/lib/chef/provider/ohai.rb +5 -3
  68. data/lib/chef/provider/package/cab.rb +1 -1
  69. data/lib/chef/provider/package/chocolatey.rb +2 -2
  70. data/lib/chef/provider/package/easy_install.rb +2 -2
  71. data/lib/chef/provider/package/msu.rb +162 -0
  72. data/lib/chef/provider/package/powershell.rb +114 -0
  73. data/lib/chef/provider/package/yum.rb +1 -1
  74. data/lib/chef/provider/yum_repository.rb +6 -7
  75. data/lib/chef/provider_resolver.rb +2 -2
  76. data/lib/chef/providers.rb +2 -0
  77. data/lib/chef/resource.rb +3 -5
  78. data/lib/chef/resource/apt_update.rb +1 -1
  79. data/lib/chef/resource/chef_gem.rb +2 -3
  80. data/lib/chef/resource/file/verification.rb +1 -1
  81. data/lib/chef/resource/launchd.rb +48 -8
  82. data/lib/chef/resource/mount.rb +1 -1
  83. data/lib/chef/resource/msu_package.rb +47 -0
  84. data/lib/chef/resource/ohai.rb +5 -25
  85. data/lib/chef/resource/powershell_package.rb +41 -0
  86. data/lib/chef/resource/reboot.rb +1 -1
  87. data/lib/chef/resource/user.rb +2 -2
  88. data/lib/chef/resource_builder.rb +4 -4
  89. data/lib/chef/resource_resolver.rb +2 -3
  90. data/lib/chef/resources.rb +2 -0
  91. data/lib/chef/rest.rb +1 -1
  92. data/lib/chef/role.rb +1 -1
  93. data/lib/chef/run_context.rb +3 -3
  94. data/lib/chef/shell/ext.rb +2 -2
  95. data/lib/chef/user.rb +3 -3
  96. data/lib/chef/user_v1.rb +1 -1
  97. data/lib/chef/version.rb +1 -1
  98. data/lib/chef/win32/api/security.rb +12 -12
  99. data/spec/data/sample_msu1.xml +10 -0
  100. data/spec/data/sample_msu2.xml +14 -0
  101. data/spec/data/sample_msu3.xml +16 -0
  102. data/spec/functional/rebooter_spec.rb +3 -3
  103. data/spec/functional/resource/link_spec.rb +62 -1
  104. data/spec/functional/resource/msu_package_spec.rb +84 -0
  105. data/spec/functional/resource/registry_spec.rb +3 -3
  106. data/spec/functional/resource/rpm_spec.rb +7 -10
  107. data/spec/integration/solo/solo_spec.rb +50 -0
  108. data/spec/spec_helper.rb +3 -0
  109. data/spec/support/platform_helpers.rb +16 -8
  110. data/spec/unit/application/exit_code_spec.rb +3 -15
  111. data/spec/unit/data_collector_spec.rb +6 -16
  112. data/spec/unit/deprecated_spec.rb +59 -0
  113. data/spec/unit/deprecation_spec.rb +1 -8
  114. data/spec/unit/handler_spec.rb +2 -2
  115. data/spec/unit/knife/client_delete_spec.rb +16 -0
  116. data/spec/unit/knife/configure_spec.rb +1 -1
  117. data/spec/unit/knife/cookbook_metadata_spec.rb +116 -113
  118. data/spec/unit/knife/core/bootstrap_context_spec.rb +55 -5
  119. data/spec/unit/knife/node_delete_spec.rb +19 -10
  120. data/spec/unit/mixin/shell_out_spec.rb +0 -1
  121. data/spec/unit/node/immutable_collections_spec.rb +5 -0
  122. data/spec/unit/node/vivid_mash_spec.rb +11 -0
  123. data/spec/unit/node_spec.rb +2 -2
  124. data/spec/unit/provider/launchd_spec.rb +81 -3
  125. data/spec/unit/provider/mount/mount_spec.rb +1 -1
  126. data/spec/unit/provider/mount_spec.rb +7 -0
  127. data/spec/unit/provider/package/chocolatey_spec.rb +5 -5
  128. data/spec/unit/provider/package/easy_install_spec.rb +6 -6
  129. data/spec/unit/provider/package/msu_spec.rb +283 -0
  130. data/spec/unit/provider/package/powershell_spec.rb +337 -0
  131. data/spec/unit/provider/service/macosx_spec.rb +1 -1
  132. data/spec/unit/provider/subversion_spec.rb +9 -0
  133. data/spec/unit/provider/user/linux_spec.rb +7 -1
  134. data/spec/unit/recipe_spec.rb +43 -11
  135. data/spec/unit/resource/apt_update_spec.rb +17 -25
  136. data/spec/unit/resource/file/verification_spec.rb +1 -1
  137. data/spec/unit/resource/mount_spec.rb +2 -1
  138. data/spec/unit/resource/msu_package_spec.rb +49 -0
  139. data/spec/unit/resource/ohai_spec.rb +1 -1
  140. data/spec/unit/resource/powershell_package_spec.rb +68 -0
  141. data/spec/unit/resource_reporter_spec.rb +4 -4
  142. data/spec/unit/run_status_spec.rb +1 -1
  143. data/tasks/announce.rb +58 -0
  144. data/tasks/changelog.rb +26 -6
  145. data/tasks/templates/prerelease.md.erb +35 -0
  146. data/tasks/templates/release.md.erb +34 -0
  147. metadata +21 -4
@@ -197,7 +197,7 @@ class Chef
197
197
  Chef::Log.debug("#{@new_resource} checking rpm status")
198
198
  shell_out_with_timeout!("rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' #{@new_resource.source}", :timeout => Chef::Config[:yum_timeout]).stdout.each_line do |line|
199
199
  case line
200
- when /([\w\d_.-]+)\s([\w\d_.-]+)/
200
+ when /^(\S+)\s(\S+)$/
201
201
  @current_resource.package_name($1)
202
202
  @new_resource.version($2)
203
203
  end
@@ -76,18 +76,17 @@ class Chef
76
76
  end
77
77
 
78
78
  action :delete do
79
+ # clean the repo cache first
80
+ declare_resource(:execute, "yum clean all #{new_resource.repositoryid}") do
81
+ command "yum clean all --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
82
+ only_if "yum repolist all | grep -P '^#{new_resource.repositoryid}([ \t]|$)'"
83
+ end
84
+
79
85
  declare_resource(:file, "/etc/yum.repos.d/#{new_resource.repositoryid}.repo") do
80
86
  action :delete
81
- notifies :run, "execute[yum clean all #{new_resource.repositoryid}]", :immediately
82
87
  notifies :create, "ruby_block[yum-cache-reload-#{new_resource.repositoryid}]", :immediately
83
88
  end
84
89
 
85
- declare_resource(:execute, "yum clean all #{new_resource.repositoryid}") do
86
- command "yum clean all --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
87
- only_if "yum repolist | grep -P '^#{new_resource.repositoryid}([ \t]|$)'"
88
- action :nothing
89
- end
90
-
91
90
  declare_resource(:ruby_block, "yum-cache-reload-#{new_resource.repositoryid}") do
92
91
  block { Chef::Provider::Package::Yum::YumCache.instance.reload }
93
92
  action :nothing
@@ -157,8 +157,8 @@ class Chef
157
157
  # perf concern otherwise.)
158
158
  handlers = providers.select { |handler| overrode_provides?(handler) && handler.provides?(node, resource) }
159
159
  handlers.each do |handler|
160
- Chef.log_deprecation("#{handler}.provides? returned true when asked if it provides DSL #{resource.resource_name}, but provides #{resource.resource_name.inspect} was never called!")
161
- Chef.log_deprecation("In Chef 13, this will break: you must call provides to mark the names you provide, even if you also override provides? yourself.")
160
+ message = "#{handler}.provides? returned true when asked if it provides DSL #{resource.resource_name}, but provides #{resource.resource_name.inspect} was never called! In Chef 13, this will break: you must call provides to mark the names you provide, even if you also override provides? yourself."
161
+ Chef.deprecated(:custom_resource, message)
162
162
  end
163
163
  end
164
164
  handlers
@@ -84,6 +84,8 @@ require "chef/provider/package/solaris"
84
84
  require "chef/provider/package/smartos"
85
85
  require "chef/provider/package/aix"
86
86
  require "chef/provider/package/cab"
87
+ require "chef/provider/package/powershell"
88
+ require "chef/provider/package/msu"
87
89
 
88
90
  require "chef/provider/service/arch"
89
91
  require "chef/provider/service/freebsd"
@@ -925,9 +925,7 @@ class Chef
925
925
  # @deprecated Multiple actions are supported by resources. Please call {}#updated_by_last_action} instead.
926
926
  #
927
927
  def updated=(true_or_false)
928
- Chef::Log.warn("Chef::Resource#updated=(true|false) is deprecated. Please call #updated_by_last_action(true|false) instead.")
929
- Chef::Log.warn("Called from:")
930
- caller[0..3].each { |line| Chef::Log.warn(line) }
928
+ Chef.deprecated(:custom_resource, "Chef::Resource#updated=(true|false) is deprecated. Please call #updated_by_last_action(true|false) instead.")
931
929
  updated_by_last_action(true_or_false)
932
930
  @updated = true_or_false
933
931
  end
@@ -982,7 +980,7 @@ class Chef
982
980
  # @deprecated Use resource_name instead.
983
981
  #
984
982
  def self.dsl_name
985
- Chef.log_deprecation "Resource.dsl_name is deprecated and will be removed in Chef 13. Use resource_name instead."
983
+ Chef.deprecated(:custom_resource, "Resource.dsl_name is deprecated and will be removed in Chef 13. Use resource_name instead.")
986
984
  if name
987
985
  name = self.name.split("::")[-1]
988
986
  convert_to_snake_case(name)
@@ -1060,7 +1058,7 @@ class Chef
1060
1058
  #
1061
1059
  def self.provider_base(arg = nil)
1062
1060
  if arg
1063
- Chef.log_deprecation("Resource.provider_base is deprecated and will be removed in Chef 13. Use provides on the provider, or provider on the resource, instead.")
1061
+ Chef.deprecated(:custom_resource, "Resource.provider_base is deprecated and will be removed in Chef 13. Use provides on the provider, or provider on the resource, instead.")
1064
1062
  end
1065
1063
  @provider_base ||= arg || Chef::Provider
1066
1064
  end
@@ -22,7 +22,7 @@ class Chef
22
22
  class Resource
23
23
  class AptUpdate < Chef::Resource
24
24
  resource_name :apt_update
25
- provides :apt_update, os: "linux"
25
+ provides :apt_update
26
26
 
27
27
  property :frequency, Integer, default: 86_400
28
28
 
@@ -34,9 +34,8 @@ class Chef
34
34
  # Chef::Resource.run_action: Caveat: this skips Chef::Runner.run_action, where notifications are handled
35
35
  # Action could be an array of symbols, but probably won't (think install + enable for a package)
36
36
  if compile_time.nil?
37
- Chef.log_deprecation "#{self} chef_gem compile_time installation is deprecated"
38
- Chef.log_deprecation "#{self} Please set `compile_time false` on the resource to use the new behavior."
39
- Chef.log_deprecation "#{self} or set `compile_time true` on the resource if compile_time behavior is required."
37
+ message = "#{self} chef_gem compile_time installation is deprecated. Please set `compile_time false` on the resource to use the new behavior, or set `compile_time true` on the resource if compile_time behavior is required."
38
+ Chef.deprecated :chef_gem_compile_time, message
40
39
  end
41
40
 
42
41
  if compile_time || compile_time.nil?
@@ -108,7 +108,7 @@ class Chef
108
108
  def verify_command(path, opts)
109
109
  # First implementation interpolated `file`; docs & RFC claim `path`
110
110
  # is interpolated. Until `file` can be deprecated, interpolate both.
111
- Chef.log_deprecation(
111
+ Chef.deprecated(:verify_file,
112
112
  "%{file} is deprecated in verify command and will not be "\
113
113
  "supported in Chef 13. Please use %{path} instead."
114
114
  ) if @command.include?("%{file}")
@@ -29,12 +29,6 @@ class Chef
29
29
  default_action :create
30
30
  allowed_actions :create, :create_if_missing, :delete, :enable, :disable
31
31
 
32
- def initialize(name, run_context = nil)
33
- super
34
- provider = Chef::Provider::Launchd
35
- resource_name = :launchd
36
- end
37
-
38
32
  property :label, String, default: lazy { name }, identity: true
39
33
  property :backup, [Integer, FalseClass]
40
34
  property :cookbook, String
@@ -46,6 +40,53 @@ class Chef
46
40
  property :source, String
47
41
  property :session_type, String
48
42
 
43
+ # StartCalendarInterval has some gotchas so we coerce it to help sanity
44
+ # check. According to `man 5 launchd.plist`:
45
+ # StartCalendarInterval <dictionary of integers or array of dictionaries of integers>
46
+ # ... Missing arguments are considered to be wildcard.
47
+ # What the man page doesn't state, but what was observed (OSX 10.11.5, launchctrl v3.4.0)
48
+ # Is that keys that are specified, but invalid, will also be treated as a wildcard
49
+ # this means that an entry like:
50
+ # { "Hour"=>0, "Weekday"=>"6-7"}
51
+ # will not just run on midnight of Sat and Sun, rather it will run _every_ midnight.
52
+ property :start_calendar_interval, [Hash, Array], coerce: proc { |type|
53
+ # Coerce into an array of hashes to make validation easier
54
+ array = if type.is_a?(Array)
55
+ type
56
+ else
57
+ [type]
58
+ end
59
+
60
+ # Check to make sure that our array only has hashes
61
+ unless array.all? { |obj| obj.is_a?(Hash) }
62
+ error_msg = "start_calendar_interval must be a single hash or an array of hashes!"
63
+ raise Chef::Exceptions::ValidationFailed, error_msg
64
+ end
65
+
66
+ # Make sure the hashes don't have any incorrect keys/values
67
+ array.each do |entry|
68
+ allowed_keys = %w{Minute Hour Day Weekday Month}
69
+ unless entry.keys.all? { |key| allowed_keys.include?(key) }
70
+ failed_keys = entry.keys.reject { |k| allowed_keys.include?(k) }.join(", ")
71
+ error_msg = "The following key(s): #{failed_keys} are invalid for start_calendar_interval, must be one of: #{allowed_keys.join(", ")}"
72
+ raise Chef::Exceptions::ValidationFailed, error_msg
73
+ end
74
+
75
+ unless entry.values.all? { |val| val.is_a?(Integer) }
76
+ failed_values = entry.values.reject { |val| val.is_a?(Integer) }.join(", ")
77
+ error_msg = "Invalid value(s) (#{failed_values}) for start_calendar_interval item. Values must be integers!"
78
+ raise Chef::Exceptions::ValidationFailed, error_msg
79
+ end
80
+ end
81
+
82
+ # Don't return array if we only have one entry
83
+ if array.size == 1
84
+ array.first
85
+ else
86
+ array
87
+ end
88
+ }
89
+
49
90
  property :type, String, default: "daemon", coerce: proc { |type|
50
91
  type = type ? type.downcase : "daemon"
51
92
  types = %w{daemon agent}
@@ -73,7 +114,7 @@ class Chef
73
114
  property :ld_group, String
74
115
  property :limit_load_from_hosts, Array
75
116
  property :limit_load_to_hosts, Array
76
- property :limit_load_to_session_type, String
117
+ property :limit_load_to_session_type, Array
77
118
  property :low_priority_io, [ TrueClass, FalseClass ]
78
119
  property :mach_services, Hash
79
120
  property :nice, Integer
@@ -89,7 +130,6 @@ class Chef
89
130
  property :standard_error_path, String
90
131
  property :standard_in_path, String
91
132
  property :standard_out_path, String
92
- property :start_calendar_interval, Hash
93
133
  property :start_interval, Integer
94
134
  property :start_on_mount, [ TrueClass, FalseClass ]
95
135
  property :throttle_interval, Integer
@@ -28,7 +28,7 @@ class Chef
28
28
  state_attrs :mount_point, :device_type, :fstype, :username, :password, :domain
29
29
 
30
30
  default_action :mount
31
- allowed_actions :mount, :umount, :remount, :enable, :disable
31
+ allowed_actions :mount, :umount, :unmount, :remount, :enable, :disable
32
32
 
33
33
  def initialize(name, run_context = nil)
34
34
  super
@@ -0,0 +1,47 @@
1
+ #
2
+ # Author:: Nimisha Sharad (<nimisha.sharad@msystechnologies.com>)
3
+ # Copyright:: Copyright 2008-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
+ require "chef/resource/package"
20
+ require "chef/mixin/uris"
21
+
22
+ class Chef
23
+ class Resource
24
+ class MsuPackage < Chef::Resource::Package
25
+ include Chef::Mixin::Uris
26
+
27
+ provides :msu_package, os: "windows"
28
+
29
+ allowed_actions :install, :remove
30
+
31
+ def initialize(name, run_context = nil)
32
+ super
33
+ @resource_name = :msu_package
34
+ @source = name
35
+ @action = :install
36
+ end
37
+
38
+ property :source, String,
39
+ coerce: (proc do |s|
40
+ unless s.nil?
41
+ uri_scheme?(s) ? s : Chef::Util::PathHelper.canonical_path(s, false)
42
+ end
43
+ end)
44
+ property :checksum, String, desired_state: false
45
+ end
46
+ end
47
+ end
@@ -20,34 +20,14 @@
20
20
  class Chef
21
21
  class Resource
22
22
  class Ohai < Chef::Resource
23
+ resource_name :ohai
24
+ provides :ohai
23
25
 
24
- identity_attr :name
25
-
26
- state_attrs :plugin
26
+ property :ohai_name, name_property: true
27
+ property :plugin, [String]
27
28
 
28
29
  default_action :reload
29
-
30
- def initialize(name, run_context = nil)
31
- super
32
- @name = name
33
- @plugin = nil
34
- end
35
-
36
- def plugin(arg = nil)
37
- set_or_return(
38
- :plugin,
39
- arg,
40
- :kind_of => [ String ]
41
- )
42
- end
43
-
44
- def name(arg = nil)
45
- set_or_return(
46
- :name,
47
- arg,
48
- :kind_of => [ String ]
49
- )
50
- end
30
+ allowed_actions :reload
51
31
  end
52
32
  end
53
33
  end
@@ -0,0 +1,41 @@
1
+ # Author:: Dheeraj Dubey(dheeraj.dubey@msystechnologies.com)
2
+ # Copyright:: Copyright 2008-2016, Chef Software, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "chef/resource/package"
19
+ require "chef/mixin/uris"
20
+
21
+ class Chef
22
+ class Resource
23
+ class PowershellPackage < Chef::Resource::Package
24
+ include Chef::Mixin::Uris
25
+
26
+ provides :powershell_package, os: "windows"
27
+
28
+ allowed_actions :install, :remove
29
+
30
+ def initialize(name, run_context = nil)
31
+ super
32
+ @resource_name = :powershell_package
33
+ end
34
+
35
+ property :package_name, [String, Array], coerce: proc { |x| [x].flatten }
36
+
37
+ property :version, [String, Array], coerce: proc { |x| [x].flatten }
38
+
39
+ end
40
+ end
41
+ end
@@ -41,7 +41,7 @@ class Chef
41
41
  end
42
42
 
43
43
  def delay_mins(arg = nil)
44
- set_or_return(:delay_mins, arg, :kind_of => Fixnum)
44
+ set_or_return(:delay_mins, arg, :kind_of => Integer)
45
45
  end
46
46
  end
47
47
  end
@@ -158,10 +158,10 @@ class Chef
158
158
 
159
159
  def supports(args = {})
160
160
  if args.key?(:manage_home)
161
- Chef.log_deprecation "supports { manage_home: #{args[:manage_home]} } on the user resource is deprecated and will be removed in Chef 13, set manage_home: #{args[:manage_home]} instead"
161
+ Chef.deprecated(:supports_property, "supports { manage_home: #{args[:manage_home]} } on the user resource is deprecated and will be removed in Chef 13, set manage_home #{args[:manage_home]} instead")
162
162
  end
163
163
  if args.key?(:non_unique)
164
- Chef.log_deprecation "supports { non_unique: #{args[:non_unique]} } on the user resource is deprecated and will be removed in Chef 13, set non_unique: #{args[:non_unique]} instead"
164
+ Chef.deprecated(:supports_property, "supports { non_unique: #{args[:non_unique]} } on the user resource is deprecated and will be removed in Chef 13, set non_unique #{args[:non_unique]} instead")
165
165
  end
166
166
  super
167
167
  end
@@ -56,7 +56,7 @@ class Chef
56
56
  # This behavior is very counter-intuitive and should be removed.
57
57
  # See CHEF-3694, https://tickets.opscode.com/browse/CHEF-3694
58
58
  # Moved to this location to resolve CHEF-5052, https://tickets.opscode.com/browse/CHEF-5052
59
- if prior_resource
59
+ if prior_resource && Chef::Config[:resource_cloning]
60
60
  resource.load_from(prior_resource)
61
61
  end
62
62
 
@@ -80,7 +80,7 @@ class Chef
80
80
  end
81
81
 
82
82
  # emit a cloned resource warning if it is warranted
83
- if prior_resource
83
+ if prior_resource && Chef::Config[:resource_cloning]
84
84
  if is_trivial_resource?(prior_resource) && identicalish_resources?(prior_resource, resource)
85
85
  emit_harmless_cloning_debug
86
86
  else
@@ -128,10 +128,10 @@ class Chef
128
128
  end
129
129
 
130
130
  def emit_cloned_resource_warning
131
- message = "Cloning resource attributes for #{resource} from prior resource (CHEF-3694)"
131
+ message = "Cloning resource attributes for #{resource} from prior resource"
132
132
  message << "\nPrevious #{prior_resource}: #{prior_resource.source_line}" if prior_resource.source_line
133
133
  message << "\nCurrent #{resource}: #{resource.source_line}" if resource.source_line
134
- Chef.log_deprecation(message)
134
+ Chef.deprecated(:resource_cloning, message)
135
135
  end
136
136
 
137
137
  def emit_harmless_cloning_debug
@@ -55,7 +55,7 @@ class Chef
55
55
  attr_reader :resource_name
56
56
  # @api private
57
57
  def resource
58
- Chef.log_deprecation("Chef::ResourceResolver.resource deprecated. Use resource_name instead.")
58
+ Chef.deprecated(:custom_resource, "Chef::ResourceResolver.resource deprecated. Use resource_name instead.")
59
59
  resource_name
60
60
  end
61
61
  # @api private
@@ -173,8 +173,7 @@ class Chef
173
173
  if handlers.empty?
174
174
  handlers = resources.select { |handler| overrode_provides?(handler) && handler.provides?(node, resource_name) }
175
175
  handlers.each do |handler|
176
- Chef.log_deprecation("#{handler}.provides? returned true when asked if it provides DSL #{resource_name}, but provides #{resource_name.inspect} was never called!")
177
- Chef.log_deprecation("In Chef 13, this will break: you must call provides to mark the names you provide, even if you also override provides? yourself.")
176
+ Chef.deprecated(:custom_resource, "#{handler}.provides? returned true when asked if it provides DSL #{resource_name}, but provides #{resource_name.inspect} was never called! In Chef 13, this will break: you must call provides to mark the names you provide, even if you also override provides? yourself.")
178
177
  end
179
178
  end
180
179
  handlers
@@ -96,3 +96,5 @@ require "chef/resource/lwrp_base"
96
96
  require "chef/resource/bff_package"
97
97
  require "chef/resource/zypper_package"
98
98
  require "chef/resource/cab_package"
99
+ require "chef/resource/powershell_package"
100
+ require "chef/resource/msu_package"
@@ -59,7 +59,7 @@ class Chef
59
59
  # http://localhost:4000, a call to +get_rest+ with 'nodes' will make an
60
60
  # HTTP GET request to http://localhost:4000/nodes
61
61
  def initialize(url, client_name = Chef::Config[:node_name], signing_key_filename = Chef::Config[:client_key], options = {})
62
- Chef.log_deprecation("Chef::REST is deprecated. Please use Chef::ServerAPI, or investigate Ridley or ChefAPI.")
62
+ Chef.deprecated(:chef_rest, "Chef::REST is deprecated. Please use Chef::ServerAPI, or investigate Ridley or ChefAPI.")
63
63
 
64
64
  signing_key_filename = nil if chef_zero_uri?(url)
65
65
 
@@ -170,7 +170,7 @@ class Chef
170
170
 
171
171
  # Create a Chef::Role from JSON
172
172
  def self.json_create(o)
173
- Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::Role#from_hash")
173
+ Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please use Chef::Role#from_hash")
174
174
  from_hash(o)
175
175
  end
176
176
 
@@ -581,17 +581,17 @@ ERROR_MESSAGE
581
581
  # These need to be settable so deploy can run a resource_collection
582
582
  # independent of any cookbooks via +recipe_eval+
583
583
  def audits=(value)
584
- Chef.log_deprecation("Setting run_context.audits will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.")
584
+ Chef.deprecated(:internal_api, "Setting run_context.audits will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.")
585
585
  @audits = value
586
586
  end
587
587
 
588
588
  def immediate_notification_collection=(value)
589
- Chef.log_deprecation("Setting run_context.immediate_notification_collection will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.")
589
+ Chef.deprecated(:internal_api, "Setting run_context.immediate_notification_collection will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.")
590
590
  @immediate_notification_collection = value
591
591
  end
592
592
 
593
593
  def delayed_notification_collection=(value)
594
- Chef.log_deprecation("Setting run_context.delayed_notification_collection will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.")
594
+ Chef.deprecated(:internal_api, "Setting run_context.delayed_notification_collection will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.")
595
595
  @delayed_notification_collection = value
596
596
  end
597
597
  end