DeprecatedPlatformMethods

All Cookstyle Cops


The department is: Chef/Deprecations

The full name of the cop is: Chef/Deprecations/DeprecatedPlatformMethods


Enabled by default Supports autocorrection Target Chef Version
Enabled No All Versions

Use provider_for_action or provides instead of the deprecated Chef::Platform methods in resources, which were removed in Chef Infra Client 13.

Examples

incorrect

resource = Chef::Resource::File.new("/tmp/foo.xyz", run_context)
provider = Chef::Platform.provider_for_resource(resource, :create)

resource = Chef::Resource::File.new("/tmp/foo.xyz", run_context)
provider = Chef::Platform.find_provider("ubuntu", "16.04", resource)

resource = Chef::Resource::File.new("/tmp/foo.xyz", run_context)
provider = Chef::Platform.find_provider_for_node(node, resource)

Chef::Platform.set :platform => :mac_os_x, :resource => :package, :provider => Chef::Provider::Package::Homebrew

correct

resource = Chef::Resource::File.new("/tmp/foo.xyz", run_context)
provider = resource.provider_for_action(:create)

# provides :package, platform_family: 'mac_os_x'

Configurable attributes

Name Default value Configurable values
Version Added 5.16.0 String
Include
  • **/libraries/*.rb
  • **/resources/*.rb
  • **/providers/*.rb
Array

© Chef Software, Inc.
Licensed under the Creative Commons Attribution 3.0 Unported License.
The Chef™ Mark and Chef Logo are either registered trademarks/service marks or trademarks/servicemarks of Chef, in the United States and other countries and are used with Chef Inc's permission.
We are not affiliated with, endorsed or sponsored by Chef Inc.
https://docs.chef.io/workstation/cookstyle/chef_deprecations_deprecatedplatformmethods/