Class: ChefDK::Policyfile::ArchivedCookbook

Inherits:
CookbookLock show all
Extended by:
Forwardable
Defined in:
lib/chef-dk/policyfile/cookbook_locks.rb

Constant Summary

Constants inherited from CookbookLock

CookbookLock::REQUIRED_LOCK_DATA_KEYS

Instance Attribute Summary

Attributes inherited from CookbookLock

#dotted_decimal_identifier, #identifier, #name, #source_options, #storage_config, #version

Instance Method Summary collapse

Methods inherited from CookbookLock

#chefignore, #cookbook_loader, #cookbook_location_spec, #cookbook_version, #dependencies, #gather_profile_data, #identifier_updated?, #identifiers, #install_locked, #lock_data, #symbolize_source_options_keys, #to_lock, #updated?, #version_updated?

Methods included from StorageConfigDelegation

#cache_path, #policyfile_expanded_path, #policyfile_filename, #policyfile_lock_expanded_path, #relative_paths_root

Constructor Details

#initialize(archived_lock, storage_config) ⇒ ArchivedCookbook

Returns a new instance of ArchivedCookbook.



433
434
435
436
# File 'lib/chef-dk/policyfile/cookbook_locks.rb', line 433

def initialize(archived_lock, storage_config)
  @archived_lock = archived_lock
  @storage_config = storage_config
end

Instance Method Details

#build_from_lock_data(lock_data) ⇒ Object

Raises:

  • (NotImplementedError)


438
439
440
# File 'lib/chef-dk/policyfile/cookbook_locks.rb', line 438

def build_from_lock_data(lock_data)
  raise NotImplementedError, "ArchivedCookbook cannot be built from lock data, it can only wrap an existing lock object"
end

#cookbook_pathObject

The cookbook is assumed to be stored in a Chef Zero compatible repo as created by ‘chef export`. Currently that only creates “compatibility mode” repos since Chef Zero doesn’t yet support cookbook_artifact APIs. So the cookbook will be located in a path like:

cookbooks/nginx-111.222.333


451
452
453
# File 'lib/chef-dk/policyfile/cookbook_locks.rb', line 451

def cookbook_path
  File.join(relative_paths_root, "cookbook_artifacts", "#{name}-#{identifier}")
end

#installed?Boolean

Returns:

  • (Boolean)


442
443
444
# File 'lib/chef-dk/policyfile/cookbook_locks.rb', line 442

def installed?
  File.exist?(cookbook_path) && File.directory?(cookbook_path)
end

#refresh!Object

We trust that archived cookbooks haven’t been modified, so just return true for #refresh!



463
464
465
# File 'lib/chef-dk/policyfile/cookbook_locks.rb', line 463

def refresh!
  true
end

#validate!Object

We trust that archived cookbooks haven’t been modified, so just return true for #validate!



457
458
459
# File 'lib/chef-dk/policyfile/cookbook_locks.rb', line 457

def validate!
  true
end