Sha256: c2accf2a8b50ee889f46d779e9002f5741ed63d207945e6fdfbd0fc007e7b56f

Contents?: true

Size: 701 Bytes

Versions: 14

Compression:

Stored size: 701 Bytes

Contents

require_relative 'common'

module Kontena::Cli::Stacks
  class ListCommand < Clamp::Command
    include Kontena::Cli::Common
    include Kontena::Cli::GridOptions
    include Common

    COLUMNS = "%-30s %-10s %-10s".freeze

    def execute
      require_api_url
      require_token

      list_stacks
    end

    private

    def list_stacks
      response = client(token).get("stacks/#{current_grid}")
      
      titles = ['NAME', 'SERVICES', 'STATE']
      puts COLUMNS % titles

      response['stacks'].each do |stack|
        vars = [
          stack['name'],
          stack['grid_services'].size,
          stack['state']
        ]

        puts COLUMNS % vars
      end
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
kontena-cli-0.15.5 lib/kontena/cli/stacks/list_command.rb
kontena-cli-0.15.5.rc2 lib/kontena/cli/stacks/list_command.rb
kontena-cli-0.15.5.rc1 lib/kontena/cli/stacks/list_command.rb
kontena-cli-0.15.4 lib/kontena/cli/stacks/list_command.rb
kontena-cli-0.15.4.rc2 lib/kontena/cli/stacks/list_command.rb
kontena-cli-0.15.4.rc1 lib/kontena/cli/stacks/list_command.rb
kontena-cli-0.15.4.pre1 lib/kontena/cli/stacks/list_command.rb
kontena-cli-0.15.3 lib/kontena/cli/stacks/list_command.rb
kontena-cli-0.15.2 lib/kontena/cli/stacks/list_command.rb
kontena-cli-0.15.1 lib/kontena/cli/stacks/list_command.rb
kontena-cli-0.15.0 lib/kontena/cli/stacks/list_command.rb
kontena-cli-0.15.0.rc3 lib/kontena/cli/stacks/list_command.rb
kontena-cli-0.15.0.rc2 lib/kontena/cli/stacks/list_command.rb
kontena-cli-0.15.0.rc1 lib/kontena/cli/stacks/list_command.rb