Class: ChefDK::Policyfile::LocalLockFetcher
- Inherits:
-
Object
- Object
- ChefDK::Policyfile::LocalLockFetcher
- Defined in:
- lib/chef-dk/policyfile/local_lock_fetcher.rb
Overview
A policyfile lock fetcher that can read a lock from a local disk
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#source_options ⇒ Object
readonly
Returns the value of attribute source_options.
-
#storage_config ⇒ Object
readonly
Returns the value of attribute storage_config.
Instance Method Summary collapse
-
#apply_locked_source_options(options_from_lock) ⇒ Object
Applies source options from a lock file.
-
#errors ⇒ Array<String>
Check the options provided when craeting this class for errors.
-
#initialize(name, source_options, storage_config) ⇒ LocalLockFetcher
constructor
Initialize a LocalLockFetcher.
-
#lock_data ⇒ String
Of the policyfile lock data.
-
#source_options_for_lock ⇒ Hash
The source_options that describe how to fetch this exact lock again.
- #valid? ⇒ True, False
Constructor Details
#initialize(name, source_options, storage_config) ⇒ LocalLockFetcher
Initialize a LocalLockFetcher
37 38 39 40 41 |
# File 'lib/chef-dk/policyfile/local_lock_fetcher.rb', line 37 def initialize(name, , storage_config) @name = name @source_options = @storage_config = storage_config end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
27 28 29 |
# File 'lib/chef-dk/policyfile/local_lock_fetcher.rb', line 27 def name @name end |
#source_options ⇒ Object (readonly)
Returns the value of attribute source_options.
28 29 30 |
# File 'lib/chef-dk/policyfile/local_lock_fetcher.rb', line 28 def @source_options end |
#storage_config ⇒ Object (readonly)
Returns the value of attribute storage_config.
29 30 31 |
# File 'lib/chef-dk/policyfile/local_lock_fetcher.rb', line 29 def storage_config @storage_config end |
Instance Method Details
#apply_locked_source_options(options_from_lock) ⇒ Object
Applies source options from a lock file. This is used to make sure that the same policyfile lock is loaded that was locked
71 72 73 |
# File 'lib/chef-dk/policyfile/local_lock_fetcher.rb', line 71 def () # There are no options the lock could provide end |
#errors ⇒ Array<String>
Check the options provided when craeting this class for errors
52 53 54 55 56 57 58 59 60 |
# File 'lib/chef-dk/policyfile/local_lock_fetcher.rb', line 52 def errors = [] [:path].each do |key| << "include_policy for #{name} is missing key #{key}" unless [key] end end |
#lock_data ⇒ String
Returns of the policyfile lock data.
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/chef-dk/policyfile/local_lock_fetcher.rb', line 76 def lock_data FFI_Yajl::Parser.new.parse(content).tap do |data| data["cookbook_locks"].each do |cookbook_name, cookbook_lock| cookbook_path = cookbook_lock["source_options"]["path"] if !cookbook_path.nil? cookbook_lock["source_options"]["path"] = transform_path(cookbook_path) end end end end |
#source_options_for_lock ⇒ Hash
Returns The source_options that describe how to fetch this exact lock again.
63 64 65 |
# File 'lib/chef-dk/policyfile/local_lock_fetcher.rb', line 63 def end |
#valid? ⇒ True, False
45 46 47 |
# File 'lib/chef-dk/policyfile/local_lock_fetcher.rb', line 45 def valid? errors.empty? end |