Class: ChefCLI::Policyfile::LocalLockFetcher
- Inherits:
-
Object
- Object
- ChefCLI::Policyfile::LocalLockFetcher
- Includes:
- LockFetcherMixin
- Defined in:
- lib/chef-cli/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 creating 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
Methods included from LockFetcherMixin
Constructor Details
#initialize(name, source_options, storage_config) ⇒ LocalLockFetcher
Initialize a LocalLockFetcher
39 40 41 42 43 |
# File 'lib/chef-cli/policyfile/local_lock_fetcher.rb', line 39 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.
29 30 31 |
# File 'lib/chef-cli/policyfile/local_lock_fetcher.rb', line 29 def name @name end |
#source_options ⇒ Object (readonly)
Returns the value of attribute source_options.
30 31 32 |
# File 'lib/chef-cli/policyfile/local_lock_fetcher.rb', line 30 def @source_options end |
#storage_config ⇒ Object (readonly)
Returns the value of attribute storage_config.
31 32 33 |
# File 'lib/chef-cli/policyfile/local_lock_fetcher.rb', line 31 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
73 74 75 |
# File 'lib/chef-cli/policyfile/local_lock_fetcher.rb', line 73 def () # There are no options the lock could provide end |
#errors ⇒ Array<String>
Check the options provided when creating this class for errors
54 55 56 57 58 59 60 61 62 |
# File 'lib/chef-cli/policyfile/local_lock_fetcher.rb', line 54 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.
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/chef-cli/policyfile/local_lock_fetcher.rb', line 78 def lock_data FFI_Yajl::Parser.new.parse(content).tap do |data| validate_revision_id(data["revision_id"], ) data["cookbook_locks"].each do |cookbook_name, cookbook_lock| cookbook_path = cookbook_lock["source_options"]["path"] unless 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.
65 66 67 |
# File 'lib/chef-cli/policyfile/local_lock_fetcher.rb', line 65 def end |
#valid? ⇒ True, False
47 48 49 |
# File 'lib/chef-cli/policyfile/local_lock_fetcher.rb', line 47 def valid? errors.empty? end |