diff options
author | Dmitry Shestoperov <dshestoperov@sitespect.com> | 2018-02-13 08:39:27 -0500 |
---|---|---|
committer | Dmitry Shestoperov <dshestoperov@sitespect.com> | 2018-02-13 08:39:27 -0500 |
commit | 29748ede0cd6fa3799a2f8c4912f037a31f1eeea (patch) | |
tree | 8ba342e1f6d6dfd00a800ed4e55af23fdac80f2b /lib/chef/chef_fs | |
parent | 68e9f4618bc6432023f8327cfce775618806fa9e (diff) | |
parent | 493947028e8560e86a014aced4273f509a678c31 (diff) | |
download | chef-29748ede0cd6fa3799a2f8c4912f037a31f1eeea.tar.gz |
Merge upstream
Diffstat (limited to 'lib/chef/chef_fs')
-rw-r--r-- | lib/chef/chef_fs/config.rb | 2 | ||||
-rw-r--r-- | lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/chef/chef_fs/config.rb b/lib/chef/chef_fs/config.rb index 63a1363724..0725426275 100644 --- a/lib/chef/chef_fs/config.rb +++ b/lib/chef/chef_fs/config.rb @@ -66,7 +66,7 @@ class Chef # upgrade/migration of older Chef Servers, so they should be considered # frozen in time. - CHEF_11_OSS_STATIC_OBJECTS = %w{cookbooks cookbook_artifacts data_bags environments roles}.freeze + CHEF_11_OSS_STATIC_OBJECTS = %w{cookbooks data_bags environments roles}.freeze CHEF_11_OSS_DYNAMIC_OBJECTS = %w{clients nodes users}.freeze RBAC_OBJECT_NAMES = %w{acls containers groups }.freeze CHEF_12_OBJECTS = %w{ cookbook_artifacts policies policy_groups client_keys }.freeze diff --git a/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb b/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb index e799e72e36..4b272daabc 100644 --- a/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb @@ -5,6 +5,8 @@ class Chef module ChefFS module DataHandler class DataBagItemDataHandler < DataHandlerBase + RESERVED_NAMES = /node|role|environment|client/ + def normalize(data_bag_item, entry) # If it's wrapped with raw_data, unwrap it. if data_bag_item["json_class"] == "Chef::DataBagItem" && data_bag_item["raw_data"] @@ -43,6 +45,7 @@ class Chef end # Verify that the JSON hash for this type has a key that matches its name. + # Also check that the data bag name is not a reserved search index name. # # @param object [Object] JSON hash of the object # @param entry [Chef::ChefFS::FileSystem::BaseFSObject] filesystem object we are verifying @@ -52,6 +55,8 @@ class Chef base_name = remove_dot_json(entry.name) if object["raw_data"]["id"] != base_name yield("ID in #{entry.path_for_printing} must be '#{base_name}' (is '#{object['raw_data']['id']}')") + elsif entry.parent.name =~ RESERVED_NAMES + yield("Data bag name ('#{entry.parent.name}') must not match #{RESERVED_NAMES.inspect}") end end |