class Kontena::Cli::Grids::EnvCommand

Public Instance Methods

execute() click to toggle source
# File lib/kontena/cli/grids/env_command.rb, line 11
def execute
  require_api_url

  name_or_current = name.nil? ? current_grid : name

  if name_or_current.nil?
    exit_with_error "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)
    exit_with_error("Grid not found") unless grid

    grid_uri = self.current_master['url'].sub('http', 'ws')


    prefix = export? ? 'export ' : ''

    puts "#{prefix}KONTENA_URI=#{grid_uri}"
    puts "#{prefix}KONTENA_TOKEN=#{grid['token']}"
  end
end