Class: OsCtld::Commands::Repository::TemplateList

Inherits:
Base
  • Object
show all
Includes:
Utils::Repository
Defined in:
lib/osctld/commands/repository/template_list.rb

Instance Attribute Summary

Attributes inherited from Base

#client, #client_handler, #id, #opts

Instance Method Summary collapse

Methods included from Utils::Repository

#osctl_repo_get, #osctl_repo_ls

Methods inherited from Base

#base_execute, #call_cmd, #call_cmd!, cmd, #error, #error!, handle, #handled, #indirect?, #initialize, #manipulate, #manipulation_holder, #ok, #progress, #request_stop, run, run!

Constructor Details

This class inherits a constructor from OsCtld::Commands::Base

Instance Method Details

#executeObject



9
10
11
12
13
14
# File 'lib/osctld/commands/repository/template_list.rb', line 9

def execute
  repo = DB::Repositories.find(opts[:name], opts[:pool])
  error!('repository not found') unless repo

  ok(osctl_repo_ls(repo).select(&method(:filter)).map(&:dump))
end

#filter(t) ⇒ Object (protected)



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/osctld/commands/repository/template_list.rb', line 17

def filter(t)
  %i(vendor variant arch distribution version).each do |v|
    return false if opts[v] && opts[v] != t.send(v)
  end

  return false if opts[:tag] && !t.tags.include?(opts[:tag])
  return false if opts[:cached] === true && !t.cached?
  return false if opts[:cached] === false && t.cached?

  true
end