Sha256: 892909aaaafbe66f9c43db7e60ceff79c687b42bcfd53e4306b58ae84235b944

Contents?: true

Size: 972 Bytes

Versions: 11

Compression:

Stored size: 972 Bytes

Contents

require 'chef_fs/data_handler/data_handler_base'
require 'chef/data_bag_item'

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 only come back from PUT and POST, but we'll
        # normalize them in in case someone is comparing with those results.
        super(data_bag_item, {
          'chef_type' => 'data_bag_item',
          'data_bag' => entry.parent.name,
          'id' => remove_dot_json(entry.name)
        })
      end

      def preserve_key(key)
        return key == 'id'
      end

      def chef_class
        Chef::DataBagItem
      end

      # Data bags do not support .rb files (or if they do, it's undocumented)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
knife-essentials-1.0.0.beta2 lib/chef_fs/data_handler/data_bag_item_data_handler.rb
knife-essentials-1.0.0.beta1 lib/chef_fs/data_handler/data_bag_item_data_handler.rb
knife-essentials-0.9.8 lib/chef_fs/data_handler/data_bag_item_data_handler.rb
knife-essentials-0.9.7 lib/chef_fs/data_handler/data_bag_item_data_handler.rb
knife-essentials-0.9.6 lib/chef_fs/data_handler/data_bag_item_data_handler.rb
knife-essentials-0.9.5 lib/chef_fs/data_handler/data_bag_item_data_handler.rb
knife-essentials-0.9.4 lib/chef_fs/data_handler/data_bag_item_data_handler.rb
knife-essentials-0.9.3 lib/chef_fs/data_handler/data_bag_item_data_handler.rb
knife-essentials-0.9.2 lib/chef_fs/data_handler/data_bag_item_data_handler.rb
knife-essentials-0.9.1 lib/chef_fs/data_handler/data_bag_item_data_handler.rb
knife-essentials-0.9.0 lib/chef_fs/data_handler/data_bag_item_data_handler.rb