Sha256: 962b749a3d7be05db3d85f821c231e98e3075b7fccf7aac85df342f76c4fedac
Contents?: true
Size: 1.84 KB
Versions: 78
Compression:
Stored size: 1.84 KB
Contents
require 'chef/chef_fs/data_handler/data_handler_base' require 'chef/data_bag_item' class Chef module ChefFS module DataHandler class DataBagItemDataHandler < DataHandlerBase 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'] data_bag_item = data_bag_item['raw_data'] end # chef_type and data_bag come back in PUT and POST results, but we don't # use those in knife-essentials. normalize_hash(data_bag_item, { 'id' => remove_dot_json(entry.name) }) end def normalize_for_post(data_bag_item, entry) if data_bag_item['json_class'] == 'Chef::DataBagItem' && data_bag_item['raw_data'] data_bag_item = data_bag_item['raw_data'] end { "name" => "data_bag_item_#{entry.parent.name}_#{remove_dot_json(entry.name)}", "json_class" => "Chef::DataBagItem", "chef_type" => "data_bag_item", "data_bag" => entry.parent.name, "raw_data" => normalize(data_bag_item, entry) } end def normalize_for_put(data_bag_item, entry) normalize_for_post(data_bag_item, entry) end def preserve_key(key) return key == 'id' end def chef_class Chef::DataBagItem end def verify_integrity(object, entry, &on_error) base_name = remove_dot_json(entry.name) if object['raw_data']['id'] != base_name on_error.call("ID in #{entry.path_for_printing} must be '#{base_name}' (is '#{object['raw_data']['id']}')") end end # Data bags do not support .rb files (or if they do, it's undocumented) end end end end
Version data entries
78 entries across 78 versions & 1 rubygems