/usr/lib/ruby/vendor_ruby/berkshelf/api/cache_builder/worker/chef_server.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 | module Berkshelf::API
class CacheBuilder
module Worker
class ChefServer < Worker::Base
worker_type "chef_server"
finalizer :finalize_callback
# @return [String]
attr_reader :url
# @option options [String] :url
# the URL of the target Chef Server
# @option options [String] :client_name
# the name of the client for authenticating to the Chef Server
# @option options [String] :client_key
# a client key for authenticating to the Chef Server
# @option options [Boolean] :ssl_verify
# turn ssl verification off if you have an unsigned SSL certificate
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
# @return [String]
def to_s
friendly_name(url)
end
# @return [Array<RemoteCookbook>]
# The list of cookbooks this builder can find
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
# @param [RemoteCookbook] remote
#
# @return [Ridley::Chef::Cookbook::Metadata]
def metadata(remote)
metadata_hash = connection.cookbook.find(remote.name, remote.version).metadata
Ridley::Chef::Cookbook::Metadata.from_hash(metadata_hash)
end
private
attr_reader :connection
def finalize_callback
connection.terminate if connection && connection.alive?
end
end
end
end
end
|