Sha256: 74bdd85119c96116bfbae42682c6c3532bf82e654c5f9985f586a2763f0e608e

Contents?: true

Size: 893 Bytes

Versions: 12

Compression:

Stored size: 893 Bytes

Contents

require_relative 'services_helper'

module Kontena::Cli::Services
  class ListCommand < Clamp::Command
    include Kontena::Cli::Common
    include ServicesHelper

    def execute
      require_api_url
      token = require_token

      grids = client(token).get("grids/#{current_grid}/services")
      titles = ['NAME', 'IMAGE', 'INSTANCES', 'STATEFUL', 'STATE']
      puts "%-30.30s %-50.50s %-10s %-8s %-10s" % titles
      grids['services'].each do |service|
        stateful = service['stateful'] ? 'yes' : 'no'
        image = service['image']
        if image.length > 50
          image = image[0..10] << '...' << image[-35..-1]
        end
        vars = [
          service['name'],
          image,
          service['container_count'],
          stateful,
          service['state']
        ]
        puts "%-30.30s %-50.50s %-10.10s %-8s %-10s" % vars
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
kontena-cli-0.11.7 lib/kontena/cli/services/list_command.rb
kontena-cli-0.11.6 lib/kontena/cli/services/list_command.rb
kontena-cli-0.11.5 lib/kontena/cli/services/list_command.rb
kontena-cli-0.11.4 lib/kontena/cli/services/list_command.rb
kontena-cli-0.11.3 lib/kontena/cli/services/list_command.rb
kontena-cli-0.11.2 lib/kontena/cli/services/list_command.rb
kontena-cli-0.11.1 lib/kontena/cli/services/list_command.rb
kontena-cli-0.11.0 lib/kontena/cli/services/list_command.rb
kontena-cli-0.10.3 lib/kontena/cli/services/list_command.rb
kontena-cli-0.10.2 lib/kontena/cli/services/list_command.rb
kontena-cli-0.10.1 lib/kontena/cli/services/list_command.rb
kontena-cli-0.10.0 lib/kontena/cli/services/list_command.rb