Class: CookbookOmnifetch::ChefServerArtifactLocation
Overview
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.
Instance Attribute Summary collapse
Attributes inherited from BaseLocation
#dependency, #options
Instance Method Summary
collapse
#to_lock, #validate_cached!
Constructor Details
Returns a new instance of ChefServerArtifactLocation.
17
18
19
20
21
22
|
# 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
|
Instance Attribute Details
#cookbook_identifier ⇒ Object
Returns the value of attribute cookbook_identifier.
14
15
16
|
# File 'lib/cookbook-omnifetch/chef_server_artifact.rb', line 14
def cookbook_identifier
@cookbook_identifier
end
|
#uri ⇒ Object
Returns the value of attribute uri.
15
16
17
|
# File 'lib/cookbook-omnifetch/chef_server_artifact.rb', line 15
def uri
@uri
end
|
Instance Method Details
#cache_key ⇒ Object
67
68
69
|
# File 'lib/cookbook-omnifetch/chef_server_artifact.rb', line 67
def cache_key
"#{dependency.name}-#{cookbook_identifier}"
end
|
#cached_cookbook ⇒ Object
#cookbook_name ⇒ Object
28
29
30
|
# File 'lib/cookbook-omnifetch/chef_server_artifact.rb', line 28
def cookbook_name
dependency.name
end
|
#http_client ⇒ Object
51
52
53
|
# File 'lib/cookbook-omnifetch/chef_server_artifact.rb', line 51
def http_client
@http_client
end
|
#install ⇒ Object
40
41
42
|
# File 'lib/cookbook-omnifetch/chef_server_artifact.rb', line 40
def install
installer.install
end
|
#install_path ⇒ Pathname?
The path where this cookbook would live in the store, if it were installed.
59
60
61
|
# File 'lib/cookbook-omnifetch/chef_server_artifact.rb', line 59
def install_path
@install_path ||= CookbookOmnifetch.storage_path.join(cache_key)
end
|
#installed? ⇒ Boolean
Determine if this revision is installed.
47
48
49
|
# File 'lib/cookbook-omnifetch/chef_server_artifact.rb', line 47
def installed?
install_path.exist?
end
|
#installer ⇒ Object
36
37
38
|
# 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 ⇒ Object
63
64
65
|
# File 'lib/cookbook-omnifetch/chef_server_artifact.rb', line 63
def lock_data
{ "chef_server_artifact" => uri, "identifier" => cookbook_identifier }
end
|
#repo_host ⇒ Object
24
25
26
|
# File 'lib/cookbook-omnifetch/chef_server_artifact.rb', line 24
def repo_host
@host ||= URI.parse(uri).host
end
|
#url_path ⇒ Object
32
33
34
|
# File 'lib/cookbook-omnifetch/chef_server_artifact.rb', line 32
def url_path
"/cookbook_artifacts/#{cookbook_name}/#{cookbook_identifier}"
end
|