Class: ChefDK::Policyfile::CookbookLocationSpecification
- Inherits:
-
Object
- Object
- ChefDK::Policyfile::CookbookLocationSpecification
show all
- Includes:
- StorageConfigDelegation
- Defined in:
- lib/chef-dk/policyfile/cookbook_location_specification.rb
Constant Summary
collapse
- SOURCE_TYPES =
[:git, :github, :path, :artifactserver]
Instance Attribute Summary collapse
Instance Method Summary
collapse
#cache_path, #policyfile_filename, #relative_paths_root
Constructor Details
#initialize(name, version_constraint, source_options, storage_config) ⇒ CookbookLocationSpecification
Returns a new instance of CookbookLocationSpecification.
48
49
50
51
52
53
54
|
# 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
|
Instance Attribute Details
#name ⇒ Object
– Required by CookbookOmnifetch API contract
40
41
42
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 40
def name
@name
end
|
#source_options ⇒ Object
– Required by CookbookOmnifetch API contract
44
45
46
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 44
def source_options
@source_options
end
|
#source_type ⇒ Object
Returns the value of attribute source_type.
45
46
47
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 45
def source_type
@source_type
end
|
#storage_config ⇒ Object
Returns the value of attribute storage_config.
46
47
48
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 46
def storage_config
@storage_config
end
|
#version_constraint ⇒ Object
– Required by CookbookOmnifetch API contract
36
37
38
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 36
def version_constraint
@version_constraint
end
|
Instance Method Details
#==(other) ⇒ Object
56
57
58
59
60
61
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 56
def ==(other)
other.kind_of?(self.class) and
other.name == name and
other.version_constraint == version_constraint and
other.source_options == source_options
end
|
#cache_key ⇒ Object
94
95
96
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 94
def cache_key
installer.cache_key
end
|
#cached_cookbook ⇒ Object
118
119
120
121
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 118
def cached_cookbook
installer.cached_cookbook
end
|
#dependencies ⇒ Object
114
115
116
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 114
def dependencies
cached_cookbook.dependencies
end
|
#ensure_cached ⇒ Object
71
72
73
74
75
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 71
def ensure_cached
unless installer.installed?
installer.install
end
end
|
#errors ⇒ Object
81
82
83
84
85
86
87
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 81
def errors
error_messages = []
if installer.nil?
error_messages << "Cookbook `#{name}' has invalid source options `#{source_options.inspect}'"
end
error_messages
end
|
#installed? ⇒ Boolean
67
68
69
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 67
def installed?
installer.installed?
end
|
#installer ⇒ Object
89
90
91
92
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 89
def installer
@installer ||= CookbookOmnifetch.init(self, source_options)
end
|
#mirrors_canonical_upstream? ⇒ Boolean
63
64
65
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 63
def mirrors_canonical_upstream?
[:git, :github, :artifactserver].include?(source_type)
end
|
#relative_path ⇒ Object
98
99
100
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 98
def relative_path
installer.relative_path.to_s
end
|
#source_options_for_lock ⇒ Object
123
124
125
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 123
def source_options_for_lock
installer.lock_data
end
|
#uri ⇒ Object
102
103
104
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 102
def uri
installer.uri
end
|
#valid? ⇒ Boolean
77
78
79
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 77
def valid?
errors.empty?
end
|
#version ⇒ Object
110
111
112
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 110
def version
cached_cookbook.version
end
|
#version_fixed? ⇒ Boolean
106
107
108
|
# File 'lib/chef-dk/policyfile/cookbook_location_specification.rb', line 106
def version_fixed?
[:git, :github, :path].include?(@source_type)
end
|