Class: Chef::ChefFS::DataHandler::ClientDataHandler

Inherits:
DataHandlerBase show all
Defined in:
lib/chef/chef_fs/data_handler/client_data_handler.rb

Instance Method Summary collapse

Methods inherited from DataHandlerBase

#chef_object, #default, #from_ruby, #minimize, #normalize_for_post, #normalize_for_put, #normalize_hash, #normalize_run_list, #remove_dot_json, #to_ruby, #to_ruby_keys, #verify_integrity

Instance Method Details

#chef_classObject



30
31
32
# File 'lib/chef/chef_fs/data_handler/client_data_handler.rb', line 30

def chef_class
  Chef::ApiClient
end

#normalize(client, entry) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/chef/chef_fs/data_handler/client_data_handler.rb', line 8

def normalize(client, entry)
  defaults = {
    'name' => remove_dot_json(entry.name),
    'clientname' => remove_dot_json(entry.name),
    'orgname' => entry.org,
    'admin' => false,
    'validator' => false,
    'chef_type' => 'client'
  }
  if entry.org
    defaults['orgname'] = entry.org
  end
  result = normalize_hash(client, defaults)
  # You can NOT send json_class, or it will fail
  result.delete('json_class')
  result
end

#preserve_key(key) ⇒ Object



26
27
28
# File 'lib/chef/chef_fs/data_handler/client_data_handler.rb', line 26

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