Skip to main content

Chef/Deprecations/DeprecatedPlatformMethods

Cookstyle cops page

The Cookstyle cops department: Chef/Deprecations

Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledNoAll 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

NameDefault valueConfigurable values
Version Added5.16.0String
Include
  • **/libraries/*.rb
  • **/resources/*.rb
  • **/providers/*.rb
Array

Thank you for your feedback!

×











Search Results