Class: Berkshelf::APIClient::ChefServerConnection

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

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ ChefServerConnection

Returns a new instance of ChefServerConnection.



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

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

Instance Method Details

#universeObject



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

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