The complete name of the cop is: Chef/Correctness/ChefDKGenerators
ChefDKGenerators is a cookstyle cop that is enabled by Default and supports autocorrection. It is a cop that can be used in all chef versions.
ChefDk (formerly called Chef Workstation 8.0) module is used to write custom cookbook generators from ChefDk to ChefCLI. We will reference the new class names for compatibility with the latest workstations.
Examples
Incorrect:
ChefDK::CLI
ChefDK::Generator::TemplateHelper
module ChefDK
# some additional code
end
Correct:
ChefCLI::CLI
ChefCLI::Generator::TemplateHelper
module ChefCLI
# some additional code
end
Configurable Attributes:
Cheffile
The complete name of the cop is: Chef/Correctness/Cheffile
Cheffile is a cookstyle cop that is enabled by Default and does not support autocorrection. It is a cop that can be used in all chef versions.
A Cheffile should no longer be used for cookbook depsolving since the librarian-chef project is no longer maintained; use Policyfiles instead.
Configurable Attributes:
ChefHandlerRecipe
The complete name of the cop is: Chef/Correctness/ChefHandlerRecipe
ChefHandlerRecipe is a cookstyle cop that is enabled by Default and supports autocorrection. It is a cop that can be used in all chef versions.
There’s no requirement to include the deprecated and empty chef_handler::default recipe to use the ChefHandler.
chef_handler 'whatever' do
type start: true, report: true, exception: true
end
Configurable Attributes:
ChefRewind
The complete name of the cop is: Chef/Correctness/ChefRewind
ChefRewind is a cookstyle cop that is enabled by Default and supports autocorrection. It is a cop that can be used in all chef versions that are above 12.10
This property of supports was removed in chef_handler cookbook version 3.0; instead, we use the type property in the chef_handler resource.
Examples
chef_gem ‘chef-rewind’
require ‘chef/rewind’
rewind “user[postgres]” do home ‘/var/lib/pgsql/9.2’ cookbook ‘my-postgresql’ end
unwind “user[postgres]”
Configurable Attributes:
ChefShellOut
The complete name of the cop is: Chef/Correctness/ChefShellOut
ChefShellOut is a cookstyle cop that is enabled by Default and supports autocorrection. It is a cop that can be used in all chef versions.
ChefShellOut is a deprecated class that got removed in Chef Infra Client 13. So, we use the Mixlib::ShellOut class instead.
Examples
Incorrect:
include Chef::ShellOut
require 'chef/shellout'
Chef::ShellOut.new('some_command')
Correct:
include Mixlib::ShellOut
require 'mixlib/shellout'
Mixlib::ShellOut.new('some_command')
Configurable Attributes:
ChefSpecCoverageReport
The complete name of the cop is: Chef/Correctness/ChefSpecCoverageReport
ChefSpecCoverageReport is a cookstyle cop that is enabled by Default and supports autocorrection. It is a cop that can be used in all chef versions.
ChefSpecCoverageReport is a deprecated class that got removed as it encouraged cookbook authors to write ineffective specs.
Examples
Incorrect:
at_exit { ChefSpec::Coverage.report! }
Configurable Attributes:
ChefSpecLegacyRunner
The complete name of the cop is: Chef/Correctness/ChefSpecLegacyRunner
ChefSpecLegacyRunner is a cookstyle cop that is enabled by Default and supports autocorrection. It is a cop that can be used in all chef versions.
ChefSpecLegacyRunner is a deprecated class; instead, we use the ChefSpec::SoloRunner or the ChefSpec::Runner that were introduced in ChefSpec 4.1
Examples
Incorrect:
describe 'foo::default' do
subject { ChefSpec::Runner.new.converge(described_recipe) }
# some spec code
end
Correct:
describe 'foo::default' do
subject { ChefSpec::ServerRunner.new.converge(described_recipe) }
# some spec code
end
Configurable Attributes:
ChefSugarHelpers
The complete name of the cop is: Chef/Correctness/ChefSugarHelpers
ChefSugarHelpers is a cookstyle cop that is enabled by Default and does not support autocorrection. It is a cop that can be used in all chef versions.
We don’t use the chef-sugar methods as they won’t be moved into the Chef Infra Client.
The complete name of the cop is: Chef/Correctness/ChefWindowsPlatformHelper
ChefWindowsPlatformHelper is a cookstyle cop that is enabled by default and supports autocorrection. It is a cop that can be used in all chef versions.
We now use platform? (‘windows) instead of the Chef::Platform.windows?
Examples
Incorrect:
Chef::Platform.windows?
Correct:
platform?('windows')
platform_family?('windows')
Configurable Attributes:
ChocolateyPackageUninstallAction
The complete name of the cop is: Chef/Correctness/ChocolateyPackageUninstallAction
ChocolateyPackageUninstallAction is a cookstyle cop that is enabled by Default and supports autocorrection. It is a cop that can be used in all chef versions.
We use the :remove from the chocolatey_package resource instead of the :uninstall, which got removed in Chef Infra Client 14+
Examples
Incorrect:
chocolatey_package 'nginx' do
action :uninstall
end
Correct:
chocolatey_package 'nginx' do
action :remove
end
Configurable Attributes:
CookbookDependsOnCompatResource
The complete name of the cop is: Chef/Correctness/CookbookDependsOnCompatResource
CookbookDependsOnCompatResource is a cookstyle cop that is enabled by Default and supports autocorrection. It is a cop that can be used in all chef versions that are above 12.19
Compact_resource is deprecated and was made obsolete by Chef Infra Client 12.19+
Examples
Incorrect:
depends 'compat_resource'
Configurable Attributes:
CookbookDependsOnPartialSearch
The complete name of the cop is: Chef/Correctness/CookbookDependsOnPartialSearch
CookbookDependsOnPartialSearch is a cookstyle cop that is enabled by Default and supports autocorrection. It is a cop that can be used in all chef versions that are above 13.0
Partial_search is deprecated and was made obsolete by Chef Infra Client 13.
Examples
Incorrect:
depends 'partial_search'
Configurable Attributes:
CookbookDependsOnPoise
The complete name of the cop is: Chef/Correctness/CookbookDependsOnPoise
CookbookDependsOnPoise is a cookstyle cop that is enabled by default and does not support autocorrection. It is a cop that can be used in all chef versions.
The poise frameworks are deprecated and must be refactored to utilize standard Chef Infra custom resources.
Cops are the checks performed on the code responsible for detecting one particular offense. There are several cop sections grouped based on the offense.
What are Policyfiles?
Policyfiles are a way to create an immutable collection of cookbooks, their dependencies, and attributes that are defined in a single document uploaded to the Chef Infra server.
What to do if the Policyfiles model isn’t compatible with your workflow?
If the Policyfiles isn’t compatible, we may find that Berkshelf offers a similar (and still supported) experience to Librarian-Chef.
Conclusion
So, with this, we saw about the Deprecations section of the CookStyle tool. I hope that the blog was informative.
If you think you are ready for the tech giants company, check out the mock test series on code studio.
You can also refer to our Guided Path on Coding Ninjas Studio to upskill yourself in domains like Data Structures and Algorithms, Competitive Programming, Aptitude, and many more! You can also prepare for tech giants companies like Amazon, Microsoft, Uber, etc., by looking for the questions asked by them in recent interviews. If you want to prepare for placements, refer to the interview bundle. If you are nervous about your interviews, you can see interview experiences to get ideas about these companies' questions.
Nevertheless, you may consider our premium courses to give your career an edge over others!
Do upvote our blogs if you find them helpful and engaging!