From 3761ce367e6a21f759e119526cc75300b95e09ff Mon Sep 17 00:00:00 2001 From: Irving Popovetsky Date: Tue, 3 Jan 2017 17:58:09 -0800 Subject: [PATCH 1/2] The DeliverySugar::ChefServer class expects a node object to exist to look up the delivery_knife_rb, but that doesn't exist the way it's being called here. Use the existing delivery_knife_rb DSL method to fix that Signed-off-by: Irving Popovetsky --- libraries/helpers_deploy.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/helpers_deploy.rb b/libraries/helpers_deploy.rb index 1d82307..475eaa4 100644 --- a/libraries/helpers_deploy.rb +++ b/libraries/helpers_deploy.rb @@ -31,9 +31,9 @@ def deployment_search_query(node) 'recipes:*push-jobs*' end - def delivery_chef_server_search(type, query) + def delivery_chef_server_search(type, query, delivery_knife_rb) results = [] - DeliverySugar::ChefServer.new.with_server_config do + DeliverySugar::ChefServer.new(delivery_knife_rb).with_server_config do ::Chef::Search::Query.new.search(type, query) { |o| results << o } end results @@ -43,7 +43,7 @@ def delivery_chef_server_search(type, query) module DSL def delivery_chef_server_search(type, query) - DeliveryTruck::Helpers::Deploy.delivery_chef_server_search(type, query) + DeliveryTruck::Helpers::Deploy.delivery_chef_server_search(type, query, delivery_knife_rb) end # Check config.json to get deployment search query From 019157e2b44fd16f57e8b1b20b56be928ea511a0 Mon Sep 17 00:00:00 2001 From: Irving Popovetsky Date: Tue, 3 Jan 2017 18:04:28 -0800 Subject: [PATCH 2/2] Fix test to include delivery_knife_rb Signed-off-by: Irving Popovetsky --- spec/unit/recipes/deploy_spec.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/unit/recipes/deploy_spec.rb b/spec/unit/recipes/deploy_spec.rb index 8bd1ac0..938702c 100644 --- a/spec/unit/recipes/deploy_spec.rb +++ b/spec/unit/recipes/deploy_spec.rb @@ -35,6 +35,9 @@ def initialize(name) "(#{recipe_list}) AND chef_environment:union AND recipes:*push-jobs*" end let(:node_list) { [MyFakeNode.new("node1"), MyFakeNode.new("node2")] } + let(:delivery_knife_rb) do + "/var/opt/delivery/workspace/.chef/knife.rb" + end context "when a single cookbook has been modified" do before do @@ -45,7 +48,7 @@ def initialize(name) let(:recipe_list) { 'recipes:julia*' } it "deploy only that cookbook" do - expect(DeliveryTruck::Helpers::Deploy).to receive(:delivery_chef_server_search).with(:node, search_query).and_return(node_list) + expect(DeliveryTruck::Helpers::Deploy).to receive(:delivery_chef_server_search).with(:node, search_query, delivery_knife_rb).and_return(node_list) expect(chef_run).to dispatch_delivery_push_job("deploy_Secret").with( :command => 'chef-client', :nodes => node_list @@ -62,7 +65,7 @@ def initialize(name) end it "deploy only that cookbook with the special search query" do expect(DeliveryTruck::Helpers::Deploy).to receive(:delivery_chef_server_search) - .with(:node, search_query) + .with(:node, search_query, delivery_knife_rb) .and_return(node_list) expect(chef_run).to dispatch_delivery_push_job("deploy_Secret").with( :command => 'chef-client',