Sha256: 5331cae77839f278484230b109cd4df7a9a70ddc6911fee84ad509a98d5b5bfe

Contents?: true

Size: 976 Bytes

Versions: 54

Compression:

Stored size: 976 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 get_node_token
      return client.get("nodes/#{current_grid}/#{name}/token")
    rescue Kontena::Errors::StandardError => exc
      raise unless exc.status == 404
      return nil
    end

    def execute
      unless token_node = get_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

54 entries across 54 versions & 2 rubygems

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