Skip to main content

Chef/Deprecations/HWRPWithoutProvides

Cookstyle cops page

The Cookstyle cops department: Chef/Deprecations

Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledYesAll Versions

Chef Infra Client 16 and later a legacy HWRP resource must use provides to define how the resource is called in recipes or other resources. To maintain compatibility with Chef Infra Client < 16 use both resource_name and provides.

correct when Chef Infra Client < 15 (but compatible with 16+ as well)

class Chef class Resource class UlimitRule < Chef::Resource resource_name :ulimit_rule provides :ulimit_rule

    property :type, [Symbol, String], required: true
    property :item, [Symbol, String], required: true

    # additional resource code
  end
end

end

correct when Chef Infra Client 16+

class Chef class Resource class UlimitRule < Chef::Resource provides :ulimit_rule

    property :type, [Symbol, String], required: true
    property :item, [Symbol, String], required: true

    # additional resource code
  end
end

end

better

Convert your legacy HWRPs to custom resources

Examples

incorrect

class Chef
  class Resource
    class UlimitRule < Chef::Resource
      property :type, [Symbol, String], required: true
      property :item, [Symbol, String], required: true

      # additional resource code
    end
  end
end

### incorrect

```ruby
class Chef
  class Resource
    class UlimitRule < Chef::Resource
      resource_name :ulimit_rule

      property :type, [Symbol, String], required: true
      property :item, [Symbol, String], required: true

      # additional resource code
    end
  end
end

Configurable attributes

NameDefault valueConfigurable values
Version Added6.0.0String
Include
  • **/libraries/*.rb
Array

Thank you for your feedback!

×










Search Results