Class: Stemcell::MetadataSource::ChefRepository
- Inherits:
-
Object
- Object
- Stemcell::MetadataSource::ChefRepository
- Includes:
- Chef::Mixin::DeepMerge
- Defined in:
- lib/stemcell/metadata_source/chef_repository.rb
Constant Summary collapse
- METADATA_ATTRIBUTES =
Search for instance metadata in the following role attributes, with priority given to the keys at the head.
[ :instance_metadata, :stemcell ]
Instance Attribute Summary collapse
-
#chef_root ⇒ Object
readonly
Returns the value of attribute chef_root.
Instance Method Summary collapse
-
#initialize(chef_root) ⇒ ChefRepository
constructor
A new instance of ChefRepository.
-
#metadata_for_role(chef_role, chef_environment, chef_options = {}) ⇒ Object
This method will return nil if the role has no stemcell metdata.
Constructor Details
#initialize(chef_root) ⇒ ChefRepository
Returns a new instance of ChefRepository.
18 19 20 21 22 23 24 25 |
# File 'lib/stemcell/metadata_source/chef_repository.rb', line 18 def initialize(chef_root) @chef_root = chef_root if chef_root.nil? raise ArgumentError, "You must specify a chef repository" end configure_chef end |
Instance Attribute Details
#chef_root ⇒ Object (readonly)
Returns the value of attribute chef_root.
9 10 11 |
# File 'lib/stemcell/metadata_source/chef_repository.rb', line 9 def chef_root @chef_root end |
Instance Method Details
#metadata_for_role(chef_role, chef_environment, chef_options = {}) ⇒ Object
This method will return nil if the role has no stemcell metdata.
28 29 30 31 |
# File 'lib/stemcell/metadata_source/chef_repository.rb', line 28 def (chef_role, chef_environment, = {}) attrs = (chef_role, chef_environment, ) METADATA_ATTRIBUTES.inject(nil) { |r, key| r || attrs[key] } end |