Class: Berkshelf::API::CacheBuilder::Worker::Opscode

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

Instance Attribute Summary

Attributes inherited from Base

#options, #priority

Instance Method Summary collapse

Methods inherited from Base

#to_s, worker_type

Methods included from Mixin::Services

extended, included

Methods included from Logging

init, #logger

Constructor Details

#initialize(options = {}) ⇒ Opscode

Returns a new instance of Opscode.

Parameters:

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

    see API::SiteConnector::Opscode.new for options



11
12
13
14
# File 'lib/berkshelf/api/cache_builder/worker/opscode.rb', line 11

def initialize(options = {})
  @connection = Berkshelf::API::SiteConnector::Opscode.pool_link(size: 25, args: [ options ])
  super
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



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/berkshelf/api/cache_builder/worker/opscode.rb', line 18

def cookbooks
  [].tap do |cookbook_versions|
    connection.cookbooks.collect do |cookbook|
      [ cookbook, connection.future(:versions, cookbook) ]
    end.each do |cookbook, versions|
      versions.value.each do |version|
        cookbook_versions << RemoteCookbook.new(cookbook, version, self.class.worker_type, @connection.api_uri, priority)
      end
    end
  end
end

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

Return the metadata of the given RemoteCookbook. If the metadata could not be found or parsed nil is returned.

Parameters:

Returns:

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


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

def (remote)
  Dir.mktmpdir('metadata') do |destination|
    if connection.download(remote.name, remote.version, destination)
      (destination, remote.name)
    end
  end
end