Class: Sle2Docker::NativeImage

Inherits:
Image
  • Object
show all
Defined in:
lib/sle2docker/native_image.rb

Overview

This class takes care of handling the native loadable images for SUSE Linux Enterprise

Constant Summary collapse

IMAGES_DIR =
'/usr/share/suse-docker-images/native'.freeze

Instance Attribute Summary

Attributes inherited from Image

#image_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Image

#activated?, #check_image_exists, #rpm_package_name, #verify_image

Constructor Details

#initialize(image_name, options) ⇒ NativeImage

Returns a new instance of NativeImage.



17
18
19
20
21
# File 'lib/sle2docker/native_image.rb', line 17

def initialize(image_name, options)
  @image_name = image_name
  @options = options
  
end

Class Method Details

.listObject



7
8
9
10
11
12
13
14
15
# File 'lib/sle2docker/native_image.rb', line 7

def self.list
  if File.exist?(NativeImage::IMAGES_DIR)
    Dir[File.join(NativeImage::IMAGES_DIR, '*.tar.xz')].map do |image|
      File.basename(image, '.tar.xz')
    end
  else
    []
  end
end

Instance Method Details

#activateObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/sle2docker/native_image.rb', line 23

def activate
  verify_image

  puts 'Loading image'
  Docker::Image.load(File.join(IMAGES_DIR, "#{@image_name}.tar.xz"))
  image = Docker::Image.get(@image_id)
  image.tag('repo' => @repository, 'tag' => 'latest')
  @options['tag_with_build'] &&
    image.tag('repo' => @repository, 'tag' => "#{@tag}-#{@build}")
end