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

basename[R]

@return [String] the filename of the stemcell

md5[R]

@return [String] md5 checksum of the stemcell

name[R]

@return [String] the name of the stemcell.

sha1[R]

@return [String] sha1 checksum of the stemcell

version[R]

@return [String] the version of the stemcell.

Public Class Methods

from_file(path_to_stemcell) click to toggle source

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
new(name:, version:, file:, md5:, sha1:) click to toggle source

@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

aws() click to toggle source

@return [nil] the interface for downloader requires this method

# File lib/vara/metadata/stemcell.rb, line 65
def aws
  nil
end
to_s() click to toggle source

@return [String] a markdown-style URL with the basename attribute.

# File lib/vara/metadata/stemcell.rb, line 70
def to_s
  "[#{basename}](#{url})"
end
url() click to toggle source

@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