From 58d7df3e61b7f76fa558d347804bd8ff81293d8a Mon Sep 17 00:00:00 2001 From: vishalbasra Date: Wed, 30 May 2018 10:56:13 +0530 Subject: [PATCH 1/2] check if cb doesnt exist --- lib/chef/knife/inventory_cookbook.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/chef/knife/inventory_cookbook.rb b/lib/chef/knife/inventory_cookbook.rb index a141fb9..9c50fc9 100644 --- a/lib/chef/knife/inventory_cookbook.rb +++ b/lib/chef/knife/inventory_cookbook.rb @@ -26,8 +26,16 @@ def run @cookbook_version = name_args[1] @show_env_constraints = config[:env_constraints] - unless @cookbook_name - ui.error "You need to specify a cookbook" + if @cookbook_name + cookbook_object = search_nodes("cookbooks_#{@cookbook_name}:*") + if cookbook_object.to_s == '[]' + ui.fatal "The cookbook name you provided #{cookbook_name} does not exist on the Chef server." + show_usage + exit 1 + end + else + ui.fatal "You did not specify a cookbook. You need to specify a cookbook." + show_usage exit 1 end From 6b18a201460b2dbb47bf4c84139717b2668793f6 Mon Sep 17 00:00:00 2001 From: vishalbasra Date: Mon, 11 Jun 2018 10:26:46 +0530 Subject: [PATCH 2/2] some rubocop fixes --- lib/chef/knife/inventory_chef_client.rb | 2 +- lib/chef/knife/inventory_cookbook.rb | 2 +- tasks/changelog.rake | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/chef/knife/inventory_chef_client.rb b/lib/chef/knife/inventory_chef_client.rb index ead4f30..e860821 100644 --- a/lib/chef/knife/inventory_chef_client.rb +++ b/lib/chef/knife/inventory_chef_client.rb @@ -43,7 +43,7 @@ def search_args rows: max_results, filter_result: { name: ["name"], - chef_version: %w[chef_packages chef version], + chef_version: %w(chef_packages chef version), ohai_time: ["ohai_time"] } } diff --git a/lib/chef/knife/inventory_cookbook.rb b/lib/chef/knife/inventory_cookbook.rb index 1685d46..a9a5128 100644 --- a/lib/chef/knife/inventory_cookbook.rb +++ b/lib/chef/knife/inventory_cookbook.rb @@ -29,7 +29,7 @@ def run if @cookbook_name cookbook_object = search_nodes("cookbooks_#{@cookbook_name}:*") - if cookbook_object.to_s == '[]' + if cookbook_object.to_s == "[]" ui.fatal "The cookbook name you provided #{cookbook_name} does not exist on the Chef server." show_usage exit 1 diff --git a/tasks/changelog.rake b/tasks/changelog.rake index 82a932e..b74b3a4 100644 --- a/tasks/changelog.rake +++ b/tasks/changelog.rake @@ -7,9 +7,9 @@ begin GitHubChangelogGenerator::RakeTask.new :changelog do |config| config.future_release = "v#{Knife::ChefInventory::VERSION}" config.issues = false - config.enhancement_labels = %w[enhancement] - config.bug_labels = %w[bug] - config.exclude_labels = %w[no_changelog] + config.enhancement_labels = %w(enhancement) + config.bug_labels = %w(bug) + config.exclude_labels = %w(no_changelog) end rescue LoadError puts "Problem loading gems please install chef and github_changelog_generator"