Sha256: 493b380f4a839c47677e0b55feeec6530f4f4be667b7bb0ba9f3242583704d4a

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

require 'chef/chef_fs/data_handler/data_handler_base'
require 'chef/api_client'

class Chef
  module ChefFS
    module DataHandler
      class ClientDataHandler < DataHandlerBase
        def normalize(client, entry)
          defaults = {
            'name' => remove_dot_json(entry.name),
            'clientname' => remove_dot_json(entry.name),
            'admin' => false,
            'validator' => false,
            'chef_type' => 'client'
          }
          # Handle the fact that admin/validator have changed type from string -> boolean
          client['admin'] = (client['admin'] == 'true') if client['admin'].is_a?(String)
          client['validator'] = (client['validator'] == 'true') if client['validator'].is_a?(String)
          if entry.respond_to?(:org) && entry.org
            defaults['orgname'] = entry.org
          end
          result = normalize_hash(client, defaults)
          result.delete('json_class')
          result
        end

        def preserve_key?(key)
          return key == 'name'
        end

        def chef_class
          Chef::ApiClient
        end

        # There is no Ruby API for Chef::ApiClient
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chef-12.6.0 lib/chef/chef_fs/data_handler/client_data_handler.rb
chef-12.6.0-universal-mingw32 lib/chef/chef_fs/data_handler/client_data_handler.rb
chef-12.5.1-universal-mingw32 lib/chef/chef_fs/data_handler/client_data_handler.rb
chef-12.5.1 lib/chef/chef_fs/data_handler/client_data_handler.rb