class Batali::Source::ChefServer
Chef
Server based source
Attributes
cache[RW]
@return [String] local cache path
dependencies[R]
@return [Array<Hash>] dependency strings
identifier[R]
@return [string] unique identifier
Public Class Methods
new(args = {})
click to toggle source
Extract extra info before allowing super to load data
@param args [Hash] @return [self]
Calls superclass method
Batali::Source::new
# File lib/batali/source/chef_server.rb, line 24 def initialize(args = {}) @deps = args.delete(:dependencies) || {} super init_chef! end
Public Instance Methods
api_service()
click to toggle source
@return [Chef::Rest]
# File lib/batali/source/chef_server.rb, line 31 def api_service memoize(:api_service) do Chef::Rest.new(endpoint) end end
asset()
click to toggle source
@return [String] directory
# File lib/batali/source/chef_server.rb, line 56 def asset path = Utility.join_path(cache_directory, name, version) begin FileUtils.mkdir_p(path) cookbook = rest.get_rest("cookbooks/#{name}/#{version}") manifest = cookbook.manifest Chef::CookbookVersion::COOKBOOK_SEGMENTS.each do |segement| if manifest.key?(segment) manifest[segement].each do |s_file| new_path = Utility.join_path(path, s_file["path"].gsub("/", File::SEPARATOR)) FileUtils.mkdir_p(File.dirname(new_path)) api_service.sign_on_redirect = false t_file = api_service.get_rest(s_file["url"], true) FilUtils.mv(t_file.path, new_path) end end end rescue => e debug "Failed to fully download cookbook [#{name}<#{version}>] - #{e.class}: #{e}" FileUtils.rm_rf(path) raise end path end
cache_directory()
click to toggle source
@return [String] path to cache
# File lib/batali/source/chef_server.rb, line 48 def cache_directory memoize(:cache_directory) do @cache ||= Utility.join_path(cache_path, "chef_server", endpoint) cache end end
unit_dependencies()
click to toggle source
@return [Array<Array<name, constraints>>]
# File lib/batali/source/chef_server.rb, line 43 def unit_dependencies deps.to_a end
unit_version()
click to toggle source
@return [String]
# File lib/batali/source/chef_server.rb, line 38 def unit_version version end