Class: OsCtl::Image::Operations::Repository::AddImage

Inherits:
Base
  • Object
show all
Defined in:
lib/osctl/image/operations/repository/add_image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

run

Constructor Details

#initialize(repo_dir, images, attrs, tags) ⇒ AddImage

Returns a new instance of AddImage.

Parameters:

  • repo_dir (String)
  • images (String)
  • attrs (Hash)
  • tags (Array<String>)

Options Hash (attrs):

  • :distribution (String)
  • :version (String)
  • :arch (String)
  • :vendor (String)
  • :variant (String)


27
28
29
30
31
32
33
# File 'lib/osctl/image/operations/repository/add_image.rb', line 27

def initialize(repo_dir, images, attrs, tags)
  super()
  @repo_dir = repo_dir
  @images = images
  @attrs = attrs
  @tags = tags
end

Instance Attribute Details

#attrsHash (readonly)

Returns:

  • (Hash)


13
14
15
# File 'lib/osctl/image/operations/repository/add_image.rb', line 13

def attrs
  @attrs
end

#imagesHash<Symbol, String> (readonly)

Returns:

  • (Hash<Symbol, String>)


10
11
12
# File 'lib/osctl/image/operations/repository/add_image.rb', line 10

def images
  @images
end

#repo_dirString (readonly)

Returns:

  • (String)


7
8
9
# File 'lib/osctl/image/operations/repository/add_image.rb', line 7

def repo_dir
  @repo_dir
end

#tagsArray<String> (readonly)

Returns:

  • (Array<String>)


16
17
18
# File 'lib/osctl/image/operations/repository/add_image.rb', line 16

def tags
  @tags
end

Instance Method Details

#executeObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/osctl/image/operations/repository/add_image.rb', line 35

def execute
  repo = OsCtl::Repo::Local::Repository.new(repo_dir)

  unless repo.exist?
    raise OperationError, 'repository does not exist'
  end

  repo.add(
    attrs[:vendor],
    attrs[:variant],
    attrs[:arch],
    attrs[:distribution],
    attrs[:version],
    tags:,
    image: images
  )
end