Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a situation where deploys would fail if the workspace is in a non-standard location #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions libraries/helpers_deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions spec/unit/recipes/deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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',
Expand Down