class CookbookOmnifetch::ChefServerArtifactLocation

This location allows fetching from the ‘cookbook_artifacts/` API where Chef Server stores cookbooks for policyfile use when they’re uploaded via ‘chef push`.

End users likely won’t have much use for this; it’s intended to facilitate included policies when including a policy stored on a chef server and cookbooks cannot be installed from the original source based on the information in the included policy.

Attributes

cookbook_identifier[R]
uri[R]

Public Class Methods

new(dependency, options = {}) click to toggle source
Calls superclass method CookbookOmnifetch::BaseLocation::new
# File lib/cookbook-omnifetch/chef_server_artifact.rb, line 17
def initialize(dependency, options = {})
  super
  @cookbook_identifier = options[:identifier]
  @http_client = options[:http_client] || default_chef_server_http_client
  @uri ||= options[:chef_server_artifact]
end

Public Instance Methods

cache_key() click to toggle source
# File lib/cookbook-omnifetch/chef_server_artifact.rb, line 67
def cache_key
  "#{dependency.name}-#{cookbook_identifier}"
end
cached_cookbook() click to toggle source

@see BaseLocation#cached_cookbook

# File lib/cookbook-omnifetch/chef_server_artifact.rb, line 72
def cached_cookbook
  @cached_cookbook ||= CookbookOmnifetch.cached_cookbook_class.from_path(install_path)
end
cookbook_name() click to toggle source
# File lib/cookbook-omnifetch/chef_server_artifact.rb, line 28
def cookbook_name
  dependency.name
end
http_client() click to toggle source
# File lib/cookbook-omnifetch/chef_server_artifact.rb, line 51
def http_client
  @http_client
end
install() click to toggle source
# File lib/cookbook-omnifetch/chef_server_artifact.rb, line 40
def install
  installer.install
end
install_path() click to toggle source

The path where this cookbook would live in the store, if it were installed.

@return [Pathname, nil]

# File lib/cookbook-omnifetch/chef_server_artifact.rb, line 59
def install_path
  @install_path ||= CookbookOmnifetch.storage_path.join(cache_key)
end
installed?() click to toggle source

Determine if this revision is installed.

@return [Boolean]

# File lib/cookbook-omnifetch/chef_server_artifact.rb, line 47
def installed?
  install_path.exist?
end
installer() click to toggle source
# File lib/cookbook-omnifetch/chef_server_artifact.rb, line 36
def installer
  MetadataBasedInstaller.new(http_client: http_client, url_path: url_path, install_path: install_path)
end
lock_data() click to toggle source
# File lib/cookbook-omnifetch/chef_server_artifact.rb, line 63
def lock_data
  { "chef_server_artifact" => uri, "identifier" => cookbook_identifier }
end
repo_host() click to toggle source
# File lib/cookbook-omnifetch/chef_server_artifact.rb, line 24
def repo_host
  @host ||= URI.parse(uri).host
end
url_path() click to toggle source
# File lib/cookbook-omnifetch/chef_server_artifact.rb, line 32
def url_path
  "/cookbook_artifacts/#{cookbook_name}/#{cookbook_identifier}"
end

Private Instance Methods

default_chef_server_http_client() click to toggle source
# File lib/cookbook-omnifetch/chef_server_artifact.rb, line 78
def default_chef_server_http_client
  CookbookOmnifetch.default_chef_server_http_client
end