class ChefDK::Policyfile::CookbookLocationSpecification
Constants
- SOURCE_TYPES
Attributes
name[R]
source_options[R]
source_type[R]
storage_config[R]
version_constraint[R]
Public Class Methods
new(name, version_constraint, source_options, storage_config)
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 48 def initialize(name, version_constraint, source_options, storage_config) @name = name @version_constraint = Semverse::Constraint.new(version_constraint) @source_options = source_options @source_type = SOURCE_TYPES.find { |type| source_options.key?(type) } @storage_config = storage_config end
Public Instance Methods
==(other)
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 56 def ==(other) other.is_a?(self.class) && other.name == name && other.version_constraint == version_constraint && other.source_options == source_options end
cache_key()
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 102 def cache_key installer.cache_key end
cached_cookbook()
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 131 def cached_cookbook # TODO: handle 'bad' return values here (cookbook not installed yet) installer.cached_cookbook end
cookbook_has_recipe?(recipe_name)
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 126 def cookbook_has_recipe?(recipe_name) expected_path = cookbook_path.join("recipes/#{recipe_name}.rb") expected_path.exist? end
cookbook_path()
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 144 def cookbook_path if installer.respond_to?(:expanded_path) installer.expanded_path else installer.install_path.expand_path end end
dependencies()
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 122 def dependencies cached_cookbook.dependencies end
ensure_cached()
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 79 def ensure_cached unless installer.installed? installer.install end end
errors()
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 89 def errors error_messages = [] if source_options_invalid? error_messages << "Cookbook `#{name}' has invalid source options `#{source_options.inspect}'" end error_messages end
installed?()
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 75 def installed? installer.installed? end
installer()
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 97 def installer # TODO: handle 'bad' return values here (invalid source_options, etc.) @installer ||= CookbookOmnifetch.init(self, source_options) end
mirrors_canonical_upstream?()
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 71 def mirrors_canonical_upstream? %i{git github artifactserver chef_server chef_server_artifact artifactory}.include?(source_type) end
relative_path()
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 106 def relative_path installer.relative_path.to_s end
source_options_for_lock()
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 136 def source_options_for_lock installer.lock_data end
source_options_invalid?()
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 140 def source_options_invalid? !source_options.empty? && installer.nil? end
to_s()
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 63 def to_s # Note, this may appear in exceptions s = "Cookbook '#{name}'" s << " #{version_constraint}" s << " #{source_options}" unless source_options.empty? s end
uri()
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 110 def uri installer.uri end
valid?()
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 85 def valid? errors.empty? end
version()
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 118 def version cached_cookbook.version end
version_fixed?()
click to toggle source
# File lib/chef-dk/policyfile/cookbook_location_specification.rb, line 114 def version_fixed? %i{git github path chef_server_artifact}.include?(@source_type) end