class Vara::Metadata::Stemcell
“Struct” representing the information about the stemcell field in metadata.yml @note 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.
@example entry from metadata.yml
stemcell: name: bosh-vsphere-esxi-ubuntu version: '2366' file: bosh-stemcell-2366-vsphere-esxi-ubuntu.tgz md5: 0fbdcd100f716d127f821b1b4335135a
Attributes
@return [String] the filename of the stemcell
@return [String] md5 checksum of the stemcell
@return [String] the name of the stemcell.
@return [String] sha1 checksum of the stemcell
@return [String] the version of the stemcell.
Public Class Methods
Infers the metadata given a stemcell file on disk @param path_to_stemcell [String] The path to the stemcell file on disk @return [Vara::StemcellMetadata]
# 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
@param name [String] @param version [String] @param file [String] @param md5 [String]
# 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
Public Instance Methods
@return [nil] the interface for downloader requires this method
# File lib/vara/metadata/stemcell.rb, line 65 def aws nil end
@return [String] a markdown-style URL with the basename attribute.
# File lib/vara/metadata/stemcell.rb, line 70 def to_s "[#{basename}](#{url})" end
@return [String] the inferred blobstore URL of the stemcell, assuming it is a BOSH public stemcell
# 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