Skip to main content

Chef/Modernize/ShellOutToChocolatey

Cookstyle cops page

The Cookstyle cops department: Chef/Modernize

Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledNoAll Versions

Use the Chocolatey resources built into Chef Infra Client instead of shelling out to the choco command

Examples

# bad
execute 'install package foo' do
  command "choco install --source=artifactory \"foo\" -y --no-progress --ignore-package-exit-codes"
end

powershell_script 'add artifactory choco source' do
  code "choco source add -n=artifactory -s='https://mycorp.jfrog.io/mycorp/api/nuget/chocolatey-remote' -u foo -p bar"
  not_if 'choco source list | findstr artifactory'
end

# good
chocolatey_package 'foo' do
  source 'artifactory'
  options '--no-progress --ignore-package-exit-codes'
end

chocolatey_source 'artifactory' do
  source 'https://mycorp.jfrog.io/mycorp/api/nuget/chocolatey-remote'
  action :add
end

Configurable attributes

NameDefault valueConfigurable values
Version Added5.5.0String
Include
    Array

    Thank you for your feedback!

    ×