From 9d427d769a416b8998c8f4b80854a0ce41cd6157 Mon Sep 17 00:00:00 2001 From: Cookstyle Bot Date: Mon, 17 Jan 2022 13:37:19 -0800 Subject: [PATCH] Cookstyle Bot Auto Corrections with Cookstyle 7.30.1 This change is automatically generated by the Cookstyle Bot using the latest version of Cookstyle (7.30.1). Adopting changes suggested by Cookstyle improves cookbook readability, avoids common coding mistakes, and eases upgrades to newer versions of the Chef Infra Client. ### Style/TrailingCommaInHashLiteral - **/attributes/default.rb:2**: Put a comma after the last item of a multiline hash. ### Chef/Correctness/ChefApplicationFatal - **/libraries/helpers.rb:77**: Use raise to force Chef Infra Client to fail instead of using Chef::Application.fatal (https://docs.chef.io/workstation/cookstyle/chef_correctness_chefapplicationfatal) ### Chef/Style/CommentFormat - **/libraries/packer_builder_provider.rb:3**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/libraries/packer_builder_resource.rb:3**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/libraries/packer_post_processor_provider.rb:3**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/libraries/packer_post_processor_resource.rb:3**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/libraries/packer_provisioner_provider.rb:3**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/libraries/packer_provisioner_resource.rb:3**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/libraries/packer_template_provider.rb:3**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/libraries/packer_template_resource.rb:3**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/libraries/packer_variable_provider.rb:3**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/libraries/packer_variable_resource.rb:3**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/recipes/default.rb:2**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/recipes/default.rb:5**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/spec/unit/recipes/default_spec.rb:2**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) - **/spec/unit/recipes/default_spec.rb:5**: Properly format header comments (https://docs.chef.io/workstation/cookstyle/chef_style_commentformat) ### Chef/Deprecations/UseInlineResourcesDefined - **/libraries/packer_builder_provider.rb:26**: use_inline_resources is now the default for resources in Chef Infra Client 13+ and does not need to be specified. (https://docs.chef.io/workstation/cookstyle/chef_deprecations_useinlineresourcesdefined) - **/libraries/packer_post_processor_provider.rb:26**: use_inline_resources is now the default for resources in Chef Infra Client 13+ and does not need to be specified. (https://docs.chef.io/workstation/cookstyle/chef_deprecations_useinlineresourcesdefined) - **/libraries/packer_provisioner_provider.rb:26**: use_inline_resources is now the default for resources in Chef Infra Client 13+ and does not need to be specified. (https://docs.chef.io/workstation/cookstyle/chef_deprecations_useinlineresourcesdefined) - **/libraries/packer_template_provider.rb:26**: use_inline_resources is now the default for resources in Chef Infra Client 13+ and does not need to be specified. (https://docs.chef.io/workstation/cookstyle/chef_deprecations_useinlineresourcesdefined) - **/libraries/packer_variable_provider.rb:27**: use_inline_resources is now the default for resources in Chef Infra Client 13+ and does not need to be specified. (https://docs.chef.io/workstation/cookstyle/chef_deprecations_useinlineresourcesdefined) ### Chef/Modernize/WhyRunSupportedTrue - **/libraries/packer_builder_provider.rb:28**: whyrun_supported? no longer needs to be set to true as it is the default in Chef Infra Client 13+ (https://docs.chef.io/workstation/cookstyle/chef_modernize_whyrunsupportedtrue) - **/libraries/packer_post_processor_provider.rb:28**: whyrun_supported? no longer needs to be set to true as it is the default in Chef Infra Client 13+ (https://docs.chef.io/workstation/cookstyle/chef_modernize_whyrunsupportedtrue) - **/libraries/packer_provisioner_provider.rb:28**: whyrun_supported? no longer needs to be set to true as it is the default in Chef Infra Client 13+ (https://docs.chef.io/workstation/cookstyle/chef_modernize_whyrunsupportedtrue) - **/libraries/packer_template_provider.rb:28**: whyrun_supported? no longer needs to be set to true as it is the default in Chef Infra Client 13+ (https://docs.chef.io/workstation/cookstyle/chef_modernize_whyrunsupportedtrue) - **/libraries/packer_variable_provider.rb:29**: whyrun_supported? no longer needs to be set to true as it is the default in Chef Infra Client 13+ (https://docs.chef.io/workstation/cookstyle/chef_modernize_whyrunsupportedtrue) ### Chef/Deprecations/ResourceUsesOnlyResourceName - **/libraries/packer_builder_resource.rb:21**: Starting with Chef Infra Client 16, using `resource_name` without also using `provides` will result in resource failures. Make sure to use both `resource_name` and `provides` to change the name of the resource. You can also omit `resource_name` entirely if the value set matches the name Chef Infra Client automatically assigns based on COOKBOOKNAME_FILENAME. (https://docs.chef.io/workstation/cookstyle/chef_deprecations_resourceusesonlyresourcename) - **/libraries/packer_post_processor_resource.rb:23**: Starting with Chef Infra Client 16, using `resource_name` without also using `provides` will result in resource failures. Make sure to use both `resource_name` and `provides` to change the name of the resource. You can also omit `resource_name` entirely if the value set matches the name Chef Infra Client automatically assigns based on COOKBOOKNAME_FILENAME. (https://docs.chef.io/workstation/cookstyle/chef_deprecations_resourceusesonlyresourcename) - **/libraries/packer_provisioner_resource.rb:21**: Starting with Chef Infra Client 16, using `resource_name` without also using `provides` will result in resource failures. Make sure to use both `resource_name` and `provides` to change the name of the resource. You can also omit `resource_name` entirely if the value set matches the name Chef Infra Client automatically assigns based on COOKBOOKNAME_FILENAME. (https://docs.chef.io/workstation/cookstyle/chef_deprecations_resourceusesonlyresourcename) - **/libraries/packer_template_resource.rb:21**: Starting with Chef Infra Client 16, using `resource_name` without also using `provides` will result in resource failures. Make sure to use both `resource_name` and `provides` to change the name of the resource. You can also omit `resource_name` entirely if the value set matches the name Chef Infra Client automatically assigns based on COOKBOOKNAME_FILENAME. (https://docs.chef.io/workstation/cookstyle/chef_deprecations_resourceusesonlyresourcename) - **/libraries/packer_variable_resource.rb:23**: Starting with Chef Infra Client 16, using `resource_name` without also using `provides` will result in resource failures. Make sure to use both `resource_name` and `provides` to change the name of the resource. You can also omit `resource_name` entirely if the value set matches the name Chef Infra Client automatically assigns based on COOKBOOKNAME_FILENAME. (https://docs.chef.io/workstation/cookstyle/chef_deprecations_resourceusesonlyresourcename) ### Layout/IndentationConsistency - **/libraries/packer_builder_resource.rb:22**: Inconsistent indentation detected. (https://rubystyle.guide#spaces-indentation, https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions) - **/libraries/packer_builder_resource.rb:22**: Inconsistent indentation detected. (https://rubystyle.guide#spaces-indentation, https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions) - **/libraries/packer_post_processor_resource.rb:24**: Inconsistent indentation detected. (https://rubystyle.guide#spaces-indentation, https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions) - **/libraries/packer_post_processor_resource.rb:24**: Inconsistent indentation detected. (https://rubystyle.guide#spaces-indentation, https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions) - **/libraries/packer_provisioner_resource.rb:22**: Inconsistent indentation detected. (https://rubystyle.guide#spaces-indentation, https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions) - **/libraries/packer_provisioner_resource.rb:22**: Inconsistent indentation detected. (https://rubystyle.guide#spaces-indentation, https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions) - **/libraries/packer_template_resource.rb:22**: Inconsistent indentation detected. (https://rubystyle.guide#spaces-indentation, https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions) - **/libraries/packer_template_resource.rb:22**: Inconsistent indentation detected. (https://rubystyle.guide#spaces-indentation, https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions) - **/libraries/packer_variable_resource.rb:24**: Inconsistent indentation detected. (https://rubystyle.guide#spaces-indentation, https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions) - **/libraries/packer_variable_resource.rb:24**: Inconsistent indentation detected. (https://rubystyle.guide#spaces-indentation, https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions) ### Layout/IndentationWidth - **/libraries/packer_builder_resource.rb:22**: Use 2 (not -4) spaces for indentation. (https://rubystyle.guide#spaces-indentation) - **/libraries/packer_builder_resource.rb:22**: Use 2 (not 8) spaces for indentation. (https://rubystyle.guide#spaces-indentation) - **/libraries/packer_post_processor_resource.rb:24**: Use 2 (not -4) spaces for indentation. (https://rubystyle.guide#spaces-indentation) - **/libraries/packer_post_processor_resource.rb:24**: Use 2 (not 8) spaces for indentation. (https://rubystyle.guide#spaces-indentation) - **/libraries/packer_provisioner_resource.rb:22**: Use 2 (not -4) spaces for indentation. (https://rubystyle.guide#spaces-indentation) - **/libraries/packer_provisioner_resource.rb:22**: Use 2 (not 8) spaces for indentation. (https://rubystyle.guide#spaces-indentation) - **/libraries/packer_template_resource.rb:22**: Use 2 (not -4) spaces for indentation. (https://rubystyle.guide#spaces-indentation) - **/libraries/packer_template_resource.rb:22**: Use 2 (not 8) spaces for indentation. (https://rubystyle.guide#spaces-indentation) - **/libraries/packer_variable_resource.rb:24**: Use 2 (not -4) spaces for indentation. (https://rubystyle.guide#spaces-indentation) - **/libraries/packer_variable_resource.rb:24**: Use 2 (not 8) spaces for indentation. (https://rubystyle.guide#spaces-indentation) ### Chef/Sharing/InvalidLicenseString - **/metadata.rb:4**: Cookbook metadata.rb does not use a SPDX compliant license string or "all rights reserved". See https://spdx.org/licenses/ for a complete list of license identifiers. (https://docs.chef.io/workstation/cookstyle/chef_sharing_invalidlicensestring) ### Chef/RedundantCode/LongDescriptionMetadata - **/metadata.rb:6**: The long_description metadata.rb method is not used and is unnecessary in cookbooks. (https://docs.chef.io/workstation/cookstyle/chef_redundantcode_longdescriptionmetadata) ### Style/StringLiterals - **/test/fixtures/cookbooks/test/recipes/default.rb:1**: Prefer single-quoted strings when you don't need string interpolation or special symbols. (https://rubystyle.guide#consistent-string-literals) ### Layout/SpaceAroundOperators - **/test/fixtures/cookbooks/test/recipes/default.rb:14**: Surrounding space missing for operator `=>`. (https://rubystyle.guide#spaces-operators) Signed-off-by: Cookstyle --- attributes/default.rb | 2 +- libraries/helpers.rb | 2 +- libraries/packer_builder_provider.rb | 8 +------- libraries/packer_builder_resource.rb | 3 ++- libraries/packer_post_processor_provider.rb | 8 +------- libraries/packer_post_processor_resource.rb | 3 ++- libraries/packer_provisioner_provider.rb | 8 +------- libraries/packer_provisioner_resource.rb | 3 ++- libraries/packer_template_provider.rb | 8 +------- libraries/packer_template_resource.rb | 3 ++- libraries/packer_variable_provider.rb | 8 +------- libraries/packer_variable_resource.rb | 3 ++- metadata.rb | 3 +-- recipes/default.rb | 4 ++-- spec/unit/recipes/default_spec.rb | 4 ++-- test/fixtures/cookbooks/test/recipes/default.rb | 4 ++-- 16 files changed, 24 insertions(+), 50 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 3b931cd..3fcde68 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,5 +1,5 @@ default['packman']['checksums'] = { - '1.1.0' => 'bd1eddfa114f7e6258ef3419613380297f1b4e438f5bae92f1177150519be934' + '1.1.0' => 'bd1eddfa114f7e6258ef3419613380297f1b4e438f5bae92f1177150519be934', } default['packman']['version'] = '1.1.0' default['packman']['bin_dir'] = '/usr/local/bin' diff --git a/libraries/helpers.rb b/libraries/helpers.rb index 35d8d81..4d1db1e 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -74,7 +74,7 @@ def add_local_shell_provisioner(provisioner) def validate_type! return if %w(shell local-shell file).include?(new_resource.type) - Chef::Application.fatal!("Invalid Packman type: '#{new_resource.type}' declared") + raise("Invalid Packman type: '#{new_resource.type}' declared") end def render_template(template_source, template_variables) diff --git a/libraries/packer_builder_provider.rb b/libraries/packer_builder_provider.rb index 3373908..c53cc55 100644 --- a/libraries/packer_builder_provider.rb +++ b/libraries/packer_builder_provider.rb @@ -1,6 +1,6 @@ # # Author:: Partner Engineering -# Copyright (c) 2016, Chef Software, Inc. +# Copyright:: (c) 2016, Chef Software, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,12 +23,6 @@ class PackerBuilder < Chef::Provider::LWRPBase include PackmanCookbook::Helpers - use_inline_resources - - def whyrun_supported? - true - end - action :create do add_builder(new_resource.name, new_resource.options) end diff --git a/libraries/packer_builder_resource.rb b/libraries/packer_builder_resource.rb index 3e41a12..ff959fc 100644 --- a/libraries/packer_builder_resource.rb +++ b/libraries/packer_builder_resource.rb @@ -1,6 +1,6 @@ # # Author:: Partner Engineering -# Copyright (c) 2016, Chef Software, Inc. +# Copyright:: (c) 2016, Chef Software, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ class Chef class Resource class PackerBuilder < Chef::Resource::LWRPBase resource_name :packer_builder + provides :packer_builder actions :create default_action :create diff --git a/libraries/packer_post_processor_provider.rb b/libraries/packer_post_processor_provider.rb index 0c6fe7e..2ca00b7 100644 --- a/libraries/packer_post_processor_provider.rb +++ b/libraries/packer_post_processor_provider.rb @@ -1,6 +1,6 @@ # # Author:: Partner Engineering -# Copyright (c) 2016, Chef Software, Inc. +# Copyright:: (c) 2016, Chef Software, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,12 +23,6 @@ class PackerPostProcessor < Chef::Provider::LWRPBase include PackmanCookbook::Helpers - use_inline_resources - - def whyrun_supported? - true - end - action :create do add_post_processor(new_resource.type, new_resource.options) end diff --git a/libraries/packer_post_processor_resource.rb b/libraries/packer_post_processor_resource.rb index f0e78a7..ea49c3c 100644 --- a/libraries/packer_post_processor_resource.rb +++ b/libraries/packer_post_processor_resource.rb @@ -1,6 +1,6 @@ # # Author:: Partner Engineering -# Copyright (c) 2016, Chef Software, Inc. +# Copyright:: (c) 2016, Chef Software, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ class Chef class Resource class PackerPostProcessor < Chef::Resource::LWRPBase resource_name :packer_post_processor + provides :packer_post_processor actions :create default_action :create diff --git a/libraries/packer_provisioner_provider.rb b/libraries/packer_provisioner_provider.rb index 250a47d..b9d2aa9 100644 --- a/libraries/packer_provisioner_provider.rb +++ b/libraries/packer_provisioner_provider.rb @@ -1,6 +1,6 @@ # # Author:: Partner Engineering -# Copyright (c) 2016, Chef Software, Inc. +# Copyright:: (c) 2016, Chef Software, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,12 +23,6 @@ class PackerProvisioner < Chef::Provider::LWRPBase include PackmanCookbook::Helpers - use_inline_resources - - def whyrun_supported? - true - end - action :create do add_provisioner end diff --git a/libraries/packer_provisioner_resource.rb b/libraries/packer_provisioner_resource.rb index cbb425f..c138306 100644 --- a/libraries/packer_provisioner_resource.rb +++ b/libraries/packer_provisioner_resource.rb @@ -1,6 +1,6 @@ # # Author:: Partner Engineering -# Copyright (c) 2016, Chef Software, Inc. +# Copyright:: (c) 2016, Chef Software, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ class Chef class Resource class PackerProvisioner < Chef::Resource::LWRPBase resource_name :packer_provisioner + provides :packer_provisioner actions :create default_action :create diff --git a/libraries/packer_template_provider.rb b/libraries/packer_template_provider.rb index 8837be7..45e0ad7 100644 --- a/libraries/packer_template_provider.rb +++ b/libraries/packer_template_provider.rb @@ -1,6 +1,6 @@ # # Author:: Partner Engineering -# Copyright (c) 2016, Chef Software, Inc. +# Copyright:: (c) 2016, Chef Software, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,12 +23,6 @@ class PackerTemplate < Chef::Provider::LWRPBase include PackmanCookbook::Helpers - use_inline_resources - - def whyrun_supported? - true - end - action :create do create_packer_template run_packer diff --git a/libraries/packer_template_resource.rb b/libraries/packer_template_resource.rb index 8124c18..664758c 100644 --- a/libraries/packer_template_resource.rb +++ b/libraries/packer_template_resource.rb @@ -1,6 +1,6 @@ # # Author:: Partner Engineering -# Copyright (c) 2016, Chef Software, Inc. +# Copyright:: (c) 2016, Chef Software, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ class Chef class Resource class PackerTemplate < Chef::Resource::LWRPBase resource_name :packer_template + provides :packer_template actions :create, :run default_action :create diff --git a/libraries/packer_variable_provider.rb b/libraries/packer_variable_provider.rb index 089b65c..10a1525 100644 --- a/libraries/packer_variable_provider.rb +++ b/libraries/packer_variable_provider.rb @@ -1,6 +1,6 @@ # # Author:: Partner Engineering -# Copyright (c) 2016, Chef Software, Inc. +# Copyright:: (c) 2016, Chef Software, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,12 +24,6 @@ class PackerVariable < Chef::Provider::LWRPBase include PackmanCookbook::Helpers - use_inline_resources - - def whyrun_supported? - true - end - action :create do add_variable(new_resource.key, new_resource.value) end diff --git a/libraries/packer_variable_resource.rb b/libraries/packer_variable_resource.rb index b33200b..8970a87 100644 --- a/libraries/packer_variable_resource.rb +++ b/libraries/packer_variable_resource.rb @@ -1,6 +1,6 @@ # # Author:: Partner Engineering -# Copyright (c) 2016, Chef Software, Inc. +# Copyright:: (c) 2016, Chef Software, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ class Chef class Resource class PackerVariable < Chef::Resource::LWRPBase resource_name :packer_variable + provides :packer_variable actions :create default_action :create diff --git a/metadata.rb b/metadata.rb index dda4c07..1f290a8 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,7 +1,6 @@ name 'packman' maintainer 'The Authors' maintainer_email 'you@example.com' -license 'all_rights' +license 'all rights reserved' description 'Installs/Configures packman' -long_description 'Installs/Configures packman' version '0.2.0' diff --git a/recipes/default.rb b/recipes/default.rb index bc573f7..375df80 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -1,7 +1,7 @@ # -# Cookbook Name:: packman +# Cookbook:: packman # Recipe:: default # -# Copyright (c) 2016 The Authors, All Rights Reserved. +# Copyright:: (c) 2016 The Authors, All Rights Reserved. include_recipe 'packman::_packer_install' diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb index 5dff71c..fc5ba6f 100644 --- a/spec/unit/recipes/default_spec.rb +++ b/spec/unit/recipes/default_spec.rb @@ -1,8 +1,8 @@ # -# Cookbook Name:: packman +# Cookbook:: packman # Spec:: default # -# Copyright (c) 2016 The Authors, All Rights Reserved. +# Copyright:: (c) 2016 The Authors, All Rights Reserved. require 'spec_helper' diff --git a/test/fixtures/cookbooks/test/recipes/default.rb b/test/fixtures/cookbooks/test/recipes/default.rb index 1f1ef8b..06ce197 100644 --- a/test/fixtures/cookbooks/test/recipes/default.rb +++ b/test/fixtures/cookbooks/test/recipes/default.rb @@ -1,4 +1,4 @@ -include_recipe "packman::default" +include_recipe 'packman::default' packer_builder 'azure_test' do options( @@ -11,7 +11,7 @@ 'client_secret' => 'P@ssw0rd!', 'subscription_id' => '1C2B75C1-74A5-472A-A729-7F8CEFC477F9', 'resource_group_name' => 'myResourceGroup', - 'image_publisher'=> 'Canonical', + 'image_publisher' => 'Canonical', 'image_offer' => 'UbuntuServer', 'image_sku' => '14.04.5-LTS', 'storage_account' => 'myimages',