Class: Berkshelf::API::CacheBuilder::Worker::FileStore

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

Instance Attribute Summary collapse

Attributes inherited from Base

#options, #priority

Instance Method Summary collapse

Methods included from Logging

init, #logger

Methods inherited from Base

worker_type

Methods included from Mixin::Services

extended, included

Constructor Details

#initialize(options = {}) ⇒ FileStore

Returns a new instance of FileStore.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :path (String)

    the directory to search for local cookbooks



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/berkshelf/api/cache_builder/worker/file_store.rb', line 14

def initialize(options = {})
  @path = Pathname(options[:path])
  log.warn "You have configured a FileStore endpoint to index the contents of #{@path}."
  log.warn "Using unfinalized artifacts, which this path may contain, to satisfiy your"
  log.warn "dependencies is *STRONGLY FROWNED UPON* and potentially *DANGEROUS*."
  log.warn ""
  log.warn "Please consider setting up a release process for the cookbooks you wish to retrieve from this"
  log.warn "filepath where the cookbook is uploaded into a Hosted Chef organization, an internal"
  log.warn "Chef Server, or the community site, and then replace this endpoint with a chef_server endpoint."
  super(options)
end

Instance Attribute Details

#pathString (readonly)

Returns:

  • (String)


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

def path
  @path
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



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/berkshelf/api/cache_builder/worker/file_store.rb', line 33

def cookbooks
  [].tap do |cookbook_versions|
    @path.each_child do |dir|
      next unless dir.cookbook?
      begin
        cookbook = Ridley::Chef::Cookbook.from_path(dir)
        cookbook_versions << RemoteCookbook.new(cookbook.cookbook_name, cookbook.version,
          self.class.worker_type, cookbook.path, priority)
      rescue => ex
        log.debug ex.message
      end
    end
  end
end

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

Parameters:

Returns:

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


51
52
53
# File 'lib/berkshelf/api/cache_builder/worker/file_store.rb', line 51

def (remote)
  (remote.location_path)
end

#to_sString

Returns:

  • (String)


27
28
29
# File 'lib/berkshelf/api/cache_builder/worker/file_store.rb', line 27

def to_s
  friendly_name(path)
end