kontena-cli 0.16.0.pre6 → 0.16.0.pre7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35b0390bffba7709f3efa1c42838fa47483991e5
4
- data.tar.gz: 1dc946fc0f3b3e498df9b3a8a766edf7d38ca0ed
3
+ metadata.gz: 4d4aed1a465c25c662ace1bc38e6de0a8a6ccdca
4
+ data.tar.gz: c000e53d82c7aa42fe5d12a187dcdaa39f6d75e3
5
5
  SHA512:
6
- metadata.gz: 4bf3bda5f481fb4648465cb0fb687fc59341557bf94c78dbb20773fa9fc7ff889c891cab3063f81100a5f00986fd1cebe2847914c1c34f00962563cba2d59101
7
- data.tar.gz: a3c18982f577d7cdc29d08d93c963a41414dbc770af349d97cc43f7d2c434f2958c5bade13ef8e6768073de63cebd87e193ebff84dd0ff11f4beac616c5d1389
6
+ metadata.gz: 34c99fe148e3d789cf87462b22dd33f1f74f9cb91c5bffd092854d8967add751307d20d39f196a8aa78dcb6aaa785eb2e01f7c9bef55793276dbacc1285c1828
7
+ data.tar.gz: 911f92be23c389ef095ddb579acd3f778d275eda7073be1422fb2404bf072b8e0d3e7cee7b32060f16a63cc2e1fc2004e0a49bc4853cfdbb978cd9da0479d3d1
data/.dockerignore ADDED
@@ -0,0 +1,5 @@
1
+ .git
2
+ .bundle
3
+ vendor
4
+ omnibus
5
+ examples
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.16.0.pre6
1
+ 0.16.0.pre7
data/bin/kontena CHANGED
@@ -16,17 +16,17 @@ begin
16
16
  Kontena::MainCommand.run
17
17
  rescue Excon::Errors::SocketError => exc
18
18
  if exc.message.include?('Unable to verify certificate')
19
- $stderr.puts "The server uses a certificate signed by an unknown authority.".colorize(:red)
20
- $stderr.puts "You can trust this server by copying server CA pem file to: #{"~/.kontena/certs/<hostname>.pem".colorize(:light_black)}"
21
- $stderr.puts "Protip: you can bypass the certificate check by setting #{'SSL_IGNORE_ERRORS=true'.colorize(:yellow)} env variable, but any data you send to the server could be intercepted by others."
22
- exit(1)
19
+ $stderr.puts " [#{Kontena.pastel.red('error')}] The server uses a certificate signed by an unknown authority."
20
+ $stderr.puts " You can trust this server by copying server CA pem file to: #{Kontena.pastel.yellow("~/.kontena/certs/<hostname>.pem")}"
21
+ $stderr.puts " Protip: you can bypass the certificate check by setting #{Kontena.pastel.yellow('SSL_IGNORE_ERRORS=true')} env variable, but any data you send to the server could be intercepted by others."
22
+ abort
23
23
  else
24
24
  abort(exc.message)
25
25
  end
26
26
  rescue Kontena::Errors::StandardError => exc
27
27
  raise exc if ENV['DEBUG']
28
28
  puts " [#{Kontena.pastel.red('error')}] #{exc.message}"
29
- exit 1
29
+ abort
30
30
  rescue => exc
31
31
  raise exc if ENV['DEBUG']
32
32
  $stderr.puts " [#{Kontena.pastel.red('error')}] #{exc.message}"
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
17
  spec.require_paths = ["lib"]
18
18
 
19
- spec.add_runtime_dependency 'kontena-cli', '~> 0.14', '>= 0.14.0'
19
+ spec.add_runtime_dependency 'kontena-cli', '>= 0.16.0.pre2'
20
20
  spec.add_development_dependency "bundler", "~> 1.11"
21
21
  spec.add_development_dependency "rake", "~> 10.0"
22
22
  end
@@ -11,9 +11,6 @@ module Kontena::Cli::Apps
11
11
 
12
12
  option ['-f', '--file'], 'FILE', 'Specify an alternate Kontena compose file', attribute_name: :filename, default: 'kontena.yml'
13
13
  option ['-p', '--project-name'], 'NAME', 'Specify an alternate project name (default: directory name)'
14
- option ["-l", "--lines"], "LINES", "How many lines to show", default: '100'
15
- option "--since", "SINCE", "Show logs since given timestamp"
16
- option ["-t", "--tail"], :flag, "Tail (follow) logs", default: false
17
14
  parameter "[SERVICE] ...", "Show only specified service logs"
18
15
 
19
16
  def execute
@@ -30,34 +27,11 @@ module Kontena::Cli::Apps
30
27
  query_services = services.map{|service_name, opts| prefixed_name(service_name)}.join ','
31
28
  query_params = {
32
29
  services: query_services,
33
- limit: lines,
34
30
  }
35
- query_params[:since] = since if since
36
31
 
37
- if tail?
38
- tail_logs(services, query_params)
39
- else
40
- show_logs(services, query_params)
41
- end
42
- end
43
-
44
- def tail_logs(services, query_params)
45
- stream_logs("grids/#{current_grid}/container_logs", query_params) do |log|
32
+ show_logs("grids/#{current_grid}/container_logs", query_params) do |log|
46
33
  show_log(log)
47
34
  end
48
35
  end
49
-
50
- def show_logs(services, query_params)
51
- result = client(token).get("grids/#{current_grid}/container_logs", query_params)
52
- result['logs'].each do |log|
53
- show_log(log)
54
- end
55
- end
56
-
57
- def show_log(log)
58
- color = color_for_container(log['name'])
59
- prefix = "#{log['created_at']} #{log['name']}:".colorize(color)
60
- puts "#{prefix} #{log['data']}"
61
- end
62
36
  end
63
37
  end
@@ -10,10 +10,6 @@ module Kontena
10
10
  module Cli
11
11
  module Common
12
12
 
13
- def pastel
14
- ::Kontena.pastel
15
- end
16
-
17
13
  def logger
18
14
  return @logger if @logger
19
15
  @logger = Logger.new(STDOUT)
@@ -77,7 +73,7 @@ module Kontena
77
73
  # Only show spinner when in verbose mode
78
74
  def vspinner(msg, &block)
79
75
  return vfakespinner(msg) unless block_given?
80
-
76
+
81
77
  if running_verbose?
82
78
  spinner(msg, &block)
83
79
  else
@@ -1,10 +1,12 @@
1
1
  require_relative 'containers/exec_command'
2
2
  require_relative 'containers/inspect_command'
3
+ require_relative 'containers/logs_command'
3
4
 
4
5
  class Kontena::Cli::ContainerCommand < Kontena::Command
5
6
 
6
7
  subcommand "exec", "Execute command inside a container", Kontena::Cli::Containers::ExecCommand
7
8
  subcommand "inspect", "Inspect the container", Kontena::Cli::Containers::InspectCommand
9
+ subcommand "logs", "Show container logs", Kontena::Cli::Containers::LogsCommand
8
10
 
9
11
  def execute
10
12
  end
@@ -0,0 +1,22 @@
1
+ require_relative '../grid_options'
2
+ require_relative '../helpers/log_helper'
3
+
4
+ module Kontena::Cli::Containers
5
+ class LogsCommand < Clamp::Command
6
+ include Kontena::Cli::Common
7
+ include Kontena::Cli::GridOptions
8
+ include Kontena::Cli::Helpers::LogHelper
9
+
10
+ parameter "CONTAINER_ID", "Container id"
11
+
12
+ def execute
13
+ require_api_url
14
+
15
+ service_name = container_id.match(/(.+)-(\d+)/)[1] rescue nil
16
+
17
+ show_logs("containers/#{current_grid}/#{service_name}/#{container_id}/logs") do |log|
18
+ show_log(log)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -7,7 +7,6 @@ module Kontena::Cli::Grids
7
7
  host = ENV['KONTENA_URL'] || self.current_master['url']
8
8
  puts "#{grid['name']}:"
9
9
  puts " uri: #{host.sub('http', 'ws')}"
10
- puts " token: #{grid['token']}"
11
10
  root_dir = grid['engine_root_dir']
12
11
  nodes = client(require_token).get("grids/#{grid['name']}/nodes")
13
12
  nodes = nodes['nodes'].select{|n| n['connected'] == true }
@@ -11,21 +11,20 @@ module Kontena::Cli::Grids
11
11
  option "--silent", :flag, "Reduce output verbosity"
12
12
  option "--token", "[TOKEN]", "Set grid token"
13
13
 
14
- def execute
15
- require_api_url
14
+ requires_current_master_token
16
15
 
17
- token = require_token
16
+ def execute
18
17
  payload = {
19
18
  name: name
20
19
  }
21
- payload[:token] = token if token
20
+ payload[:token] = self.token if self.token
22
21
  payload[:initial_size] = initial_size if initial_size
23
22
  grid = nil
24
23
  if initial_size == 1
25
24
  warning "Option --initial-size=1 is only recommended for test/dev usage" unless running_silent?
26
25
  end
27
26
  spinner "Creating #{pastel.cyan(name)} grid " do
28
- grid = client(token).post('grids', payload)
27
+ grid = client.post('grids', payload)
29
28
  end
30
29
  if grid
31
30
  spinner "Switching scope to #{pastel.cyan(name)} grid " do
@@ -5,18 +5,10 @@ module Kontena::Cli::Grids
5
5
  include Kontena::Cli::Common
6
6
  include Kontena::Cli::Helpers::LogHelper
7
7
 
8
- option ["-t", "--tail"], :flag, "Tail (follow) logs", default: false
9
- option "--lines", "LINES", "Number of lines to show from the end of the logs"
10
- option "--since", "SINCE", "Show logs since given timestamp"
11
8
  option "--node", "NODE", "Filter by node name", multivalued: true
12
9
  option "--service", "SERVICE", "Filter by service name", multivalued: true
13
10
  option ["-c", "--container"], "CONTAINER", "Filter by container", multivalued: true
14
11
 
15
- # @return [String]
16
- def token
17
- @token ||= require_token
18
- end
19
-
20
12
  def execute
21
13
  require_api_url
22
14
 
@@ -24,35 +16,21 @@ module Kontena::Cli::Grids
24
16
  query_params[:nodes] = node_list.join(",") unless node_list.empty?
25
17
  query_params[:services] = service_list.join(",") unless service_list.empty?
26
18
  query_params[:containers] = container_list.join(",") unless container_list.empty?
27
- query_params[:limit] = lines if lines
28
- query_params[:since] = since if since
29
19
 
30
- if tail?
31
- tail_logs(query_params)
32
- else
33
- list_logs(query_params)
20
+ show_logs("grids/#{current_grid}/container_logs", query_params) do |log|
21
+ show_log(log)
34
22
  end
35
23
  end
36
24
 
37
- def list_logs(query_params)
38
- result = client(token).get("grids/#{current_grid}/container_logs", query_params)
39
- result['logs'].each do |log|
40
- color = color_for_container(log['name'])
41
- prefix = ""
42
- prefix << "#{log['created_at']} "
43
- prefix << "#{log['name']}:"
44
- prefix = prefix.colorize(color)
45
- puts "#{prefix} #{log['data']}"
25
+ def show_log(log)
26
+ color = color_for_container(log['name'])
27
+ if tail?
28
+ prefix = "#{log['name']} |"
29
+ else
30
+ prefix = "#{log['created_at']} #{log['name']}:"
46
31
  end
47
- end
48
32
 
49
- # @param [String] token
50
- # @param [Hash] query_params
51
- def tail_logs(query_params)
52
- stream_logs("grids/#{current_grid}/container_logs", query_params) do |log|
53
- color = color_for_container(log['name'])
54
- puts "#{log['name'].colorize(color)} | #{log['data']}"
55
- end
33
+ puts "#{prefix.colorize(color)} #{log['data']}"
56
34
  end
57
35
  end
58
36
  end
@@ -7,13 +7,19 @@ module Kontena::Cli::Grids
7
7
 
8
8
  parameter "NAME", "Grid name"
9
9
 
10
+ option '--token', :flag, 'Just output grid token'
11
+
10
12
  def execute
11
13
  require_api_url
12
14
 
13
15
  grid = find_grid_by_name(name)
14
16
  exit_with_error("Grid not found") unless grid
15
17
 
16
- print_grid(grid)
18
+ if self.token?
19
+ puts grid['token']
20
+ else
21
+ print_grid(grid)
22
+ end
17
23
  end
18
24
  end
19
25
  end
@@ -1,9 +1,46 @@
1
1
  module Kontena::Cli::Helpers
2
2
  module LogHelper
3
3
 
4
+ def self.included(base)
5
+ if base.respond_to?(:option)
6
+ base.option ["-t", "--tail"], :flag, "Tail (follow) logs", default: false
7
+ base.option "--lines", "LINES", "Number of lines to show from the end of the logs", default: 100 do |s|
8
+ Integer(s)
9
+ end
10
+ base.option "--since", "SINCE", "Show logs since given timestamp"
11
+ end
12
+ end
13
+
14
+ # @return [String]
15
+ def token
16
+ @token ||= require_token
17
+ end
18
+
19
+ def show_logs(url, query_params = { }, &block)
20
+ if tail?
21
+ stream_logs(url, query_params, &block)
22
+ else
23
+ get_logs(url, query_params, &block)
24
+ end
25
+ end
26
+
27
+ def get_logs(url, query_params)
28
+ query_params[:limit] = lines if lines
29
+ query_params[:since] = since if since
30
+
31
+ result = client(token).get(url, query_params)
32
+ result['logs'].each do |log|
33
+ yield log
34
+ end
35
+ end
36
+
4
37
  # @param [String] url
5
38
  # @param [Hash] query_params
6
39
  def stream_logs(url, query_params)
40
+ query_params[:limit] = lines if lines
41
+ query_params[:since] = since if since
42
+ query_params[:follow] = 1
43
+
7
44
  last_seen = nil
8
45
  streamer = lambda do |chunk, remaining_bytes, total_bytes|
9
46
  log = buffered_log_json(chunk)
@@ -14,7 +51,6 @@ module Kontena::Cli::Helpers
14
51
  end
15
52
 
16
53
  begin
17
- query_params[:follow] = 1
18
54
  query_params[:from] = last_seen if last_seen
19
55
  result = client(token).get_stream(url, streamer, query_params)
20
56
  rescue => exc
@@ -44,6 +80,13 @@ module Kontena::Cli::Helpers
44
80
  end
45
81
  end
46
82
 
83
+ def show_log(log)
84
+ color = color_for_container(log['name'])
85
+ prefix = "#{log['created_at']} #{log['name']}:"
86
+
87
+ puts "#{prefix.colorize(color)} #{log['data']}"
88
+ end
89
+
47
90
  # @param [String] container_id
48
91
  # @return [Symbol]
49
92
  def color_for_container(container_id)
@@ -9,70 +9,25 @@ module Kontena::Cli::Services
9
9
  include ServicesHelper
10
10
 
11
11
  parameter "NAME", "Service name"
12
- option ["-t", "--tail"], :flag, "Tail (follow) logs", default: false
13
- option ["-l", "--lines"], "LINES", "How many lines to show", default: '100'
14
- option "--since", "SINCE", "Show logs since given timestamp"
15
12
  option ["-i", "--instance"], "INSTANCE", "Show only given instance specific logs"
16
-
13
+
17
14
  def execute
18
15
  require_api_url
19
- token = require_token
20
-
21
16
 
22
17
  query_params = {}
23
- query_params[:limit] = lines if lines
24
- query_params[:since] = since if since
25
18
  query_params[:container] = "#{name}-#{instance}" if instance
26
19
 
27
- if tail?
28
- @buffer = ''
29
- query_params[:follow] = 1
30
- stream_logs(token, query_params)
31
- else
32
- list_logs(token, query_params)
20
+ show_logs("services/#{current_grid}/#{name}/container_logs", query_params) do |log|
21
+ show_log(log)
33
22
  end
34
-
35
23
  end
36
24
 
37
- def render_log_line(log)
25
+ def show_log(log)
38
26
  color = color_for_container(log['name'])
39
27
  instance_number = log['name'].match(/^.+-(\d+)$/)[1]
40
28
  name = instance_number.nil? ? log['name'] : instance_number
41
29
  prefix = "#{log['created_at']} [#{name}]:".colorize(color)
42
30
  puts "#{prefix} #{log['data']}"
43
31
  end
44
-
45
- def list_logs(token, query_params)
46
- result = client(token).get("services/#{current_grid}/#{name}/container_logs", query_params)
47
- result['logs'].each do |log|
48
- render_log_line(log)
49
- end
50
- end
51
-
52
- # @param [String] token
53
- # @param [Hash] query_params
54
- def stream_logs(token, query_params)
55
- last_seen = nil
56
- streamer = lambda do |chunk, remaining_bytes, total_bytes|
57
- log = buffered_log_json(chunk)
58
- if log
59
- last_seen = log['id']
60
- render_log_line(log)
61
- end
62
- end
63
-
64
- begin
65
- query_params[:follow] = true
66
- if last_seen
67
- query_params[:from] = last_seen
68
- end
69
- result = client(token).get_stream(
70
- "services/#{current_grid}/#{name}/container_logs", streamer, query_params
71
- )
72
- rescue => exc
73
- retry if exc.cause.is_a?(EOFError) # Excon wraps the EOFerror into SocketError
74
- raise
75
- end
76
- end
77
32
  end
78
33
  end
@@ -39,7 +39,7 @@ module Kontena::Cli::Services
39
39
  elsif container['status'] == 'killed'
40
40
  color = :red
41
41
  elsif container['status'] == 'stopped'
42
- color = :gray
42
+ color = :bright_black
43
43
  else
44
44
  color = :yellow
45
45
  end
@@ -4,6 +4,9 @@ module Kontena
4
4
  class PluginManager
5
5
  include Singleton
6
6
 
7
+ CLI_GEM = 'kontena-cli'.freeze
8
+ MIN_CLI_VERSION = '0.15.99'.freeze
9
+
7
10
  attr_reader :plugins
8
11
 
9
12
  def initialize
@@ -17,10 +20,16 @@ module Kontena
17
20
  plugin = File.join(spec.gem_dir, require_path, 'kontena_cli_plugin.rb')
18
21
  if File.exist?(plugin) && !@plugins.find{ |p| p.name == spec.name }
19
22
  begin
20
- load(plugin)
21
- @plugins << spec
23
+ if spec_has_valid_dependency?(spec)
24
+ load(plugin)
25
+ @plugins << spec
26
+ else
27
+ plugin_name = spec.name.sub('kontena-plugin-', '')
28
+ STDERR.puts " [#{Kontena.pastel.red('error')}] Plugin #{Kontena.pastel.cyan(plugin_name)} (#{spec.version}) is not compatible with the current cli version."
29
+ STDERR.puts " To update plugin, run 'kontena plugin install #{plugin_name}'"
30
+ end
22
31
  rescue LoadError => exc
23
- STDERR.puts "failed to load plugin: #{spec.name}"
32
+ STDERR.puts " [#{Kontena.pastel.red('error')}] Failed to load plugin: #{spec.name}"
24
33
  if ENV['DEBUG']
25
34
  STDERR.puts exc.message
26
35
  STDERR.puts exc.backtrace.join("\n")
@@ -34,5 +43,14 @@ module Kontena
34
43
  rescue => exc
35
44
  STDERR.puts exc.message
36
45
  end
46
+
47
+ # @param [Gem::Specification] spec
48
+ # @return [Boolean]
49
+ def spec_has_valid_dependency?(spec)
50
+ kontena_cli = spec.runtime_dependencies.find{ |d| d.name == CLI_GEM }
51
+ !kontena_cli.match?(CLI_GEM, MIN_CLI_VERSION)
52
+ rescue
53
+ false
54
+ end
37
55
  end
38
56
  end
@@ -18,8 +18,8 @@ describe Kontena::Cli::Apps::LogsCommand do
18
18
  end
19
19
 
20
20
  let(:current_grid) do
21
- 'test-grid'
22
- end
21
+ 'test-grid'
22
+ end
23
23
 
24
24
  let(:service_prefix) do
25
25
  'test'
@@ -94,7 +94,7 @@ end
94
94
  it "shows all service logs" do
95
95
  expect(client).to receive(:get).with('grids/test-grid/container_logs', {
96
96
  services: 'test-wordpress,test-mysql',
97
- limit: '100',
97
+ limit: 100,
98
98
  }) { { 'logs' => logs } }
99
99
 
100
100
  subject.run([])
@@ -107,7 +107,7 @@ end
107
107
 
108
108
  expect(client).to receive(:get).with('grids/test-grid/container_logs', {
109
109
  services: 'test-mysql',
110
- limit: '100',
110
+ limit: 100,
111
111
  }) { { 'logs' => mysql_logs } }
112
112
 
113
113
  subject.run(["mysql"])
@@ -121,7 +121,7 @@ end
121
121
 
122
122
  expect(client).to receive(:get).with('grids/test-grid/container_logs', {
123
123
  services: 'test-wordpress,test-mysql',
124
- limit: '100',
124
+ limit: 100,
125
125
  since: since,
126
126
  }) { { 'logs' => since_logs } }
127
127
 
@@ -0,0 +1,53 @@
1
+ require_relative "../../../spec_helper"
2
+ require 'kontena/cli/grid_options'
3
+ require "kontena/cli/containers/logs_command"
4
+
5
+ describe Kontena::Cli::Containers::LogsCommand do
6
+ include ClientHelpers
7
+
8
+ context "for a single container with logs" do
9
+ let(:logs) do
10
+ [
11
+ {
12
+ 'id' => '57cff2e8cfee65c8b6efc8bd',
13
+ 'name' => 'test-mysql-1',
14
+ 'created_at' => '2016-09-07T15:19:04.362690',
15
+ 'data' => "mysql log message 1",
16
+ },
17
+ {
18
+ 'id' => '57cff2e8cfee65c8b6efc8be',
19
+ 'name' => 'test-mysql-1',
20
+ 'created_at' => '2016-09-07T15:19:04.500000',
21
+ 'data' => "mysql log message 2",
22
+ },
23
+ {
24
+ 'id' => '57cff2e8cfee65c8b6efc8c1',
25
+ 'name' => 'test-mysql-1',
26
+ 'created_at' => '2016-09-07T15:19:06.100000',
27
+ 'data' => "mysql log message 3",
28
+ },
29
+ ]
30
+ end
31
+
32
+ before(:each) do
33
+ Kontena.pastel.resolver.color.disable!
34
+ end
35
+
36
+ it "shows all logs" do
37
+ allow(client).to receive(:get).with('containers/test-grid/test-mysql/test-mysql-1/logs', {
38
+ limit: 100,
39
+ }) { { 'logs' => logs } }
40
+
41
+ expect { subject.run(['test-mysql-1']) }.to output(<<LOGS
42
+ 2016-09-07T15:19:04.362690 test-mysql-1: mysql log message 1
43
+ 2016-09-07T15:19:04.500000 test-mysql-1: mysql log message 2
44
+ 2016-09-07T15:19:06.100000 test-mysql-1: mysql log message 3
45
+ LOGS
46
+ ).to_stdout
47
+ end
48
+
49
+ it "errors for an invalid --lines" do
50
+ expect { subject.run(["--lines=invalid", "test-mysql-1"]) }.to raise_error(Clamp::UsageError, "option '--lines': invalid value for Integer(): \"invalid\"")
51
+ end
52
+ end
53
+ end
@@ -19,4 +19,46 @@ describe Kontena::PluginManager do
19
19
  }.to raise_error(Clamp::HelpWanted)
20
20
  end
21
21
  end
22
+
23
+ describe 'spec_has_valid_dependency?' do
24
+ before(:each) do
25
+ stub_const('Kontena::PluginManager::MIN_CLI_VERSION', '0.15.99999')
26
+ end
27
+
28
+ it 'returns true if spec dependency > than MIN_CLI_VERSION' do
29
+ spec = Gem::Specification.new do |s|
30
+ s.name = 'kontena-plugin-foo'
31
+ s.version = '0.1.0'
32
+ s.add_runtime_dependency 'kontena-cli', '>= 0.16.0'
33
+ end
34
+ expect(subject.spec_has_valid_dependency?(spec)).to be_truthy
35
+ end
36
+
37
+ it 'returns true if spec dependency > than MIN_CLI_VERSION and is prerelease' do
38
+ spec = Gem::Specification.new do |s|
39
+ s.name = 'kontena-plugin-foo'
40
+ s.version = '0.1.0'
41
+ s.add_runtime_dependency 'kontena-cli', '>= 0.16.0.pre2'
42
+ end
43
+ expect(subject.spec_has_valid_dependency?(spec)).to be_truthy
44
+ end
45
+
46
+ it 'returns false if spec dependency < than MIN_CLI_VERSION' do
47
+ spec = Gem::Specification.new do |s|
48
+ s.name = 'kontena-plugin-foo'
49
+ s.version = '0.1.0'
50
+ s.add_runtime_dependency 'kontena-cli', '>= 0.15.0'
51
+ end
52
+ expect(subject.spec_has_valid_dependency?(spec)).to be_falsey
53
+ end
54
+
55
+ it 'returns false if spec dependency < than MIN_CLI_VERSION and is prerelease' do
56
+ spec = Gem::Specification.new do |s|
57
+ s.name = 'kontena-plugin-foo'
58
+ s.version = '0.1.0'
59
+ s.add_runtime_dependency 'kontena-cli', '>= 0.15.0.beta1'
60
+ end
61
+ expect(subject.spec_has_valid_dependency?(spec)).to be_falsey
62
+ end
63
+ end
22
64
  end
data/spec/spec_helper.rb CHANGED
@@ -11,6 +11,7 @@ begin
11
11
  rescue LoadError
12
12
  end
13
13
 
14
+ require 'stringio'
14
15
  require 'clamp'
15
16
  require 'ruby_dig'
16
17
  require 'kontena_cli'
@@ -30,7 +31,7 @@ RSpec.configure do |config|
30
31
  allow(ENV).to receive(:[]).with('DEBUG').and_call_original
31
32
  Kontena::Cli::Config.reset_instance
32
33
  end
33
-
34
+
34
35
  config.after(:each) do
35
36
  RSpec::Mocks.space.proxy_for(File).reset
36
37
  RSpec::Mocks.space.proxy_for(Kontena::Cli::Config).reset
@@ -44,6 +45,14 @@ RSpec.configure do |config|
44
45
  puts "Got SystemExit: #{$!.message} - Exit code: #{$!.status}"
45
46
  end
46
47
  end
48
+
49
+ config.before(:each) do
50
+ $stdout = StringIO.new
51
+ end
52
+
53
+ config.after(:each) do
54
+ $stdout = STDOUT
55
+ end
47
56
  end
48
57
 
49
58
  require_relative 'support/client_helpers'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kontena-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0.pre6
4
+ version: 0.16.0.pre7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kontena, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-07 00:00:00.000000000 Z
11
+ date: 2016-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -186,6 +186,7 @@ executables:
186
186
  extensions: []
187
187
  extra_rdoc_files: []
188
188
  files:
189
+ - ".dockerignore"
189
190
  - ".gitignore"
190
191
  - Dockerfile
191
192
  - Gemfile
@@ -264,6 +265,7 @@ files:
264
265
  - lib/kontena/cli/containers/containers_helper.rb
265
266
  - lib/kontena/cli/containers/exec_command.rb
266
267
  - lib/kontena/cli/containers/inspect_command.rb
268
+ - lib/kontena/cli/containers/logs_command.rb
267
269
  - lib/kontena/cli/etcd/common.rb
268
270
  - lib/kontena/cli/etcd/get_command.rb
269
271
  - lib/kontena/cli/etcd/list_command.rb
@@ -450,6 +452,7 @@ files:
450
452
  - spec/kontena/cli/cloud/logout_command_spec.rb
451
453
  - spec/kontena/cli/common_spec.rb
452
454
  - spec/kontena/cli/containers/containers_helper_spec.rb
455
+ - spec/kontena/cli/containers/logs_command_spec.rb
453
456
  - spec/kontena/cli/grids/trusted_subnets/add_command_spec.rb
454
457
  - spec/kontena/cli/grids/trusted_subnets/list_command_spec.rb
455
458
  - spec/kontena/cli/grids/trusted_subnets/remove_command_spec.rb
@@ -541,6 +544,7 @@ test_files:
541
544
  - spec/kontena/cli/cloud/logout_command_spec.rb
542
545
  - spec/kontena/cli/common_spec.rb
543
546
  - spec/kontena/cli/containers/containers_helper_spec.rb
547
+ - spec/kontena/cli/containers/logs_command_spec.rb
544
548
  - spec/kontena/cli/grids/trusted_subnets/add_command_spec.rb
545
549
  - spec/kontena/cli/grids/trusted_subnets/list_command_spec.rb
546
550
  - spec/kontena/cli/grids/trusted_subnets/remove_command_spec.rb