Class: ChefCLI::Policyfile::RemoteLockFetcher
- Inherits:
-
Object
- Object
- ChefCLI::Policyfile::RemoteLockFetcher
- Includes:
- LockFetcherMixin
- Defined in:
- lib/chef-cli/policyfile/remote_lock_fetcher.rb
Overview
A policyfile lock fetcher that can read a lock from a remote location.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#source_options ⇒ Object
readonly
Returns the value of attribute source_options.
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) ⇒ RemoteLockFetcher
constructor
Initialize a RemoteLockFetcher.
-
#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) ⇒ RemoteLockFetcher
Initialize a RemoteLockFetcher
39 40 41 42 |
# File 'lib/chef-cli/policyfile/remote_lock_fetcher.rb', line 39 def initialize(name, ) @name = name @source_options = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
31 32 33 |
# File 'lib/chef-cli/policyfile/remote_lock_fetcher.rb', line 31 def name @name end |
#source_options ⇒ Object (readonly)
Returns the value of attribute source_options.
32 33 34 |
# File 'lib/chef-cli/policyfile/remote_lock_fetcher.rb', line 32 def @source_options 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
72 73 74 |
# File 'lib/chef-cli/policyfile/remote_lock_fetcher.rb', line 72 def () # There are no options the lock could provide end |
#errors ⇒ Array<String>
Check the options provided when creating this class for errors
53 54 55 56 57 58 59 60 61 |
# File 'lib/chef-cli/policyfile/remote_lock_fetcher.rb', line 53 def errors = [] [:remote].each do |key| << "include_policy for #{name} is missing key #{key}" unless [key] end end |
#lock_data ⇒ String
Returns of the policyfile lock data.
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/chef-cli/policyfile/remote_lock_fetcher.rb', line 77 def lock_data fetch_lock_data.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? raise ChefCLI::InvalidLockfile, "Invalid cookbook path: #{cookbook_path}. Remote Policyfiles should only use remote cookbooks." end end end end |
#source_options_for_lock ⇒ Hash
Returns The source_options that describe how to fetch this exact lock again.
64 65 66 |
# File 'lib/chef-cli/policyfile/remote_lock_fetcher.rb', line 64 def end |
#valid? ⇒ True, False
46 47 48 |
# File 'lib/chef-cli/policyfile/remote_lock_fetcher.rb', line 46 def valid? errors.empty? end |