class HammerCLICsv::CsvCommand::ContainersCommand

Constants

ATTACH
COMMAND
COMPUTERESOURCE
ENTRYPOINT
REGISTRY
REPOSITORY

Public Instance Methods

create_containers_from_csv(line) click to toggle source
# File lib/hammer_cli_csv/containers.rb, line 38
def create_containers_from_csv(line)
  # TODO: containers cannot be updated (no api)
  # count(line[COUNT]).times do |number|
  #   name = namify(line[NAME], number)
  #   params =  { 'id' => foreman_container(:name => name),
  #               'container' => {
  #                 'name' => name,
  #                 'command' => line[COMMAND]
  #               }
  #             }
  #   print "Updating container '#{name}'..." if option_verbose?
  #   @api.resource(:containers).call(:update, params)
  # end
  # print "done\n" if option_verbose?
end
export(csv) click to toggle source
# File lib/hammer_cli_csv/containers.rb, line 14
def export(csv)
  csv << [NAME, REGISTRY, REPOSITORY, COMPUTERESOURCE, ATTACH, ENTRYPOINT, COMMAND]
  @api.resource(:containers).call(:index, {
      'per_page' => 999999,
      'search' => option_search
  })['results'].each do |container|
    csv << [container['name'],
            container['registry_name'],
            "#{container['repository_name']}:#{container['tag']}",
            container['compute_resource_name'],
            export_attach_types(container),
            container['entrypoint'],
            container['command']]
  end
end
import() click to toggle source
# File lib/hammer_cli_csv/containers.rb, line 30
def import
  @existing = {}

  thread_import do |line|
    create_containers_from_csv(line)
  end
end

Private Instance Methods

export_attach_types(container) click to toggle source
# File lib/hammer_cli_csv/containers.rb, line 56
def export_attach_types(container)
  types = []
  types << 'tty' if container['tty']
  types << 'stdin' if container['attach_stdin']
  types << 'stdout' if container['attach_stdout']
  types << 'stderr' if container['attach_stderr']
  types.join(',')
end