Class: VagrantPlugins::Scaleway::Action::ListImages

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-scaleway/action/list_images.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, _env) ⇒ ListImages

Returns a new instance of ListImages.



5
6
7
# File 'lib/vagrant-scaleway/action/list_images.rb', line 5

def initialize(app, _env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/vagrant-scaleway/action/list_images.rb', line 9

def call(env)
  compute = env[:scaleway_compute]

  env[:ui].info(format('%-37s %-26s %-7s %-36s %s', 'Image ID', 'Created At', 'Arch', 'Default Bootscript', 'Image Name'), prefix: false)
  compute.images.sort_by(&:name).each do |image|
    created_at = Time.parse(image.creation_date)
    bootscript = image.default_bootscript && image.default_bootscript.title
    env[:ui].info(format('%-37s %-26s %-7s %-36s %s', image.id, created_at, image.arch, bootscript, image.name), prefix: false)
  end

  @app.call(env)
end