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
kontena-cli-1.4.0.pre1 lib/kontena/cli/whoami_command.rb
kontena-cli-1.3.4 lib/kontena/cli/whoami_command.rb
kontena-cli-1.3.4.rc1 lib/kontena/cli/whoami_command.rb
kontena-cli-1.3.3 lib/kontena/cli/whoami_command.rb
kontena-cli-1.3.3.rc1 lib/kontena/cli/whoami_command.rb
kontena-cli-1.3.2 lib/kontena/cli/whoami_command.rb
kontena-cli-1.3.2.rc2 lib/kontena/cli/whoami_command.rb
kontena-cli-1.3.2.rc1 lib/kontena/cli/whoami_command.rb
kontena-cli-1.3.1 lib/kontena/cli/whoami_command.rb
kontena-cli-1.3.1.rc2 lib/kontena/cli/whoami_command.rb
kontena-cli-1.3.1.rc1 lib/kontena/cli/whoami_command.rb
kontena-cli-1.3.0 lib/kontena/cli/whoami_command.rb
kontena-cli-1.3.0.rc4 lib/kontena/cli/whoami_command.rb
kontena-cli-1.3.0.rc3 lib/kontena/cli/whoami_command.rb
kontena-cli-1.3.0.rc2 lib/kontena/cli/whoami_command.rb
kontena-cli-1.3.0.rc1 lib/kontena/cli/whoami_command.rb
kontena-cli-1.3.0.pre2 lib/kontena/cli/whoami_command.rb
kontena-cli-1.3.0.pre1 lib/kontena/cli/whoami_command.rb
kontena-cli-1.2.2 lib/kontena/cli/whoami_command.rb
kontena-cli-1.2.2.rc2 lib/kontena/cli/whoami_command.rb