Sha256: eeeb91b9da6f90bf57a087704d6912b6f877caf5ab5079439c776ab925f19db4

Contents?: true

Size: 759 Bytes

Versions: 8

Compression:

Stored size: 759 Bytes

Contents

require "berkshelf/ridley_compat"

module Berkshelf
  module APIClient
    require_relative "errors"

    class ChefServerConnection
      attr_reader :client

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

      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
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
berkshelf-7.0.8 lib/berkshelf/api_client/chef_server_connection.rb
berkshelf-7.0.7 lib/berkshelf/api_client/chef_server_connection.rb
berkshelf-7.0.6 lib/berkshelf/api_client/chef_server_connection.rb
berkshelf-7.0.5 lib/berkshelf/api_client/chef_server_connection.rb
berkshelf-7.0.4 lib/berkshelf/api_client/chef_server_connection.rb
berkshelf-7.0.3 lib/berkshelf/api_client/chef_server_connection.rb
berkshelf-7.0.2 lib/berkshelf/api_client/chef_server_connection.rb
berkshelf-7.0.1 lib/berkshelf/api_client/chef_server_connection.rb