Sha256: 21e78813da320813019dbc700190d41f62b170f4e12366afa6e4f790ce789618

Contents?: true

Size: 1.18 KB

Versions: 43

Compression:

Stored size: 1.18 KB

Contents

require_relative 'services_helper'

module Kontena::Cli::Services
  class ContainersCommand < Kontena::Command
    include Kontena::Cli::Common
    include Kontena::Cli::GridOptions
    include ServicesHelper

    parameter "NAME", "Service name"
    option ['-q', '--quiet'], :flag, "Output the identifying column only"

    def execute
      require_api_url
      token = require_token

      result = client(token).get("services/#{parse_service_id(name)}/containers")

      if quiet?
        puts result['containers'].map { |c| "#{c['node']['name']}/#{c['name']}" }.join("\n")
        exit 0
      end

      result['containers'].each do |container|
        puts "#{container['name']}:"
        puts "  rev: #{container['deploy_rev']}"
        puts "  node: #{container['node']['name']}"
        puts "  dns: #{container['hostname']}.#{container['domainname']}"
        puts "  ip: #{container['ip_address']}"
        puts "  public ip: #{container['node']['public_ip']}"
        if container['status'] == 'unknown'
          puts "  status: #{container['status'].colorize(:yellow)}"
        else
          puts "  status: #{container['status']}"
        end
        puts ""
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
kontena-cli-1.4.3 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.4.3.rc1 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.4.2 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.4.2.rc1 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.4.2.pre1 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.4.1 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.4.1.rc1 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.4.1.pre1 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.3.5 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.3.5.rc1 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.4.0 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.4.0.rc2 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.4.0.rc1 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.4.0.pre14 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.4.0.pre13 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.4.0.pre12 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.4.0.pre11 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.4.0.pre10 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.4.0.pre9 lib/kontena/cli/services/containers_command.rb
kontena-cli-1.4.0.pre8 lib/kontena/cli/services/containers_command.rb