/usr/lib/ruby/vendor_ruby/berkshelf/api/cache_builder/worker/file_store.rb is in berkshelf-api 2.2.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | module Berkshelf::API
class CacheBuilder
module Worker
class FileStore < Worker::Base
worker_type "file_store"
include Logging
# @return [String]
attr_reader :path
# @option options [String] :path
# the directory to search for local cookbooks
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
# @return [String]
def to_s
friendly_name(path)
end
# @return [Array<RemoteCookbook>]
# The list of cookbooks this builder can find
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
# @param [RemoteCookbook] remote
#
# @return [Ridley::Chef::Cookbook::Metadata]
def metadata(remote)
load_metadata(remote.location_path)
end
private
# Helper function for loading metadata from a particular directory
#
# @param [String] path
# path of directory to load from
#
# @return [Ridley::Chef::Cookbook::Metadata, nil]
def load_metadata(path)
cookbook = Ridley::Chef::Cookbook.from_path(path)
cookbook.metadata
rescue => ex
nil
end
end
end
end
end
|