Sha256: 185a1b18af44921ebe81223b1ff46e37ebaf757e9c8067b12b7db02b18eb74ca

Contents?: true

Size: 1.13 KB

Versions: 34

Compression:

Stored size: 1.13 KB

Contents

require_relative 'common'

module Kontena::Cli::Master::Token
  class CurrentCommand < Kontena::Command

    include Kontena::Cli::Common
    include Common

    requires_current_master
    requires_current_master_token

    option '--token', :flag, "Only output access token"
    option '--refresh-token', :flag, "Only output refresh token"
    option '--expires-in', :flag, "Only output expires in seconds"
    option '--id', :flag, "Only output access token id"

    def execute
      if self.token?
        puts current_master.token.access_token
        return
      end

      if self.refresh_token?
        if current_master.token.refresh_token
          puts current_master.token.refresh_token
        end
        return
      end

      if self.expires_in?
        if current_master.token.expires_at.to_i > 0
          puts current_master.token.expires_at - Time.now.utc.to_i
        end
        return
      end

      if self.id?
        Kontena.run!(['master', 'token', 'show',  '--id', current_master.token.access_token])
      else
        Kontena.run!(['master', 'token', 'show',  current_master.token.access_token])
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

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