diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-09-09 10:24:42 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-09-21 10:37:59 -0700 |
commit | 723bac74427f6f605fd2c9ab855afe59ba84d08b (patch) | |
tree | 957ccc2475a557a8d96cff5b69c1dc8ebcfebcc3 /spec | |
parent | ed0729ba1ef9a7494dbe374c9ee2ec0c776a76f6 (diff) | |
download | chef-723bac74427f6f605fd2c9ab855afe59ba84d08b.tar.gz |
ignore unknown metadata fields in metadata.rb
if we're just using chef-zero there's no metadata.json file so
chef-client doesn't do json parsing (which ignores unknown metadata
fields already) but parses metadata.json which explodes.
i believe since TK goes through berks it renders the rb to json before
copying to the virt so we don't see this in TK or in running chef-client
from a real server.
this only affects the chef-client -z or chef-zolo mode of operation (and
probably legacy chef-solo)
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/cookbook/metadata_spec.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb index 27666eb338..a6c85bd397 100644 --- a/spec/unit/cookbook/metadata_spec.rb +++ b/spec/unit/cookbook/metadata_spec.rb @@ -948,5 +948,24 @@ describe Chef::Cookbook::Metadata do end end + describe "from_file" do + it "ignores unknown metadata fields in metadata.rb files" do + expect(Chef::Log).to receive(:warn).with(/ignoring method some_spiffy_new_metadata_field/) + Tempfile.open("metadata.rb") do |f| + f.write <<-EOF + some_spiffy_new_metadata_field "stuff its set to" + EOF + f.close + metadata.from_file(f.path) + end + end + end + + describe "from_json" do + it "ignores unknown metadata fields in metdata.json files" do + json = %q{{ "some_spiffy_new_metadata_field": "stuff its set to" }} + metadata.from_json(json) + end + end end end |