Class: Bosh::Cli::PublicStemcells
Constant Summary collapse
- PUBLIC_STEMCELLS_BASE_URL =
'https://bosh-jenkins-artifacts.s3.amazonaws.com'
Instance Method Summary collapse
- #all ⇒ Object
- #find(stemcell_filename) ⇒ Object
- #has_stemcell?(stemcell_filename) ⇒ Boolean
- #recent ⇒ Object
Instance Method Details
#all ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cli/public_stemcells.rb', line 18 def all response = HTTPClient.new.get(PUBLIC_STEMCELLS_BASE_URL) doc = REXML::Document.new(response.body) = REXML::XPath.match(doc, "/ListBucketResult/Contents[Key[text()[starts-with(.,'bosh-stemcell/') and not(contains(.,'latest'))]]]") .map do |stemcell_tag| stemcell_key = stemcell_tag.get_text('Key').value stemcell_size = Integer(stemcell_tag.get_text('Size').value) PublicStemcell.new(stemcell_key, stemcell_size) end end |
#find(stemcell_filename) ⇒ Object
14 15 16 |
# File 'lib/cli/public_stemcells.rb', line 14 def find(stemcell_filename) all.detect { |stemcell| stemcell.name == stemcell_filename } end |
#has_stemcell?(stemcell_filename) ⇒ Boolean
10 11 12 |
# File 'lib/cli/public_stemcells.rb', line 10 def has_stemcell?(stemcell_filename) all.any? { |stemcell| stemcell.name == stemcell_filename } end |
#recent ⇒ Object
31 32 33 34 |
# File 'lib/cli/public_stemcells.rb', line 31 def recent stemcell_varietes = all.reject(&:legacy?).group_by(&:variety).values stemcell_varietes.map { |stemcells| stemcells.sort_by(&:version).last } end |