Method: Chef::Provisioning::ChefManagedEntryStore#get_data

Defined in:
lib/chef/provisioning/chef_managed_entry_store.rb

#get_data(resource_type, name) ⇒ Hash, Array

Get the given data

Parameters:

  • resource_type (Symbol)

    The type of thing to retrieve (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, …)

  • name (String)

    The unique identifier of the thing to retrieve

Returns:

  • (Hash, Array)

    The data, or nil if the data does not exist. Will be JSON- and YAML-compatible (Hash, Array, String, Integer, Boolean, Nil)



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/chef/provisioning/chef_managed_entry_store.rb', line 25

def get_data(resource_type, name)
  begin
    if resource_type == :machine
      chef_api.get("nodes/#{name}")
    else
      chef_api.get("data/#{resource_type}/#{name}")
    end
  rescue Net::HTTPServerException => e
    if e.response.code == '404'
      backcompat_type = ChefManagedEntryStore.type_names_for_backcompat[resource_type]
      if backcompat_type && backcompat_type != resource_type
        get_data(backcompat_type, name)
      else
        nil
      end
    else
      raise
    end
  end
end