From 250fe79dc8257b90fe9ab72220c52b9be808284f Mon Sep 17 00:00:00 2001 From: Jonathan Hartman Date: Wed, 17 May 2017 14:18:17 -0700 Subject: [PATCH] Ensure a config object is passed down in the update action The install action was already doing this, but the update action would fail on a Chef Server or Artifactory source when they tried to fetch a client or API key from the nil chef_config. Signed-off-by: Jonathan Hartman --- lib/chef-dk/command/update.rb | 2 +- spec/unit/command/install_spec.rb | 4 ++-- spec/unit/command/update_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/chef-dk/command/update.rb b/lib/chef-dk/command/update.rb index f43f4bbd7..6c560a076 100644 --- a/lib/chef-dk/command/update.rb +++ b/lib/chef-dk/command/update.rb @@ -101,7 +101,7 @@ def run(params = []) end def installer - @installer ||= PolicyfileServices::Install.new(policyfile: policyfile_relative_path, ui: ui, root_dir: Dir.pwd, overwrite: true) + @installer ||= PolicyfileServices::Install.new(policyfile: policyfile_relative_path, ui: ui, root_dir: Dir.pwd, config: chef_config, overwrite: true) end def attributes_updater diff --git a/spec/unit/command/install_spec.rb b/spec/unit/command/install_spec.rb index 77216ff25..5aaede60a 100644 --- a/spec/unit/command/install_spec.rb +++ b/spec/unit/command/install_spec.rb @@ -78,7 +78,7 @@ it "creates the installer service with a `nil` policyfile path" do expect(ChefDK::PolicyfileServices::Install).to receive(:new). - with(hash_including(policyfile: nil, ui: command.ui, root_dir: Dir.pwd)). + with(hash_including(policyfile: nil, ui: command.ui, root_dir: Dir.pwd, config: Chef::Config)). and_return(install_service) expect(command.installer).to eq(install_service) end @@ -95,7 +95,7 @@ it "creates the installer service with the specified policyfile path" do expect(ChefDK::PolicyfileServices::Install).to receive(:new). - with(hash_including(policyfile: "MyPolicy.rb", ui: command.ui, root_dir: Dir.pwd)). + with(hash_including(policyfile: "MyPolicy.rb", ui: command.ui, root_dir: Dir.pwd, config: Chef::Config)). and_return(install_service) expect(command.installer).to eq(install_service) end diff --git a/spec/unit/command/update_spec.rb b/spec/unit/command/update_spec.rb index b65bb21b0..f182a3633 100644 --- a/spec/unit/command/update_spec.rb +++ b/spec/unit/command/update_spec.rb @@ -96,7 +96,7 @@ it "creates the installer service with a `nil` policyfile path" do expect(ChefDK::PolicyfileServices::Install).to receive(:new). - with(policyfile: nil, ui: command.ui, root_dir: Dir.pwd, overwrite: true). + with(policyfile: nil, ui: command.ui, root_dir: Dir.pwd, config: Chef::Config, overwrite: true). and_return(install_service) expect(command.installer).to eq(install_service) end @@ -113,7 +113,7 @@ it "creates the installer service with the specified policyfile path" do expect(ChefDK::PolicyfileServices::Install).to receive(:new). - with(policyfile: "MyPolicy.rb", ui: command.ui, root_dir: Dir.pwd, overwrite: true). + with(policyfile: "MyPolicy.rb", ui: command.ui, root_dir: Dir.pwd, config: Chef::Config, overwrite: true). and_return(install_service) expect(command.installer).to eq(install_service) end