class ChefCLI::Policyfile::LockApplier
A class that can apply constraints from a lock to a compiler
Attributes
policyfile_compiler[R]
policyfile_lock[R]
unlocked_policies[R]
Public Class Methods
new(policyfile_lock, policyfile_compiler)
click to toggle source
Initialize a LockApplier
. By default, all locked data this class knows about will be applied to the compiler. Currently, it applies locks only for included policies.
@param policyfile_lock
[PolicyfileLock] contains the locked data to use @param policyfile_compiler
[PolicyfileCompiler] the compiler to apply the locked data
# File lib/chef-cli/policyfile/lock_applier.rb, line 33 def initialize(policyfile_lock, policyfile_compiler) @policyfile_lock = policyfile_lock @policyfile_compiler = policyfile_compiler @unlocked_policies = [] end
Public Instance Methods
apply!()
click to toggle source
Apply locks described in policyfile_lock
allowing for the deviations asked for.
@note No changes are applied until apply! is invoked
# File lib/chef-cli/policyfile/lock_applier.rb, line 58 def apply! prepare_constraints_for_policies end
with_unlocked_policies(policies)
click to toggle source
Unlocks included policies
@param policies [:all] Unconstrain all policies @param policies [Array<String>] Unconstrain a specific policy by name
# File lib/chef-cli/policyfile/lock_applier.rb, line 43 def with_unlocked_policies(policies) if policies == :all || unlocked_policies == :all @unlocked_policies = :all else policies.each do |policy| @unlocked_policies << policy end end self end
Private Instance Methods
prepare_constraints_for_policies()
click to toggle source
# File lib/chef-cli/policyfile/lock_applier.rb, line 64 def prepare_constraints_for_policies if unlocked_policies == :all return end policyfile_compiler.included_policies.each do |policy| unless unlocked_policies.include?(policy.name) lock = policyfile_lock.included_policy_locks.find do |policy_lock| policy_lock["name"] == policy.name end policy.apply_locked_source_options(lock["source_options"]) end end end