Sha256: 3ab3bed80259f045d7b1447549b0fe0a8046871ac3672bcb06820b19697ce5b6

Contents?: true

Size: 838 Bytes

Versions: 5

Compression:

Stored size: 838 Bytes

Contents

module Kontena::Cli::Nodes
  class EnvCommand < Kontena::Command
    include Kontena::Cli::Common
    include Kontena::Cli::GridOptions

    requires_current_master
    requires_current_master_token
    requires_current_grid

    parameter "NAME", "Node name"
    option ['--token'], :flag, 'Only show token', default: false

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

    def execute
      token_node = client.get("nodes/#{current_grid}/#{name}/token")

      unless token_node['token']
        exit_with_error "Node #{name} was not created with a node token. Use `kontena grid env` instead"
      end

      if self.token?
        puts token_node['token']
      else
        puts "KONTENA_URI=#{grid_uri}"
        puts "KONTENA_NODE_TOKEN=#{token_node['token']}"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kontena-cli-1.4.0.pre5 lib/kontena/cli/nodes/env_command.rb
kontena-cli-1.4.0.pre4 lib/kontena/cli/nodes/env_command.rb
kontena-cli-1.4.0.pre3 lib/kontena/cli/nodes/env_command.rb
kontena-cli-1.4.0.pre2 lib/kontena/cli/nodes/env_command.rb
kontena-cli-1.4.0.pre1 lib/kontena/cli/nodes/env_command.rb