Class: RuboCop::Cop::Chef::Modernize::OpensslRsaKeyResource

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector, TargetChefVersion
Defined in:
lib/rubocop/cop/chef/modernize/openssl_rsa_key_resource.rb

Overview

The openssl_rsa_key resource was renamed to openssl_rsa_private_key in Chef Infra Client 14.0. The new resource name should be used.

Examples:


### incorrect
openssl_rsa_key '/etc/httpd/ssl/server.key' do
  key_length 2048
end

### correct
openssl_rsa_private_key '/etc/httpd/ssl/server.key' do
  key_length 2048
end

Constant Summary collapse

MSG =
'The openssl_rsa_key resource was renamed to openssl_rsa_private_key in Chef Infra Client 14.0. The new resource name should be used.'
RESTRICT_ON_SEND =
[:openssl_rsa_key].freeze

Instance Method Summary collapse

Methods included from TargetChefVersion

minimum_target_chef_version, required_minimum_chef_version, support_target_chef_version?

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



45
46
47
48
49
# File 'lib/rubocop/cop/chef/modernize/openssl_rsa_key_resource.rb', line 45

def on_send(node)
  add_offense(node, severity: :refactor) do |corrector|
    corrector.replace(node, node.source.gsub(/^openssl_rsa_key/, 'openssl_rsa_private_key'))
  end
end