Class: Bosh::Cli::PublicStemcells

Inherits:
Object
  • Object
show all
Defined in:
lib/cli/public_stemcells.rb

Constant Summary collapse

PUBLIC_STEMCELLS_BASE_URL =
'https://bosh-jenkins-artifacts.s3.amazonaws.com'

Instance Method Summary collapse

Instance Method Details

#allObject



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)
  stemcell_tags = REXML::XPath.match(doc, "/ListBucketResult/Contents[Key[text()[starts-with(.,'bosh-stemcell/') and not(contains(.,'latest'))]]]")

  stemcell_tags.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

Returns:

  • (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

#recentObject



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