Class: Bosh::Director::Manifest
- Defined in:
- lib/bosh/director/manifest/manifest.rb
Instance Attribute Summary collapse
-
#cloud_config_hash ⇒ Object
readonly
Returns the value of attribute cloud_config_hash.
-
#manifest_hash ⇒ Object
readonly
Returns the value of attribute manifest_hash.
-
#runtime_config_hash ⇒ Object
readonly
Returns the value of attribute runtime_config_hash.
Class Method Summary collapse
- .load_from_hash(manifest_hash, cloud_config, runtime_config) ⇒ Object
- .load_from_text(manifest_text, cloud_config, runtime_config) ⇒ Object
Instance Method Summary collapse
- #diff(other_manifest, redact) ⇒ Object
-
#initialize(manifest_hash, cloud_config_hash, runtime_config_hash) ⇒ Manifest
constructor
A new instance of Manifest.
- #resolve_aliases ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(manifest_hash, cloud_config_hash, runtime_config_hash) ⇒ Manifest
Returns a new instance of Manifest.
19 20 21 22 23 |
# File 'lib/bosh/director/manifest/manifest.rb', line 19 def initialize(manifest_hash, cloud_config_hash, runtime_config_hash) @manifest_hash = manifest_hash @cloud_config_hash = cloud_config_hash @runtime_config_hash = runtime_config_hash end |
Instance Attribute Details
#cloud_config_hash ⇒ Object (readonly)
Returns the value of attribute cloud_config_hash.
17 18 19 |
# File 'lib/bosh/director/manifest/manifest.rb', line 17 def cloud_config_hash @cloud_config_hash end |
#manifest_hash ⇒ Object (readonly)
Returns the value of attribute manifest_hash.
17 18 19 |
# File 'lib/bosh/director/manifest/manifest.rb', line 17 def manifest_hash @manifest_hash end |
#runtime_config_hash ⇒ Object (readonly)
Returns the value of attribute runtime_config_hash.
17 18 19 |
# File 'lib/bosh/director/manifest/manifest.rb', line 17 def runtime_config_hash @runtime_config_hash end |
Class Method Details
.load_from_hash(manifest_hash, cloud_config, runtime_config) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/bosh/director/manifest/manifest.rb', line 10 def self.load_from_hash(manifest_hash, cloud_config, runtime_config) cloud_config_hash = cloud_config.nil? ? nil : cloud_config.manifest runtime_config_hash = runtime_config.nil? ? nil : runtime_config.manifest manifest_hash = manifest_hash.nil? ? {} : manifest_hash new(manifest_hash, cloud_config_hash, runtime_config_hash) end |
.load_from_text(manifest_text, cloud_config, runtime_config) ⇒ Object
5 6 7 8 |
# File 'lib/bosh/director/manifest/manifest.rb', line 5 def self.load_from_text(manifest_text, cloud_config, runtime_config) manifest_text ||= '{}' self.load_from_hash(YAML.load(manifest_text), cloud_config, runtime_config) end |
Instance Method Details
#diff(other_manifest, redact) ⇒ Object
40 41 42 |
# File 'lib/bosh/director/manifest/manifest.rb', line 40 def diff(other_manifest, redact) Changeset.new(to_hash, other_manifest.to_hash).diff(redact).order end |
#resolve_aliases ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bosh/director/manifest/manifest.rb', line 25 def resolve_aliases hashed = to_hash hashed['resource_pools'].to_a.each do |rp| rp['stemcell']['version'] = resolve_stemcell_version(rp['stemcell']) end hashed['stemcells'].to_a.each do |stemcell| stemcell['version'] = resolve_stemcell_version(stemcell) end hashed['releases'].to_a.each do |release| release['version'] = resolve_release_version(release) end end |
#to_hash ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/bosh/director/manifest/manifest.rb', line 44 def to_hash hash = @manifest_hash.merge(@cloud_config_hash || {}) hash.merge(@runtime_config_hash || {}) do |key, old, new| if key == 'releases' if old && new old.to_set.merge(new.to_set).to_a else old.nil? ? new : old end else new end end end |