Sha256: 9c743e7476d29ab3e8c88ca0483857615b3bc41dba1b3bbc049880866cab7883

Contents?: true

Size: 1.12 KB

Versions: 158

Compression:

Stored size: 1.12 KB

Contents

class Kontena::Cli::WhoamiCommand < Kontena::Command
  include Kontena::Cli::Common

  option '--bash-completion-path', :flag, 'Show bash completion path', hidden: true
  option '--token', :flag, 'Show current master token', hidden: true

  def execute
    if bash_completion_path?
      puts File.realpath(File.join(__dir__, '../scripts/init'))
      exit 0
    end

    if self.token?
      if config.current_master && config.current_master.token
        puts config.current_master.token.access_token
        exit 0
      else
        exit 1
      end
    end

    require_api_url
    puts "Master: #{ENV['KONTENA_URL'] || self.current_master['name']}"
    puts "URL: #{ENV['KONTENA_URL'] || api_url}"
    puts "Grid: #{ENV['KONTENA_GRID'] || current_grid}"
    unless ENV['KONTENA_URL']
      if current_master['username']
        puts "User: #{current_master['username']}"
      else # In case local storage doesn't have the user email yet
        token = require_token
        user = client.get('user')
        puts "User: #{user['email']}"
        current_master['username'] = user['email']
        config.write
      end
    end
  end
end

Version data entries

158 entries across 158 versions & 2 rubygems

Version Path
krates-1.7.11 lib/kontena/cli/whoami_command.rb
krates-1.7.10 lib/kontena/cli/whoami_command.rb
krates-1.7.9 lib/kontena/cli/whoami_command.rb
krates-1.7.8 lib/kontena/cli/whoami_command.rb
krates-1.7.7 lib/kontena/cli/whoami_command.rb
krates-1.7.6 lib/kontena/cli/whoami_command.rb
krates-1.7.5 lib/kontena/cli/whoami_command.rb
krates-1.7.4 lib/kontena/cli/whoami_command.rb
krates-1.7.3 lib/kontena/cli/whoami_command.rb
krates-1.7.2 lib/kontena/cli/whoami_command.rb
krates-1.7.1 lib/kontena/cli/whoami_command.rb
krates-1.7.0 lib/kontena/cli/whoami_command.rb
krates-1.6.9 lib/kontena/cli/whoami_command.rb
krates-1.6.8 lib/kontena/cli/whoami_command.rb
krates-1.6.7 lib/kontena/cli/whoami_command.rb
krates-1.6.6 lib/kontena/cli/whoami_command.rb
krates-1.6.5 lib/kontena/cli/whoami_command.rb
krates-1.6.4 lib/kontena/cli/whoami_command.rb
krates-1.6.3 lib/kontena/cli/whoami_command.rb
krates-1.6.2 lib/kontena/cli/whoami_command.rb