summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md56
-rw-r--r--Dockerfile2
-rw-r--r--Gemfile.lock10
-rw-r--r--VERSION2
-rw-r--r--chef-config/lib/chef-config/version.rb2
-rw-r--r--lib/chef/mixin/deep_merge.rb2
-rw-r--r--lib/chef/shell.rb1
-rw-r--r--lib/chef/shell/shell_session.rb8
-rw-r--r--lib/chef/version.rb2
-rw-r--r--spec/unit/node_spec.rb7
-rw-r--r--spec/unit/shell/shell_session_spec.rb140
11 files changed, 136 insertions, 96 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 75934a4d27..dcb5ce4fae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,38 +1,46 @@
-<!-- latest_release 13.3.46 -->
-## [v13.3.46](https://github.com/chef/chef/tree/v13.3.46) (2017-08-15)
+<!-- latest_release 13.3.47 -->
+## [v13.3.47](https://github.com/chef/chef/tree/v13.3.47) (2017-08-16)
-#### Merged Pull Requests
-- Ignore validation errors in Resource#to_text [#6331](https://github.com/chef/chef/pull/6331) ([coderanger](https://github.com/coderanger))
+#### Bug Fixes
+- Pass json configuration to ShellSession class [#6314](https://github.com/chef/chef/pull/6314) ([btm](https://github.com/btm))
<!-- latest_release -->
-<!-- release_rollup since=13.2.20 -->
-### Changes since 13.2.20 release
+<!-- release_rollup since=13.3.42 -->
+### Changes since 13.3.42 release
+
+#### Bug Fixes
+- Pass json configuration to ShellSession class [#6314](https://github.com/chef/chef/pull/6314) ([btm](https://github.com/btm)) <!-- 13.3.47 -->
#### Merged Pull Requests
-- Ignore validation errors in Resource#to_text [#6331](https://github.com/chef/chef/pull/6331) ([coderanger](https://github.com/coderanger)) <!-- 13.3.46 -->
-- Catch Chef 12 changelog up to current 12 release [#6327](https://github.com/chef/chef/pull/6327) ([tas50](https://github.com/tas50)) <!-- 13.3.45 -->
-- Fix bad examples in the release notes [#6326](https://github.com/chef/chef/pull/6326) ([tas50](https://github.com/tas50)) <!-- 13.3.44 -->
- Add more items to the 13.3 release notes [#6325](https://github.com/chef/chef/pull/6325) ([tas50](https://github.com/tas50)) <!-- 13.3.43 -->
-- Bump InSpec to v1.33.1 [#6324](https://github.com/chef/chef/pull/6324) ([adamleff](https://github.com/adamleff)) <!-- 13.3.42 -->
-- README improvement for Chef beginner. [#6297](https://github.com/chef/chef/pull/6297) ([takaya-fuj19](https://github.com/takaya-fuj19)) <!-- 13.3.41 -->
-- Maintain compat with old zypper_repo resource used in cookbooks [#6318](https://github.com/chef/chef/pull/6318) ([tas50](https://github.com/tas50)) <!-- 13.3.40 -->
-- Pull in Ohai 13.3 [#6319](https://github.com/chef/chef/pull/6319) ([tas50](https://github.com/tas50)) <!-- 13.3.39 -->
-- Add release notes for 13.3 [#6317](https://github.com/chef/chef/pull/6317) ([tas50](https://github.com/tas50)) <!-- 13.3.38 -->
-- Add zypper_repository resource [#5948](https://github.com/chef/chef/pull/5948) ([tas50](https://github.com/tas50)) <!-- 13.3.37 -->
-- throw readable errors if multiple dsc resources are found [#6307](https://github.com/chef/chef/pull/6307) ([Happycoil](https://github.com/Happycoil)) <!-- 13.3.36 -->
-- Bump omnibus-software version [#6310](https://github.com/chef/chef/pull/6310) ([thommay](https://github.com/thommay)) <!-- 13.3.35 -->
-- add option to enable unprivileged symlink creation on windows [#6236](https://github.com/chef/chef/pull/6236) ([svmastersamurai](https://github.com/svmastersamurai)) <!-- 13.3.34 -->
-- Fix git command in DCO sign-off example [#6306](https://github.com/chef/chef/pull/6306) ([edmorley](https://github.com/edmorley)) <!-- 13.3.33 -->
-- Add .dockerignore to reduce size of resulting images [#6296](https://github.com/chef/chef/pull/6296) ([tduffield](https://github.com/tduffield)) <!-- 13.3.32 -->
-- Set explicit page size for every search request [#6299](https://github.com/chef/chef/pull/6299) ([stevendanna](https://github.com/stevendanna)) <!-- 13.3.31 -->
-- Fix typos [#6298](https://github.com/chef/chef/pull/6298) ([akitada](https://github.com/akitada)) <!-- 13.3.30 -->
-- Apt: Add apt_preference resource from apt cookbooks [#5529](https://github.com/chef/chef/pull/5529) ([tas50](https://github.com/tas50)) <!-- 13.3.29 -->
-- Update Expeditor config to use new Merge and Artifact Actions [#6287](https://github.com/chef/chef/pull/6287) ([tduffield](https://github.com/tduffield)) <!-- 13.3.28 -->
+- Fix bad examples in the release notes [#6326](https://github.com/chef/chef/pull/6326) ([tas50](https://github.com/tas50)) <!-- 13.3.44 -->
+- Catch Chef 12 changelog up to current 12 release [#6327](https://github.com/chef/chef/pull/6327) ([tas50](https://github.com/tas50)) <!-- 13.3.45 -->
+- Ignore validation errors in Resource#to_text [#6331](https://github.com/chef/chef/pull/6331) ([coderanger](https://github.com/coderanger)) <!-- 13.3.46 -->
<!-- release_rollup -->
<!-- latest_stable_release -->
+## [v13.3.42](https://github.com/chef/chef/tree/v13.3.42) (2017-08-16)
+
+#### Merged Pull Requests
+- Update Expeditor config to use new Merge and Artifact Actions [#6287](https://github.com/chef/chef/pull/6287) ([tduffield](https://github.com/tduffield))
+- Apt: Add apt_preference resource from apt cookbooks [#5529](https://github.com/chef/chef/pull/5529) ([tas50](https://github.com/tas50))
+- Fix typos [#6298](https://github.com/chef/chef/pull/6298) ([akitada](https://github.com/akitada))
+- Set explicit page size for every search request [#6299](https://github.com/chef/chef/pull/6299) ([stevendanna](https://github.com/stevendanna))
+- Add .dockerignore to reduce size of resulting images [#6296](https://github.com/chef/chef/pull/6296) ([tduffield](https://github.com/tduffield))
+- Fix git command in DCO sign-off example [#6306](https://github.com/chef/chef/pull/6306) ([edmorley](https://github.com/edmorley))
+- add option to enable unprivileged symlink creation on windows [#6236](https://github.com/chef/chef/pull/6236) ([svmastersamurai](https://github.com/svmastersamurai))
+- Bump omnibus-software version [#6310](https://github.com/chef/chef/pull/6310) ([thommay](https://github.com/thommay))
+- throw readable errors if multiple dsc resources are found [#6307](https://github.com/chef/chef/pull/6307) ([Happycoil](https://github.com/Happycoil))
+- Add zypper_repository resource [#5948](https://github.com/chef/chef/pull/5948) ([tas50](https://github.com/tas50))
+- Add release notes for 13.3 [#6317](https://github.com/chef/chef/pull/6317) ([tas50](https://github.com/tas50))
+- Pull in Ohai 13.3 [#6319](https://github.com/chef/chef/pull/6319) ([tas50](https://github.com/tas50))
+- Maintain compat with old zypper_repo resource used in cookbooks [#6318](https://github.com/chef/chef/pull/6318) ([tas50](https://github.com/tas50))
+- README improvement for Chef beginner. [#6297](https://github.com/chef/chef/pull/6297) ([takaya-fuj19](https://github.com/takaya-fuj19))
+- Bump InSpec to v1.33.1 [#6324](https://github.com/chef/chef/pull/6324) ([adamleff](https://github.com/adamleff))
<!-- latest_stable_release -->
+
+
## [v13.3.27](https://github.com/chef/chef/tree/v13.3.27) (2017-07-26)
[Full Changelog](https://github.com/chef/chef/compare/v13.0.118...v13.3.27)
diff --git a/Dockerfile b/Dockerfile
index 4befc17d39..97461cee9e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,7 +2,7 @@ FROM busybox
MAINTAINER Chef Software, Inc. <docker@chef.io>
ARG CHANNEL=stable
-ARG VERSION=13.2.20
+ARG VERSION=13.3.42
RUN wget "http://packages.chef.io/files/${CHANNEL}/chef/${VERSION}/el/5/chef-${VERSION}-1.el5.x86_64.rpm" -O /tmp/chef-client.rpm && \
rpm2cpio /tmp/chef-client.rpm | cpio -idmv && \
diff --git a/Gemfile.lock b/Gemfile.lock
index bb456f69d1..fc0a094749 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -17,10 +17,10 @@ GIT
PATH
remote: .
specs:
- chef (13.3.46)
+ chef (13.3.47)
addressable
bundler (>= 1.10)
- chef-config (= 13.3.46)
+ chef-config (= 13.3.47)
chef-zero (>= 13.0)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
@@ -47,10 +47,10 @@ PATH
specinfra (~> 2.10)
syslog-logger (~> 1.6)
uuidtools (~> 2.1.5)
- chef (13.3.46-universal-mingw32)
+ chef (13.3.47-universal-mingw32)
addressable
bundler (>= 1.10)
- chef-config (= 13.3.46)
+ chef-config (= 13.3.47)
chef-zero (>= 13.0)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
@@ -92,7 +92,7 @@ PATH
PATH
remote: chef-config
specs:
- chef-config (13.3.46)
+ chef-config (13.3.47)
addressable
fuzzyurl
mixlib-config (~> 2.0)
diff --git a/VERSION b/VERSION
index cd774741a8..db6914fc5e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-13.3.46 \ No newline at end of file
+13.3.47 \ No newline at end of file
diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb
index 5fd2149b35..9552a5002b 100644
--- a/chef-config/lib/chef-config/version.rb
+++ b/chef-config/lib/chef-config/version.rb
@@ -20,7 +20,7 @@
module ChefConfig
CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__)
- VERSION = "13.3.46"
+ VERSION = "13.3.47"
end
#
diff --git a/lib/chef/mixin/deep_merge.rb b/lib/chef/mixin/deep_merge.rb
index 7016b08ff7..9ec2b397d4 100644
--- a/lib/chef/mixin/deep_merge.rb
+++ b/lib/chef/mixin/deep_merge.rb
@@ -64,7 +64,7 @@ class Chef
when Hash
if dest.kind_of?(Hash)
source.each do |src_key, src_value|
- if dest[src_key]
+ if dest.key?(src_key)
dest[src_key] = deep_merge!(src_value, dest[src_key])
else # dest[src_key] doesn't exist so we take whatever source has
dest[src_key] = src_value
diff --git a/lib/chef/shell.rb b/lib/chef/shell.rb
index b4c0277c57..40bdf01762 100644
--- a/lib/chef/shell.rb
+++ b/lib/chef/shell.rb
@@ -138,6 +138,7 @@ module Shell
def self.session
unless client_type.instance.node_built?
puts "Session type: #{client_type.session_type}"
+ client_type.instance.json_configuration = @json_attribs
client_type.instance.reset!
end
client_type.instance
diff --git a/lib/chef/shell/shell_session.rb b/lib/chef/shell/shell_session.rb
index 41d5bd64a0..dfed5372c1 100644
--- a/lib/chef/shell/shell_session.rb
+++ b/lib/chef/shell/shell_session.rb
@@ -38,7 +38,7 @@ module Shell
@session_type
end
- attr_accessor :node, :compile, :recipe, :run_context
+ attr_accessor :node, :compile, :recipe, :run_context, :json_configuration
attr_reader :node_attributes, :client
def initialize
@node_built = false
@@ -151,7 +151,7 @@ module Shell
def rebuild_node
Chef::Config[:solo_legacy_mode] = true
- @client = Chef::Client.new(nil, Chef::Config[:shell_config])
+ @client = Chef::Client.new(json_configuration, Chef::Config[:shell_config])
@client.run_ohai
@client.load_node
@client.build_node
@@ -183,7 +183,7 @@ module Shell
def rebuild_node
# Tell the client we're chef solo so it won't try to contact the server
Chef::Config[:solo_legacy_mode] = true
- @client = Chef::Client.new(nil, Chef::Config[:shell_config])
+ @client = Chef::Client.new(json_configuration, Chef::Config[:shell_config])
@client.run_ohai
@client.load_node
@client.build_node
@@ -218,7 +218,7 @@ module Shell
def rebuild_node
# Make sure the client knows this is not chef solo
Chef::Config[:solo_legacy_mode] = false
- @client = Chef::Client.new(nil, Chef::Config[:shell_config])
+ @client = Chef::Client.new(json_configuration, Chef::Config[:shell_config])
@client.run_ohai
@client.register
@client.load_node
diff --git a/lib/chef/version.rb b/lib/chef/version.rb
index 1d30b97614..fa9eab78da 100644
--- a/lib/chef/version.rb
+++ b/lib/chef/version.rb
@@ -22,7 +22,7 @@ require "chef/version_string"
class Chef
CHEF_ROOT = File.expand_path("../..", __FILE__)
- VERSION = Chef::VersionString.new("13.3.46")
+ VERSION = Chef::VersionString.new("13.3.47")
end
#
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 73f0e6da09..7dc972b5a0 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -337,6 +337,13 @@ describe Chef::Node do
node.override_unless[:decontamination] = "foo"
expect(node.override[:decontamination]).to eql("foo")
end
+
+ it "consume_attributes does not exhibit chef/chef/issues/6302 bug" do
+ node.normal["a"]["r1"] = nil
+ node.consume_attributes({ "a" => { "r2" => nil } })
+ expect(node["a"]["r1"]).to be_nil
+ expect(node["a"]["r2"]).to be_nil
+ end
end
describe "default attributes" do
diff --git a/spec/unit/shell/shell_session_spec.rb b/spec/unit/shell/shell_session_spec.rb
index 170767fbd6..7ed372f375 100644
--- a/spec/unit/shell/shell_session_spec.rb
+++ b/spec/unit/shell/shell_session_spec.rb
@@ -47,119 +47,143 @@ describe Shell::ShellSession do
end
describe Shell::ClientSession do
+ let(:json_attribs) { { "a" => "b" } }
+ let(:chef_rest) { double("Chef::ServerAPI") }
+ let(:node) { Chef::Node.build("foo") }
+ let(:session) { Shell::ClientSession.instance }
+ let(:client) do
+ double("Chef::Client.new",
+ :run_ohai => true,
+ :load_node => true,
+ :build_node => true,
+ :register => true,
+ :sync_cookbooks => {}
+ )
+ end
+
before do
Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] }
- @chef_rest = double("Chef::ServerAPI")
- @session = Shell::ClientSession.instance
- @node = Chef::Node.build("foo")
- @session.node = @node
- @client = double("Chef::Client.new",
- :run_ohai => true,
- :load_node => true,
- :build_node => true,
- :register => true,
- :sync_cookbooks => {})
+ session.node = node
+ session.json_configuration = json_attribs
end
it "builds the node's run_context with the proper environment" do
- @session.instance_variable_set(:@client, @client)
- @expansion = Chef::RunList::RunListExpansion.new(@node.chef_environment, [])
+ session.instance_variable_set(:@client, client)
+ expansion = Chef::RunList::RunListExpansion.new(node.chef_environment, [])
- expect(@node.run_list).to receive(:expand).with(@node.chef_environment).and_return(@expansion)
- expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url]).and_return(@chef_rest)
- @session.rebuild_context
+ expect(node.run_list).to receive(:expand).with(node.chef_environment).and_return(expansion)
+ expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url]).and_return(chef_rest)
+ session.rebuild_context
end
it "passes the shell CLI args to the client" do
- expect(Chef::Client).to receive(:new).with(nil, Chef::Config[:shell_config]).and_return(@client)
- @session.send(:rebuild_node)
+ expect(Chef::Client).to receive(:new).with(json_attribs, Chef::Config[:shell_config]).and_return(client)
+ session.send(:rebuild_node)
end
end
describe Shell::SoloSession do
+ let(:json_attribs) { { "a" => "b" } }
+ let(:chef_rest) { double("Chef::ServerAPI") }
+ let(:node) { Chef::Node.build("foo") }
+ let(:session) { Shell::SoloSession.instance }
+ let(:client) do
+ double("Chef::Client.new",
+ :run_ohai => true,
+ :load_node => true,
+ :build_node => true,
+ :register => true,
+ :sync_cookbooks => {}
+ )
+ end
+
before do
Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] }
- @chef_rest = double("Chef::ServerAPI")
- @session = Shell::SoloSession.instance
- @node = Chef::Node.build("foo")
- @session.node = @node
- @client = double("Chef::Client.new",
- :run_ohai => true,
- :load_node => true,
- :build_node => true,
- :register => true,
- :sync_cookbooks => {})
+ session.node = node
+ session.json_configuration = json_attribs
end
it "builds the node's run_context with the proper environment" do
- @session.instance_variable_set(:@client, @client)
- @expansion = Chef::RunList::RunListExpansion.new(@node.chef_environment, [])
+ session.instance_variable_set(:@client, client)
+ expansion = Chef::RunList::RunListExpansion.new(node.chef_environment, [])
- expect(@node.run_list).to receive(:expand).with(@node.chef_environment).and_return(@expansion)
- expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url]).and_return(@chef_rest)
- @session.rebuild_context
+ expect(node.run_list).to receive(:expand).with(node.chef_environment).and_return(expansion)
+ expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url]).and_return(chef_rest)
+ session.rebuild_context
end
it "passes the shell CLI args to the client" do
- expect(Chef::Client).to receive(:new).with(nil, Chef::Config[:shell_config]).and_return(@client)
- @session.send(:rebuild_node)
+ expect(Chef::Client).to receive(:new).with(json_attribs, Chef::Config[:shell_config]).and_return(client)
+ session.send(:rebuild_node)
end
end
describe Shell::StandAloneSession do
+ let(:json_attribs) { { "a" => "b" } }
+ let(:chef_rest) { double("Chef::ServerAPI") }
+ let(:node) { Chef::Node.new }
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
+ let(:session) { Shell::StandAloneSession.instance }
+ let(:client) do
+ double("Chef::Client.new",
+ :run_ohai => true,
+ :load_node => true,
+ :build_node => true,
+ :register => true,
+ :sync_cookbooks => {}
+ )
+ end
+ let(:recipe) { Chef::Recipe.new(nil, nil, run_context) }
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
+
before do
Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] }
- @session = Shell::StandAloneSession.instance
- @node = @session.node = Chef::Node.new
- @events = Chef::EventDispatch::Dispatcher.new
- @run_context = @session.run_context = Chef::RunContext.new(@node, {}, @events)
- @recipe = @session.recipe = Chef::Recipe.new(nil, nil, @run_context)
- Shell::Extensions.extend_context_recipe(@recipe)
+ session.node = node
+ session.json_configuration = json_attribs
+ session.run_context = run_context
+ session.recipe = recipe
+ Shell::Extensions.extend_context_recipe(recipe)
end
it "has a run_context" do
- expect(@session.run_context).to equal(@run_context)
+ expect(session.run_context).to equal(run_context)
end
it "returns a collection based on it's standalone recipe file" do
- expect(@session.resource_collection).to eq(@recipe.run_context.resource_collection)
+ expect(session.resource_collection).to eq(recipe.run_context.resource_collection)
end
it "gives nil for the definitions (for now)" do
- expect(@session.definitions).to be_nil
+ expect(session.definitions).to be_nil
end
it "gives nil for the cookbook_loader" do
- expect(@session.cookbook_loader).to be_nil
+ expect(session.cookbook_loader).to be_nil
end
it "runs chef with the standalone recipe" do
- allow(@session).to receive(:node_built?).and_return(true)
+ allow(session).to receive(:node_built?).and_return(true)
allow(Chef::Log).to receive(:level)
chef_runner = double("Chef::Runner.new", :converge => :converged)
# pre-heat resource collection cache
- @session.resource_collection
+ session.resource_collection
- expect(Chef::Runner).to receive(:new).with(@session.recipe.run_context).and_return(chef_runner)
- expect(@recipe.run_chef).to eq(:converged)
+ expect(Chef::Runner).to receive(:new).with(session.recipe.run_context).and_return(chef_runner)
+ expect(recipe.run_chef).to eq(:converged)
end
it "passes the shell CLI args to the client" do
- @client = double("Chef::Client.new",
- :run_ohai => true,
- :load_node => true,
- :build_node => true,
- :register => true,
- :sync_cookbooks => {})
- expect(Chef::Client).to receive(:new).with(nil, Chef::Config[:shell_config]).and_return(@client)
- @session.send(:rebuild_node)
+ expect(Chef::Client).to receive(:new).with(json_attribs, Chef::Config[:shell_config]).and_return(client)
+ session.send(:rebuild_node)
end
end
describe Shell::SoloLegacySession do
+ let(:json_attribs) { { "a" => "b" } }
+
before do
Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] }
Chef::Config[:shell_solo] = true
@@ -219,8 +243,8 @@ describe Shell::SoloLegacySession do
:build_node => true,
:register => true,
:sync_cookbooks => {})
- expect(Chef::Client).to receive(:new).with(nil, Chef::Config[:shell_config]).and_return(@client)
+ expect(Chef::Client).to receive(:new).with(json_attribs, Chef::Config[:shell_config]).and_return(@client)
+ @session.json_configuration = json_attribs
@session.send(:rebuild_node)
end
-
end