Sha256: bed9f0219a76e874b2c9c9014121d9e5dd044e46bfb6fd17006f2bd00a9e9e46

Contents?: true

Size: 812 Bytes

Versions: 14

Compression:

Stored size: 812 Bytes

Contents

require_relative '../grid_options'
require_relative './containers_helper'

module Kontena::Cli::Containers
  class ExecCommand < Clamp::Command
    include Kontena::Cli::Common
    include Kontena::Cli::GridOptions
    include ContainersHelper

    parameter "CONTAINER_ID", "Container id"
    parameter "CMD ...", "Command"

    def execute
      require_api_url
      token = require_token

      cmd = build_command(cmd_list)
      payload = {cmd: ["sh", "-c", cmd]}

      service_name = container_id.match(/(.+)-(\d+)/)[1] rescue nil
      result = client(token).post("containers/#{current_grid}/#{service_name}/#{container_id}/exec", payload)

      puts result[0].join(" ") unless result[0].size == 0
      STDERR.puts result[1].join(" ") unless result[1].size == 0
      exit result[2]
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
kontena-cli-0.15.5 lib/kontena/cli/containers/exec_command.rb
kontena-cli-0.15.5.rc2 lib/kontena/cli/containers/exec_command.rb
kontena-cli-0.15.5.rc1 lib/kontena/cli/containers/exec_command.rb
kontena-cli-0.15.4 lib/kontena/cli/containers/exec_command.rb
kontena-cli-0.15.4.rc2 lib/kontena/cli/containers/exec_command.rb
kontena-cli-0.15.4.rc1 lib/kontena/cli/containers/exec_command.rb
kontena-cli-0.15.4.pre1 lib/kontena/cli/containers/exec_command.rb
kontena-cli-0.15.3 lib/kontena/cli/containers/exec_command.rb
kontena-cli-0.15.2 lib/kontena/cli/containers/exec_command.rb
kontena-cli-0.15.1 lib/kontena/cli/containers/exec_command.rb
kontena-cli-0.15.0 lib/kontena/cli/containers/exec_command.rb
kontena-cli-0.15.0.rc3 lib/kontena/cli/containers/exec_command.rb
kontena-cli-0.15.0.rc2 lib/kontena/cli/containers/exec_command.rb
kontena-cli-0.15.0.rc1 lib/kontena/cli/containers/exec_command.rb