Class: OsCtl::Image::Operations::Repository::GetImagePath
- Defined in:
- lib/osctl/image/operations/repository/get_image_path.rb
Instance Attribute Summary collapse
- #attrs ⇒ Hash readonly
- #format ⇒ String readonly
- #repo_dir ⇒ String readonly
Instance Method Summary collapse
-
#execute ⇒ String
Path to the image.
-
#initialize(repo_dir, attrs, format) ⇒ GetImagePath
constructor
A new instance of GetImagePath.
Methods inherited from Base
Constructor Details
#initialize(repo_dir, attrs, format) ⇒ GetImagePath
Returns a new instance of GetImagePath.
23 24 25 26 27 28 |
# File 'lib/osctl/image/operations/repository/get_image_path.rb', line 23 def initialize(repo_dir, attrs, format) super() @repo_dir = repo_dir @attrs = attrs @format = format.to_s end |
Instance Attribute Details
#attrs ⇒ Hash (readonly)
10 11 12 |
# File 'lib/osctl/image/operations/repository/get_image_path.rb', line 10 def attrs @attrs end |
#format ⇒ String (readonly)
13 14 15 |
# File 'lib/osctl/image/operations/repository/get_image_path.rb', line 13 def format @format end |
#repo_dir ⇒ String (readonly)
7 8 9 |
# File 'lib/osctl/image/operations/repository/get_image_path.rb', line 7 def repo_dir @repo_dir end |
Instance Method Details
#execute ⇒ String
Returns path to the image.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/osctl/image/operations/repository/get_image_path.rb', line 31 def execute repo = OsCtl::Repo::Local::Repository.new(repo_dir) unless repo.exist? raise OperationError, 'repository does not exist' end img = repo.find( attrs[:vendor], attrs[:variant], attrs[:arch], attrs[:distribution], attrs[:version] ) raise OperationError, 'image not found' unless img raise OperationError 'image format not found' unless img.has_image?(format) File.join(repo_dir, img.version_image_path(format)) end |