Method: Chef::ChefFS::DataHandler::ClientDataHandler#normalize

Defined in:
lib/chef/chef_fs/data_handler/client_data_handler.rb

#normalize(client, entry) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 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),
    "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