summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md8
-rw-r--r--Gemfile.lock10
-rw-r--r--VERSION2
-rw-r--r--chef-config/lib/chef-config/version.rb2
-rw-r--r--lib/chef/application.rb4
-rw-r--r--lib/chef/application/windows_service.rb2
-rw-r--r--lib/chef/node.rb21
-rw-r--r--lib/chef/version.rb2
-rw-r--r--lib/chef/whitelist.rb2
-rw-r--r--spec/unit/application_spec.rb2
-rw-r--r--spec/unit/log/syslog_spec.rb4
-rw-r--r--spec/unit/log/winevt_spec.rb4
-rw-r--r--spec/unit/node_spec.rb87
13 files changed, 73 insertions, 77 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8e1333d844..10b1a4f4cf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,15 +1,17 @@
<!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ -->
-<!-- latest_release 14.12.6 -->
-## [v14.12.6](https://github.com/chef/chef/tree/v14.12.6) (2019-04-19)
+<!-- latest_release 14.12.8 -->
+## [v14.12.8](https://github.com/chef/chef/tree/v14.12.8) (2019-04-19)
#### Merged Pull Requests
-- Add placeholder license acceptance flags [#8398](https://github.com/chef/chef/pull/8398) ([tas50](https://github.com/tas50))
+- Improve the error message when no config can be loaded [#8401](https://github.com/chef/chef/pull/8401) ([tas50](https://github.com/tas50))
<!-- latest_release -->
<!-- release_rollup since=14.12.3 -->
### Changes since 14.12.3 release
#### Merged Pull Requests
+- Improve the error message when no config can be loaded [#8401](https://github.com/chef/chef/pull/8401) ([tas50](https://github.com/tas50)) <!-- 14.12.8 -->
+- Fix default/override attribute blacklists and whitelists [#8400](https://github.com/chef/chef/pull/8400) ([tas50](https://github.com/tas50)) <!-- 14.12.7 -->
- Add placeholder license acceptance flags [#8398](https://github.com/chef/chef/pull/8398) ([tas50](https://github.com/tas50)) <!-- 14.12.6 -->
- Update win32-service + bump inspec to 3.9.3 [#8387](https://github.com/chef/chef/pull/8387) ([tas50](https://github.com/tas50)) <!-- 14.12.5 -->
- Backport #8077 to Chef 14 [#8384](https://github.com/chef/chef/pull/8384) ([btm](https://github.com/btm)) <!-- 14.12.4 -->
diff --git a/Gemfile.lock b/Gemfile.lock
index ac674ef364..dfc60d29e7 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,10 +1,10 @@
PATH
remote: .
specs:
- chef (14.12.6)
+ chef (14.12.8)
addressable
bundler (>= 1.10)
- chef-config (= 14.12.6)
+ chef-config (= 14.12.8)
chef-zero (>= 13.0)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
@@ -31,10 +31,10 @@ PATH
specinfra (~> 2.10)
syslog-logger (~> 1.6)
uuidtools (~> 2.1.5)
- chef (14.12.6-universal-mingw32)
+ chef (14.12.8-universal-mingw32)
addressable
bundler (>= 1.10)
- chef-config (= 14.12.6)
+ chef-config (= 14.12.8)
chef-zero (>= 13.0)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
@@ -77,7 +77,7 @@ PATH
PATH
remote: chef-config
specs:
- chef-config (14.12.6)
+ chef-config (14.12.8)
addressable
fuzzyurl
mixlib-config (>= 2.2.12, < 4.0)
diff --git a/VERSION b/VERSION
index f683b68c32..c58de1883b 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-14.12.6 \ No newline at end of file
+14.12.8 \ 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 4076ab99d2..a7d742a32e 100644
--- a/chef-config/lib/chef-config/version.rb
+++ b/chef-config/lib/chef-config/version.rb
@@ -21,7 +21,7 @@
module ChefConfig
CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__)
- VERSION = "14.12.6".freeze
+ VERSION = "14.12.8".freeze
end
#
diff --git a/lib/chef/application.rb b/lib/chef/application.rb
index a63d8218f4..717d9e588b 100644
--- a/lib/chef/application.rb
+++ b/lib/chef/application.rb
@@ -132,10 +132,10 @@ class Chef
config[:config_file] = config_fetcher.expanded_path
if config[:config_file].nil?
- logger.warn("No config file found or specified on command line, using command line options.")
+ logger.warn("No config file found or specified on command line. Using command line options instead.")
elsif config_fetcher.config_missing?
logger.warn("*****************************************")
- logger.warn("Did not find config file: #{config[:config_file]}, using command line options.")
+ logger.warn("Did not find config file: #{config[:config_file]}. Using command line options instead.")
logger.warn("*****************************************")
else
config_content = config_fetcher.read_config
diff --git a/lib/chef/application/windows_service.rb b/lib/chef/application/windows_service.rb
index 3c73a4925d..de570068e3 100644
--- a/lib/chef/application/windows_service.rb
+++ b/lib/chef/application/windows_service.rb
@@ -313,7 +313,7 @@ class Chef
end
rescue Errno::ENOENT
Chef::Log.warn("*****************************************")
- Chef::Log.warn("Did not find config file: #{config[:config_file]}, using command line options.")
+ Chef::Log.warn("Did not find config file: #{config[:config_file]}. Using command line options instead.")
Chef::Log.warn("*****************************************")
Chef::Config.merge!(config)
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index 87418b5732..2123d71068 100644
--- a/lib/chef/node.rb
+++ b/lib/chef/node.rb
@@ -455,13 +455,10 @@ class Chef
# Transform the node to a Hash
def to_hash
- index_hash = Hash.new
+ index_hash = attributes.to_hash
index_hash["chef_type"] = "node"
index_hash["name"] = name
index_hash["chef_environment"] = chef_environment
- attribute.each do |key, value|
- index_hash[key] = value
- end
index_hash["recipe"] = run_list.recipe_names if run_list.recipe_names.length > 0
index_hash["role"] = run_list.role_names if run_list.role_names.length > 0
index_hash["run_list"] = run_list.run_list_items
@@ -472,10 +469,10 @@ class Chef
display = {}
display["name"] = name
display["chef_environment"] = chef_environment
- display["automatic"] = automatic_attrs
- display["normal"] = normal_attrs
- display["default"] = attributes.combined_default
- display["override"] = attributes.combined_override
+ display["automatic"] = attributes.automatic.to_hash
+ display["normal"] = attributes.normal.to_hash
+ display["default"] = attributes.combined_default.to_hash
+ display["override"] = attributes.combined_override.to_hash
display["run_list"] = run_list.run_list_items
display
end
@@ -490,11 +487,11 @@ class Chef
"name" => name,
"chef_environment" => chef_environment,
"json_class" => self.class.name,
- "automatic" => attributes.automatic,
- "normal" => attributes.normal,
+ "automatic" => attributes.automatic.to_hash,
+ "normal" => attributes.normal.to_hash,
"chef_type" => "node",
- "default" => attributes.combined_default,
- "override" => attributes.combined_override,
+ "default" => attributes.combined_default.to_hash,
+ "override" => attributes.combined_override.to_hash,
# Render correctly for run_list items so malformed json does not result
"run_list" => @primary_runlist.run_list.map { |item| item.to_s },
}
diff --git a/lib/chef/version.rb b/lib/chef/version.rb
index 118ec50e7f..f4b3955730 100644
--- a/lib/chef/version.rb
+++ b/lib/chef/version.rb
@@ -23,7 +23,7 @@ require "chef/version_string"
class Chef
CHEF_ROOT = File.expand_path("../..", __FILE__)
- VERSION = Chef::VersionString.new("14.12.6")
+ VERSION = Chef::VersionString.new("14.12.8")
end
#
diff --git a/lib/chef/whitelist.rb b/lib/chef/whitelist.rb
index 58d0bd70c6..c94ffcaed2 100644
--- a/lib/chef/whitelist.rb
+++ b/lib/chef/whitelist.rb
@@ -45,7 +45,7 @@ class Chef
all_data = data
filtered_data = new_data
parts[0..-2].each do |part|
- unless all_data[part]
+ unless all_data.key?(part)
Chef::Log.warn("Could not find whitelist attribute #{item}.")
return nil
end
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb
index b8d7242466..f5959e7fb4 100644
--- a/spec/unit/application_spec.rb
+++ b/spec/unit/application_spec.rb
@@ -162,7 +162,7 @@ describe Chef::Application do
it "should emit a warning" do
expect(Chef::Config).not_to receive(:from_file).with("/etc/chef/default.rb")
- expect(Chef::Log).to receive(:warn).with("No config file found or specified on command line, using command line options.")
+ expect(Chef::Log).to receive(:warn).with("No config file found or specified on command line. Using command line options instead.")
@app.configure_chef
end
end
diff --git a/spec/unit/log/syslog_spec.rb b/spec/unit/log/syslog_spec.rb
index 4586503e88..a5219fa8fb 100644
--- a/spec/unit/log/syslog_spec.rb
+++ b/spec/unit/log/syslog_spec.rb
@@ -40,8 +40,8 @@ describe "Chef::Log::Syslog", unix_only: true do
end
it "should send message with severity warning to syslog." do
- expect(syslog).to receive(:add).with(2, "No config file found or specified on command line, using command line options.", nil)
- Chef::Log.warn("No config file found or specified on command line, using command line options.")
+ expect(syslog).to receive(:add).with(2, "No config file found or specified on command line. Using command line options instead.", nil)
+ Chef::Log.warn("No config file found or specified on command line. Using command line options instead.")
end
it "should fallback into send message with severity info to syslog when wrong format." do
diff --git a/spec/unit/log/winevt_spec.rb b/spec/unit/log/winevt_spec.rb
index c7cc49f40d..d2e7784701 100644
--- a/spec/unit/log/winevt_spec.rb
+++ b/spec/unit/log/winevt_spec.rb
@@ -43,8 +43,8 @@ describe Chef::Log::WinEvt do
end
it "should send message with severity warning to Windows Event Log." do
- expect(winevt).to receive(:add).with(2, "No config file found or specified on command line, using command line options.", nil)
- Chef::Log.warn("No config file found or specified on command line, using command line options.")
+ expect(winevt).to receive(:add).with(2, "No config file found or specified on command line. Using command line options instead.", nil)
+ Chef::Log.warn("No config file found or specified on command line. Using command line options instead.")
end
it "should fallback into send message with severity info to Windows Event Log when wrong format." do
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 4c056ca349..0901fa2682 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -1469,13 +1469,12 @@ describe Chef::Node do
context "with whitelisted attributes configured" do
it "should only save whitelisted attributes (and subattributes)" do
- Chef::Config[:automatic_attribute_whitelist] = [
+ Chef::Config[:default_attribute_whitelist] = [
["filesystem", "/dev/disk0s2"],
"network/interfaces/eth0",
]
- data = {
- "automatic" => {
+ node.default = {
"filesystem" => {
"/dev/disk0s2" => { "size" => "10mb" },
"map - autohome" => { "size" => "10mb" },
@@ -1486,12 +1485,13 @@ describe Chef::Node do
"eth1" => {},
},
},
- },
- "default" => {}, "normal" => {}, "override" => {}
- }
+ }
+ node.automatic = {}
+ node.normal = {}
+ node.override = {}
selected_data = {
- "automatic" => {
+ "default" => {
"filesystem" => {
"/dev/disk0s2" => { "size" => "10mb" },
},
@@ -1501,12 +1501,11 @@ describe Chef::Node do
},
},
},
- "default" => {}, "normal" => {}, "override" => {}
+ "automatic" => {}, "normal" => {}, "override" => {}
}
node.name("picky-monkey")
- allow(node).to receive(:for_json).and_return(data)
- expect(@rest).to receive(:put).with("nodes/picky-monkey", selected_data).and_return("foo")
+ expect(@rest).to receive(:put).with("nodes/picky-monkey", hash_including(selected_data)).and_return("foo")
node.save
end
@@ -1515,8 +1514,7 @@ describe Chef::Node do
"foo/bar/baz",
]
- data = {
- "default" => {
+ node.default = {
"foo" => {
"bar" => {
"baz" => false,
@@ -1525,8 +1523,11 @@ describe Chef::Node do
"stuff" => true,
},
},
- },
- }
+ }
+
+ node.automatic = {}
+ node.normal = {}
+ node.override = {}
selected_data = {
"default" => {
@@ -1539,44 +1540,41 @@ describe Chef::Node do
}
node.name("falsey-monkey")
- allow(node).to receive(:for_json).and_return(data)
- expect(@rest).to receive(:put).with("nodes/falsey-monkey", selected_data).and_return("foo")
+ expect(@rest).to receive(:put).with("nodes/falsey-monkey", hash_including(selected_data)).and_return("foo")
node.save
end
it "should not save any attributes if the whitelist is empty" do
- Chef::Config[:automatic_attribute_whitelist] = []
+ Chef::Config[:default_attribute_whitelist] = []
- data = {
- "automatic" => {
+ node.default = {
"filesystem" => {
"/dev/disk0s2" => { "size" => "10mb" },
"map - autohome" => { "size" => "10mb" },
},
- },
- "default" => {}, "normal" => {}, "override" => {}
- }
+ }
+ node.automatic = {}
+ node.normal = {}
+ node.override = {}
selected_data = {
"automatic" => {}, "default" => {}, "normal" => {}, "override" => {}
}
node.name("picky-monkey")
- allow(node).to receive(:for_json).and_return(data)
- expect(@rest).to receive(:put).with("nodes/picky-monkey", selected_data).and_return("foo")
+ expect(@rest).to receive(:put).with("nodes/picky-monkey", hash_including(selected_data)).and_return("foo")
node.save
end
end
context "with blacklisted attributes configured" do
it "should only save non-blacklisted attributes (and subattributes)" do
- Chef::Config[:automatic_attribute_blacklist] = [
+ Chef::Config[:default_attribute_blacklist] = [
["filesystem", "/dev/disk0s2"],
"network/interfaces/eth0",
]
- data = {
- "automatic" => {
+ node.default = {
"filesystem" => {
"/dev/disk0s2" => { "size" => "10mb" },
"map - autohome" => { "size" => "10mb" },
@@ -1587,12 +1585,13 @@ describe Chef::Node do
"eth1" => {},
},
},
- },
- "default" => {}, "normal" => {}, "override" => {}
- }
+ }
+ node.automatic = {}
+ node.normal = {}
+ node.override = {}
selected_data = {
- "automatic" => {
+ "default" => {
"filesystem" => {
"map - autohome" => { "size" => "10mb" },
},
@@ -1602,40 +1601,38 @@ describe Chef::Node do
},
},
},
- "default" => {}, "normal" => {}, "override" => {}
+ "automatic" => {}, "normal" => {}, "override" => {}
}
node.name("picky-monkey")
- allow(node).to receive(:for_json).and_return(data)
- expect(@rest).to receive(:put).with("nodes/picky-monkey", selected_data).and_return("foo")
+ expect(@rest).to receive(:put).with("nodes/picky-monkey", hash_including(selected_data)).and_return("foo")
node.save
end
- it "should save all attributes if the blacklist is empty" do
- Chef::Config[:automatic_attribute_blacklist] = []
+ it "should save all attributes if the blacklist is empty" do
+ Chef::Config[:default_attribute_blacklist] = []
- data = {
- "automatic" => {
+ node.default = {
"filesystem" => {
"/dev/disk0s2" => { "size" => "10mb" },
"map - autohome" => { "size" => "10mb" },
},
- },
- "default" => {}, "normal" => {}, "override" => {}
- }
+ }
+ node.automatic = {}
+ node.normal = {}
+ node.override = {}
selected_data = {
- "automatic" => {
+ "default" => {
"filesystem" => {
"/dev/disk0s2" => { "size" => "10mb" },
"map - autohome" => { "size" => "10mb" },
},
},
- "default" => {}, "normal" => {}, "override" => {}
+ "automatic" => {}, "normal" => {}, "override" => {}
}
node.name("picky-monkey")
- allow(node).to receive(:for_json).and_return(data)
- expect(@rest).to receive(:put).with("nodes/picky-monkey", selected_data).and_return("foo")
+ expect(@rest).to receive(:put).with("nodes/picky-monkey", hash_including(selected_data)).and_return("foo")
node.save
end
end