Class: Vara::Metadata::Stemcell
- Inherits:
-
Object
- Object
- Vara::Metadata::Stemcell
- Defined in:
- lib/vara/metadata/stemcell.rb
Overview
Unlike Vara::ReleaseMetadata and Vara::CompiledPackagesMetadata, this class does not have a settable URL because there is an inferred URL from the global BOSH stemcell blobstore.
“Struct” representing the information about the stemcell field in metadata.yml
Instance Attribute Summary collapse
-
#basename ⇒ String
readonly
The filename of the stemcell.
-
#md5 ⇒ String
readonly
Md5 checksum of the stemcell.
-
#name ⇒ String
readonly
The name of the stemcell.
-
#sha1 ⇒ String
readonly
Sha1 checksum of the stemcell.
-
#version ⇒ String
readonly
The version of the stemcell.
Class Method Summary collapse
-
.from_file(path_to_stemcell) ⇒ Vara::StemcellMetadata
Infers the metadata given a stemcell file on disk.
Instance Method Summary collapse
-
#aws ⇒ nil
The interface for downloader requires this method.
-
#initialize(name:, version:, file:, md5:, sha1:) ⇒ Stemcell
constructor
A new instance of Stemcell.
-
#to_s ⇒ String
A markdown-style URL with the basename attribute.
-
#url ⇒ String
The inferred blobstore URL of the stemcell, assuming it is a BOSH public stemcell.
Constructor Details
#initialize(name:, version:, file:, md5:, sha1:) ⇒ Stemcell
Returns a new instance of Stemcell.
50 51 52 53 54 55 56 |
# File 'lib/vara/metadata/stemcell.rb', line 50 def initialize(name:, version:, file:, md5:, sha1:) @name = name @version = version @basename = file @md5 = md5 @sha1 = sha1 end |
Instance Attribute Details
#basename ⇒ String (readonly)
Returns the filename of the stemcell.
20 21 22 |
# File 'lib/vara/metadata/stemcell.rb', line 20 def basename @basename end |
#md5 ⇒ String (readonly)
Returns md5 checksum of the stemcell.
23 24 25 |
# File 'lib/vara/metadata/stemcell.rb', line 23 def md5 @md5 end |
#name ⇒ String (readonly)
Returns the name of the stemcell.
14 15 16 |
# File 'lib/vara/metadata/stemcell.rb', line 14 def name @name end |
#sha1 ⇒ String (readonly)
Returns sha1 checksum of the stemcell.
26 27 28 |
# File 'lib/vara/metadata/stemcell.rb', line 26 def sha1 @sha1 end |
#version ⇒ String (readonly)
Returns the version of the stemcell.
17 18 19 |
# File 'lib/vara/metadata/stemcell.rb', line 17 def version @version end |
Class Method Details
.from_file(path_to_stemcell) ⇒ Vara::StemcellMetadata
Infers the metadata given a stemcell file on disk
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vara/metadata/stemcell.rb', line 31 def self.from_file(path_to_stemcell) md5 = Digest::MD5.file(path_to_stemcell).hexdigest sha1 = Digest::SHA1.file(path_to_stemcell).hexdigest basename = File.basename(path_to_stemcell) stemcell_parts = basename.gsub(/^bosh-stemcell-/, '').gsub(/\.tgz$/, '') raw_version, iaas, hypervisor, os = stemcell_parts.split('-') version = raw_version.tr('_', '.') name = ['bosh', iaas, hypervisor, os].join('-') new(name: name, version: version, file: basename, md5: md5, sha1: sha1) end |
Instance Method Details
#aws ⇒ nil
Returns the interface for downloader requires this method.
65 66 67 |
# File 'lib/vara/metadata/stemcell.rb', line 65 def aws nil end |
#to_s ⇒ String
Returns a markdown-style URL with the basename attribute.
70 71 72 |
# File 'lib/vara/metadata/stemcell.rb', line 70 def to_s "[#{basename}](#{url})" end |
#url ⇒ String
Returns the inferred blobstore URL of the stemcell, assuming it is a BOSH public stemcell.
59 60 61 62 |
# File 'lib/vara/metadata/stemcell.rb', line 59 def url iaas = basename.gsub(/.*\d-(\w+)-.*/, '\1') "http://bosh-jenkins-artifacts.cf-app.com/bosh-stemcell/#{iaas}/#{basename}" end |