Sha256: 88752486d37047790dc92b70acdc3ffaf5dbbe8828f2139b5bb22a5bb76a3245

Contents?: true

Size: 925 Bytes

Versions: 38

Compression:

Stored size: 925 Bytes

Contents

require_relative 'common'

module Kontena::Cli::Grids
  class EnvCommand < Clamp::Command
    include Kontena::Cli::Common
    include Common

    parameter "[NAME]", "Grid name"
    option ["-e", "--export"], :flag, "Add export", default: false

    def execute
      require_api_url

      name_or_current = name.nil? ? current_grid : name

      if name_or_current.nil?
        abort "No grid selected. Use: kontena grid env <name>, or select a grid with: kontena grid use <name>"
      else
        grid = find_grid_by_name(name_or_current)
        abort("Grid not found".colorize(:red)) unless grid

        prefix = export? ? 'export ' : ''

        server = settings['servers'].find{|s| s['name'] == settings['current_server']}
        if server
          puts "#{prefix}KONTENA_URI=#{server['url'].sub('http', 'ws')}"
          puts "#{prefix}KONTENA_TOKEN=#{server['token']}"
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
kontena-cli-0.15.5 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.15.5.rc2 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.15.5.rc1 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.15.4 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.15.4.rc2 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.15.4.rc1 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.15.4.pre1 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.15.3 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.15.2 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.15.1 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.15.0 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.15.0.rc3 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.15.0.rc2 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.15.0.rc1 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.14.7 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.14.6 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.14.5 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.14.4 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.14.3 lib/kontena/cli/grids/env_command.rb
kontena-cli-0.14.2 lib/kontena/cli/grids/env_command.rb