Class: Berkshelf::APIClient::ChefServerConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/berkshelf/api_client/chef_server_connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ChefServerConnection

Returns a new instance of ChefServerConnection.



10
11
12
13
# File 'lib/berkshelf/api_client/chef_server_connection.rb', line 10

def initialize(*args)
  @client = Berkshelf::RidleyCompat.new(*args)
  @url = args[0][:server_url]
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/berkshelf/api_client/chef_server_connection.rb', line 8

def client
  @client
end

Instance Method Details

#universeObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/berkshelf/api_client/chef_server_connection.rb', line 15

def universe
  response = client.get("universe")

  [].tap do |cookbooks|
    response.each do |name, versions|
      versions.each do |version, attributes|
        attributes[:location_path] = @url
        cookbooks << RemoteCookbook.new(name, version, attributes) end
    end
  end
rescue Ridley::Errors::HTTPNotFound
  raise ServiceNotFound, "service not found at: #{@url}"
end