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



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cli/public_stemcells.rb', line 19

def all
  response = HTTPClient.new.get(PUBLIC_STEMCELLS_BASE_URL, {'prefix' => 'bosh-stemcell'})
  doc = REXML::Document.new(response.body)
  stemcells_tags = parse_document(doc)
  stemcells = parse_stemcells(stemcells_tags)

  while is_truncated(doc)
    response = HTTPClient.new.get(PUBLIC_STEMCELLS_BASE_URL, {
      'prefix' => 'bosh-stemcell',
      'marker' => stemcells_tags.last.get_text('Key').value
    })

    doc = REXML::Document.new(response.body)
    stemcells_tags = parse_document(doc)
    stemcells += parse_stemcells(stemcells_tags)
  end

  stemcells
end

#find(stemcell_filename) ⇒ Object



15
16
17
# File 'lib/cli/public_stemcells.rb', line 15

def find(stemcell_filename)
  all.detect { |stemcell| stemcell.name == stemcell_filename }
end

#has_stemcell?(stemcell_filename) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/cli/public_stemcells.rb', line 11

def has_stemcell?(stemcell_filename)
  all.any? { |stemcell| stemcell.name == stemcell_filename }
end

#recentObject



39
40
41
42
# File 'lib/cli/public_stemcells.rb', line 39

def recent
  stemcell_varietes = all.reject(&:legacy?).group_by(&:variety).values
  stemcell_varietes.map { |stemcells| stemcells.sort_by(&:version).last }
end