class Ruboty::Docker::Actions::Inspect

Public Instance Methods

call() click to toggle source
# File lib/ruboty/docker/actions/inspect.rb, line 5
def call
    images = ::Docker::Image.get(message[:target_name])
    info   = images.instance_variable_get(:@info)
    message.reply(info, code: true) if message[:debug] == ' -D '
    rows = []
    rows.push ['ID', images.instance_variable_get(:@id)]
    rows.push ['Architecture', info['Architecture']]
    rows.push ['Author', info['Author']]
    rows.push ['Command', info['Config']['Cmd']]
    unless info['Config']['Env'].nil?
        info['Config']['Env'].each_index do |n|
            if n == 0
                rows.push ['Env', info['Config']['Env'][n]]
            else
                rows.push ['', info['Config']['Env'][n]]
            end
        end
    end
    unless info['Config']['OnBuild'].nil?
        info['Config']['OnBuild'].each_index do |n|
            if n == 0
                rows.push ['OnBuild', info['Config']['OnBuild'][n]]
            else
                rows.push ['', info['Config']['OnBuild'][n]]
            end
        end
    end
    rows.push ['Port Specs', info['Config']['PortSpecs']]
    rows.push ['User', info['Config']['User']]
    rows.push ['Volumes', info['Config']['Volumes']]
    rows.push ['Working Dir', info['Config']['WorkingDir']]

    table       = ::Terminal::Table.new title: 'DOCKER INSPECT', rows: rows
    table.style = { :padding_left => 0, :border_x => '', :border_y => ' ', :border_i => '' }
    message.reply(table, code: true)
rescue => e
    value = [e.class.name, e.message].join("\n")
    message.reply value
ensure
end