Class: Berkshelf::API::CacheBuilder::Worker::ChefServer

Inherits:
Base
  • Object
show all
Defined in:
lib/berkshelf/api/cache_builder/worker/chef_server.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#options, #priority

Instance Method Summary collapse

Methods inherited from Base

worker_type

Methods included from Mixin::Services

extended, included

Methods included from Logging

init, #logger

Constructor Details

#initialize(options = {}) ⇒ ChefServer

Returns a new instance of ChefServer.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :url (String)

    the URL of the target Chef Server

  • :client_name (String)

    the name of the client for authenticating to the Chef Server

  • :client_key (String)

    a client key for authenticating to the Chef Server

  • :ssl_verify (Boolean)

    turn ssl verification off if you have an unsigned SSL certificate



20
21
22
23
24
25
# File 'lib/berkshelf/api/cache_builder/worker/chef_server.rb', line 20

def initialize(options = {})
  @url = options[:url]
  @connection = Ridley::Client.new_link(server_url: url, client_key: options[:client_key],
    client_name: options[:client_name], ssl: { verify: options[:ssl_verify] })
  super
end

Instance Attribute Details

#urlString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/berkshelf/api/cache_builder/worker/chef_server.rb', line 10

def url
  @url
end

Instance Method Details

#cookbooksArray<RemoteCookbook>

Returns The list of cookbooks this builder can find.

Returns:

  • (Array<RemoteCookbook>)

    The list of cookbooks this builder can find



34
35
36
37
38
39
40
41
42
43
# File 'lib/berkshelf/api/cache_builder/worker/chef_server.rb', line 34

def cookbooks
  [].tap do |cookbook_versions|
    connection.cookbook.all.each do |cookbook, versions|
      versions.each do |version|
        cookbook_versions << RemoteCookbook.new(cookbook, version, self.class.worker_type,
          @connection.server_url, priority)
      end
    end
  end
end

#metadata(remote) ⇒ Ridley::Chef::Cookbook::Metadata

Parameters:

Returns:

  • (Ridley::Chef::Cookbook::Metadata)


48
49
50
51
# File 'lib/berkshelf/api/cache_builder/worker/chef_server.rb', line 48

def (remote)
   = connection.cookbook.find(remote.name, remote.version).
  Ridley::Chef::Cookbook::Metadata.from_hash()
end

#to_sString

Returns:

  • (String)


28
29
30
# File 'lib/berkshelf/api/cache_builder/worker/chef_server.rb', line 28

def to_s
  friendly_name(url)
end