kontena-cli 1.4.3 → 1.5.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +7 -3
  3. data/Gemfile +7 -3
  4. data/README.md +1 -1
  5. data/VERSION +1 -1
  6. data/bin/kontena +1 -0
  7. data/kontena-cli.gemspec +5 -6
  8. data/lib/kontena/cli/browser_launcher.rb +61 -0
  9. data/lib/kontena/cli/certificate/authorize_command.rb +40 -16
  10. data/lib/kontena/cli/certificate/get_command.rb +1 -1
  11. data/lib/kontena/cli/cloud/login_command.rb +3 -4
  12. data/lib/kontena/cli/cloud/master/add_command.rb +1 -1
  13. data/lib/kontena/cli/cloud/master/list_command.rb +1 -1
  14. data/lib/kontena/cli/cloud/master/remove_command.rb +1 -1
  15. data/lib/kontena/cli/cloud/master/update_command.rb +1 -1
  16. data/lib/kontena/cli/common.rb +2 -2
  17. data/lib/kontena/cli/etcd_command.rb +1 -1
  18. data/lib/kontena/cli/external_registries/add_command.rb +2 -2
  19. data/lib/kontena/cli/external_registries/remove_command.rb +1 -1
  20. data/lib/kontena/cli/grids/common.rb +14 -4
  21. data/lib/kontena/cli/grids/events_command.rb +2 -2
  22. data/lib/kontena/cli/grids/list_command.rb +1 -1
  23. data/lib/kontena/cli/grids/logs_command.rb +1 -1
  24. data/lib/kontena/cli/grids/remove_command.rb +12 -10
  25. data/lib/kontena/cli/grids/trusted_subnets/add_command.rb +1 -1
  26. data/lib/kontena/cli/grids/trusted_subnets/remove_command.rb +12 -10
  27. data/lib/kontena/cli/grids/use_command.rb +1 -1
  28. data/lib/kontena/cli/helpers/log_helper.rb +1 -1
  29. data/lib/kontena/cli/logout_command.rb +1 -1
  30. data/lib/kontena/cli/master/login_command.rb +2 -3
  31. data/lib/kontena/cli/master/logout_command.rb +2 -2
  32. data/lib/kontena/cli/master/token/common.rb +2 -1
  33. data/lib/kontena/cli/master/token/create_command.rb +5 -2
  34. data/lib/kontena/cli/master/token/current_command.rb +9 -4
  35. data/lib/kontena/cli/master/token/list_command.rb +1 -1
  36. data/lib/kontena/cli/master/token/show_command.rb +11 -1
  37. data/lib/kontena/cli/master/user/invite_command.rb +1 -1
  38. data/lib/kontena/cli/master_command.rb +0 -1
  39. data/lib/kontena/cli/nodes/create_command.rb +1 -1
  40. data/lib/kontena/cli/nodes/labels/remove_command.rb +17 -3
  41. data/lib/kontena/cli/nodes/remove_command.rb +12 -10
  42. data/lib/kontena/cli/nodes/reset_token_command.rb +1 -1
  43. data/lib/kontena/cli/nodes/update_command.rb +1 -1
  44. data/lib/kontena/cli/plugin_command.rb +2 -1
  45. data/lib/kontena/cli/plugins/install_command.rb +2 -2
  46. data/lib/kontena/cli/plugins/uninstall_command.rb +19 -10
  47. data/lib/kontena/cli/plugins/upgrade_command.rb +60 -0
  48. data/lib/kontena/cli/registry/create_command.rb +1 -1
  49. data/lib/kontena/cli/registry/remove_command.rb +2 -2
  50. data/lib/kontena/cli/services/containers_command.rb +1 -1
  51. data/lib/kontena/cli/services/create_command.rb +1 -1
  52. data/lib/kontena/cli/services/deploy_command.rb +1 -1
  53. data/lib/kontena/cli/services/envs/add_command.rb +1 -1
  54. data/lib/kontena/cli/services/envs/remove_command.rb +5 -3
  55. data/lib/kontena/cli/services/link_command.rb +1 -1
  56. data/lib/kontena/cli/services/logs_command.rb +1 -1
  57. data/lib/kontena/cli/services/monitor_command.rb +1 -1
  58. data/lib/kontena/cli/services/remove_command.rb +11 -9
  59. data/lib/kontena/cli/services/restart_command.rb +1 -1
  60. data/lib/kontena/cli/services/secrets/link_command.rb +1 -1
  61. data/lib/kontena/cli/services/services_helper.rb +6 -12
  62. data/lib/kontena/cli/services/start_command.rb +5 -3
  63. data/lib/kontena/cli/services/stop_command.rb +5 -3
  64. data/lib/kontena/cli/services/unlink_command.rb +1 -1
  65. data/lib/kontena/cli/services/update_command.rb +1 -1
  66. data/lib/kontena/cli/spinner.rb +10 -10
  67. data/lib/kontena/cli/stack_command.rb +1 -0
  68. data/lib/kontena/cli/stacks/build_command.rb +6 -6
  69. data/lib/kontena/cli/stacks/deploy_command.rb +12 -10
  70. data/lib/kontena/cli/stacks/inspect_command.rb +17 -0
  71. data/lib/kontena/cli/stacks/install_command.rb +15 -4
  72. data/lib/kontena/cli/stacks/list_command.rb +2 -3
  73. data/lib/kontena/cli/stacks/logs_command.rb +1 -1
  74. data/lib/kontena/cli/stacks/monitor_command.rb +2 -2
  75. data/lib/kontena/cli/stacks/remove_command.rb +28 -19
  76. data/lib/kontena/cli/stacks/restart_command.rb +5 -4
  77. data/lib/kontena/cli/stacks/stop_command.rb +6 -5
  78. data/lib/kontena/cli/stacks/upgrade_command.rb +84 -64
  79. data/lib/kontena/cli/stacks/yaml/reader.rb +9 -4
  80. data/lib/kontena/cli/vault/remove_command.rb +7 -5
  81. data/lib/kontena/cli/vault/update_command.rb +1 -1
  82. data/lib/kontena/cli/vault/write_command.rb +1 -1
  83. data/lib/kontena/cli/volumes/remove_command.rb +6 -4
  84. data/lib/kontena/cli/vpn/create_command.rb +1 -1
  85. data/lib/kontena/cli/vpn/remove_command.rb +1 -1
  86. data/lib/kontena/client.rb +23 -14
  87. data/lib/kontena/command.rb +2 -2
  88. data/lib/kontena/debug_instrumentor.rb +11 -2
  89. data/lib/kontena/plugin_manager/common.rb +5 -2
  90. data/lib/kontena/plugin_manager/installer.rb +34 -10
  91. data/lib/kontena/scripts/completer.rb +91 -43
  92. data/lib/kontena/{cli/stacks → stacks}/change_resolver.rb +38 -16
  93. data/lib/kontena/stacks/stack_data.rb +58 -0
  94. data/lib/kontena/stacks/stack_data_set.rb +51 -0
  95. data/lib/kontena_cli.rb +1 -0
  96. data/omnibus/Gemfile.lock +32 -22
  97. data/omnibus/config/projects/kontena.rb +2 -0
  98. data/omnibus/config/software/kontena-cli.rb +6 -4
  99. data/omnibus/package-scripts/kontena/postinstall +1 -1
  100. data/omnibus/wrappers/sh/kontena +1 -1
  101. data/spec/fixtures/kontena_v3_with_registry_extends.yml +20 -0
  102. data/spec/kontena/cli/certificates/authorize_command_spec.rb +81 -0
  103. data/spec/kontena/cli/cloud/login_command_spec.rb +4 -4
  104. data/spec/kontena/cli/common_spec.rb +8 -1
  105. data/spec/kontena/cli/grids/update_command_spec.rb +13 -0
  106. data/spec/kontena/cli/master/join_command_spec.rb +1 -4
  107. data/spec/kontena/cli/master/login_command_spec.rb +4 -4
  108. data/spec/kontena/cli/master/token/create_command_spec.rb +132 -0
  109. data/spec/kontena/cli/master/token/show_command_spec.rb +90 -0
  110. data/spec/kontena/cli/nodes/labels/remove_command_spec.rb +35 -5
  111. data/spec/kontena/cli/stacks/install_command_spec.rb +16 -6
  112. data/spec/kontena/cli/stacks/remove_command_spec.rb +23 -2
  113. data/spec/kontena/cli/stacks/validate_command_spec.rb +1 -1
  114. data/spec/kontena/cli/stacks/yaml/reader_spec.rb +33 -1
  115. data/spec/kontena/client_spec.rb +38 -1
  116. data/spec/kontena/stacks/change_resolver_spec.rb +44 -0
  117. data/spec/kontena/stacks/stack_data_set_spec.rb +59 -0
  118. metadata +36 -34
  119. data/lib/kontena/cli/master/users_command.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d785a1ae86f7e7450509061ed82b9d9c6bb3e21af0104b9b2d4338150c6a6e76
4
- data.tar.gz: 78a7f31ac3116200301d56e3ad52aadb473cdfc4e341c43fe7bd8711acc9ed89
3
+ metadata.gz: 3d3147d4def0570ae7d592b83163f2a55bebcf939901adba261c18a78e3189e7
4
+ data.tar.gz: c6a3f61cfc69c56a62b1ae5e75ca45c5880937d8861a5e65c2f3074981070a44
5
5
  SHA512:
6
- metadata.gz: 6a0a5ebdc9759841bb3967110e00ad4fec841a680f9837f9e5b2a2d1515cc614e00c7eda2b5a0520c97aee5beb4f5ff4d3f52b87b9db5e6678cdbe912b34f83f
7
- data.tar.gz: cebf05eb5e1d5552459fb85b2c5bf6c23137cb59865f1ffc69d8cfd0f6f4976bdcb25b53af383da27167d9fd97b03a985acb26d7068940c8f51a31ee842ae512
6
+ metadata.gz: 7c1b25a00c0c46e046d62d530a316d77949b766c6272b8bf56685fdb6ce902c1a7ed29b527b5ab18f985fa7adac46f95e42b1c6e74b04bea7916d362490290cb
7
+ data.tar.gz: dc54b0386062eea65878e11b0339658091afbfafa5beb45241ce46507c9dd3c4889897b653557cabc520593151faa4e213fd16138d15c3a548a9b67fb31bfd85
data/Dockerfile CHANGED
@@ -1,12 +1,16 @@
1
- FROM alpine:3.5
1
+ FROM alpine:3.6
2
2
  MAINTAINER Kontena, Inc. <info@kontena.io>
3
3
 
4
- ADD https://get.docker.com/builds/Linux/x86_64/docker-1.10.3 /usr/local/bin/docker
5
4
  ARG CLI_VERSION
6
5
 
7
6
  RUN apk update && \
8
7
  apk --update add ruby ruby-json ruby-bigdecimal ruby-io-console \
9
- ca-certificates libssl1.0 openssl libstdc++ && \
8
+ curl ca-certificates libssl1.0 openssl libstdc++ && \
9
+ curl -sL https://download.docker.com/linux/static/stable/x86_64/docker-17.06.2-ce.tgz > /tmp/docker.tgz && \
10
+ cd /tmp && \
11
+ tar zxf docker.tgz && \
12
+ mv docker/docker /usr/local/bin/ && \
13
+ rm -rf /tmp/docker* && \
10
14
  chmod +x /usr/local/bin/docker
11
15
 
12
16
  RUN apk --update add --virtual build-dependencies ruby-dev build-base openssl-dev && \
data/Gemfile CHANGED
@@ -2,11 +2,15 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in kontena-cli.gemspec
4
4
  gemspec
5
- group :development, :test do
5
+
6
+ group :test do
6
7
  gem "rspec"
7
- gem 'simplecov', :require => false, :group => :test
8
8
  gem "kontena-plugin-hello", path: "./examples/kontena-plugin-hello"
9
+ gem 'simplecov', :require => false, :group => :test
10
+ gem 'webmock', '~> 3.0', require: false
11
+ end
12
+
13
+ group :development do
9
14
  gem 'pry', require: false
10
15
  gem 'pry-byebug', require: false
11
- gem 'webmock', '~> 3.0', require: false
12
16
  end
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  This is a command line tool for [Kontena](http://www.kontena.io).
5
5
 
6
6
  ## Installation
7
- > Prerequisities: [Ruby](https://www.ruby-lang.org/en/) version 2.1.0 or greater.
7
+ > Prerequisities: [Ruby](https://www.ruby-lang.org/en/) version 2.2.0 or greater.
8
8
 
9
9
  Install it yourself as:
10
10
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.3
1
+ 1.5.0.pre1
data/bin/kontena CHANGED
@@ -10,6 +10,7 @@ STDOUT.sync = true
10
10
 
11
11
  if ARGV[0] == 'complete'
12
12
  ARGV.delete_at(0)
13
+ $VERSION_WARNING_ADDED=true
13
14
  require 'kontena/scripts/completer'
14
15
  else
15
16
  ENV['DEBUG'] = "true" if ARGV.any? { |arg| arg == '-D' || arg == '--debug'}
data/kontena-cli.gemspec CHANGED
@@ -18,16 +18,15 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.required_ruby_version = ">= 2.1.0"
21
+ spec.required_ruby_version = ">= 2.2.0"
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.7"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_runtime_dependency "excon", "~> 0.49.0"
26
- spec.add_runtime_dependency "tty-prompt", "0.13.1"
27
- spec.add_runtime_dependency "clamp", "~> 1.1.0"
25
+ spec.add_runtime_dependency "excon", "0.60.0"
26
+ spec.add_runtime_dependency "tty-prompt", "0.14.0"
27
+ spec.add_runtime_dependency "clamp", "~> 1.2.1"
28
28
  spec.add_runtime_dependency "ruby_dig", "~> 0.0.2"
29
- spec.add_runtime_dependency "launchy", "~> 2.4.3"
30
- spec.add_runtime_dependency "hash_validator", "~> 0.7.1"
29
+ spec.add_runtime_dependency "hash_validator", "0.8.0"
31
30
  spec.add_runtime_dependency "retriable", "~> 2.1.0"
32
31
  spec.add_runtime_dependency "opto", "1.8.7"
33
32
  spec.add_runtime_dependency "semantic", "~> 1.5"
@@ -0,0 +1,61 @@
1
+ require 'kontena/util'
2
+
3
+ module Kontena
4
+ module Cli
5
+ class BrowserLauncher
6
+ def self.open(url)
7
+ Kontena::Cli::BrowserLauncher.new(url).launch
8
+ end
9
+
10
+ attr_reader :url
11
+
12
+ def initialize(url)
13
+ @url = url
14
+ end
15
+
16
+ def launch
17
+ system(*command)
18
+ end
19
+
20
+ def command
21
+ cmd = if Kontena.on_windows?
22
+ ['cmd', '/c', 'start', '/b', url.gsub(/&/, '^&')]
23
+ elsif RUBY_PLATFORM =~ /darwin/
24
+ ["open", url]
25
+ elsif Kontena.browserless?
26
+ raise RuntimeError, "Environment variable DISPLAY not set, assuming non-desktop session, unable to open browser. Try using '--remote' option."
27
+ else
28
+ [detect_unixlike_command, url]
29
+ end
30
+
31
+ Kontena.logger.debug { "Using %p to launch browser" % cmd }
32
+
33
+ cmd
34
+ end
35
+
36
+ def detect_unixlike_command
37
+ Kontena.logger.debug { "Assuming unix-like environment, looking for browser" }
38
+
39
+ cmd = %w(
40
+ xdg-open
41
+ sensible-browser
42
+ x-www-browser
43
+ ).find { |c| !which(c).nil? }
44
+
45
+ if cmd.nil?
46
+ if ENV['BROWSER']
47
+ cmd = which(ENV['BROWSER'])
48
+ return cmd unless cmd.nil?
49
+ end
50
+ raise RuntimeError, "Unable to launch a local browser. Try installing xdg-utils or sensible-utils package, setting BROWSER environment variable or using the --remote option"
51
+ end
52
+
53
+ cmd
54
+ end
55
+
56
+ def which(cmd)
57
+ Kontena::Util.which(cmd)
58
+ end
59
+ end
60
+ end
61
+ end
@@ -13,22 +13,36 @@ module Kontena::Cli::Certificate
13
13
  option '--type', 'AUTHORIZATION_TYPE', 'Authorization type, either tls-sni-01 or dns-01', default: 'dns-01'
14
14
  option '--linked-service', "LINKED_SERVICE", 'A service (usually LB) where the tls-sni-01 challenge certificate is bundled to'
15
15
 
16
- def execute
17
- require_api_url
18
- token = require_token
16
+ requires_current_master
17
+ requires_current_master_token
18
+ requires_current_grid
19
+
20
+ def requires_linked_service?
21
+ case type
22
+ when 'dns-01'
23
+ false
24
+ when 'http-01'
25
+ true
26
+ when 'tls-sni-01'
27
+ true
28
+ else
29
+ fail "Invalid authorization --type=#{type}"
30
+ end
31
+ end
19
32
 
20
- exit_with_error "Service link needs to be given with tls-sni-01 auth type" if self.type == 'tls-sni-01' && self.linked_service.nil?
33
+ def execute
34
+ exit_with_error "--linked-service is required with --type=#{type}" if requires_linked_service? && !self.linked_service
21
35
 
22
36
  data = {
23
37
  domain: domain,
24
38
  authorization_type: self.type
25
39
  }
26
- data['linked_service'] = service_path(self.linked_service) if self.type == 'tls-sni-01'
40
+ data[:linked_service] = service_path(self.linked_service) if self.linked_service
27
41
  retried = false
28
42
 
29
43
  response = nil
30
44
  retry_on_le_registration do
31
- response = client(token).post("grids/#{current_grid}/domain_authorizations", data)
45
+ response = client.post("grids/#{current_grid}/domain_authorizations", data)
32
46
  end
33
47
 
34
48
  case self.type
@@ -37,28 +51,38 @@ module Kontena::Cli::Certificate
37
51
  puts "Record name: #{response.dig('challenge_opts', 'record_name')}.#{domain}"
38
52
  puts "Record type: #{response.dig('challenge_opts', 'record_type')}"
39
53
  puts "Record content: #{response.dig('challenge_opts', 'record_content')}"
54
+ when 'http-01'
55
+ domain_auth = spinner "Waiting for http-01 challenge to be deployed into #{response.dig('linked_service', 'id').colorize(:cyan)} " do
56
+ wait_for_domain_auth_deployed(response)
57
+ end
58
+ if domain_auth['state'] == 'deploy_error'
59
+ exit_with_error "Linked services deploy failed. Check service events for details"
60
+ else
61
+ puts "HTTP challenge is deployed, you can now request the actual certificate"
62
+ end
40
63
  when 'tls-sni-01'
41
- state = nil
42
- spinner "Waiting for tls-sni-01 certificate to be deployed into #{response.dig('linked_service', 'id').colorize(:cyan)} " do
43
- state = wait_for_domain_auth_deployed(token, response['id'])
64
+ domain_auth = spinner "Waiting for tls-sni-01 challenge to be deployed into #{response.dig('linked_service', 'id').colorize(:cyan)} " do
65
+ wait_for_domain_auth_deployed(response)
44
66
  end
45
- if state == 'deploy_error'
46
- puts "Linked services deploy failed. Check service events for details"
67
+ if domain_auth['state'] == 'deploy_error'
68
+ exit_with_error "Linked services deploy failed. Check service events for details"
47
69
  else
48
70
  puts "TLS-SNI challenge certificate is deployed, you can now request the actual certificate"
49
71
  end
50
72
  else
51
73
  exit_with_error "Unknown authorization type: #{self.type}"
52
74
  end
53
-
54
75
  end
55
76
 
56
- def wait_for_domain_auth_deployed(token, domain_auth_id)
57
- state = nil
77
+ def wait_for_domain_auth_deployed(domain_auth)
58
78
  Timeout.timeout(300) {
59
- sleep 1 until (state = client(token).get("domain_authorizations/#{domain_auth_id}")['status']) != 'deploying'
79
+ while domain_auth['status'] == 'deploying' do
80
+ sleep 1
81
+
82
+ domain_auth = client.get("domain_authorizations/#{domain_auth['id']}")
83
+ end
84
+ return domain_auth
60
85
  }
61
- state
62
86
  end
63
87
 
64
88
  def service_path(linked_service)
@@ -24,7 +24,7 @@ module Kontena::Cli::Certificate
24
24
  response = client(token).post("certificates/#{current_grid}/certificate", data)
25
25
  puts "Certificate successfully received and stored into vault with keys:"
26
26
  response.each do |secret|
27
- puts secret.colorize(:green)
27
+ puts pastel.green(secret)
28
28
  end
29
29
  puts "Use the #{secret}_BUNDLE with Kontena loadbalancer!"
30
30
 
@@ -74,7 +74,7 @@ module Kontena::Cli::Cloud
74
74
  exit_with_error "Parsing remote login URL failed."
75
75
  end
76
76
 
77
- puts "Please visit #{verification_uri.to_s.colorize(:cyan)} and enter the code"
77
+ puts "Please visit #{pastel.cyan(verification_uri.to_s)} and enter the code"
78
78
  puts
79
79
  puts "#{auth_request_response['user_code']}"
80
80
  puts
@@ -105,7 +105,7 @@ module Kontena::Cli::Cloud
105
105
  end
106
106
 
107
107
  require_relative '../localhost_web_server'
108
- require 'launchy'
108
+ require 'kontena/cli/browser_launcher'
109
109
 
110
110
  uri = URI.parse(kontena_account.authorization_endpoint)
111
111
  uri.host ||= kontena_account.url
@@ -137,12 +137,11 @@ module Kontena::Cli::Cloud
137
137
  puts
138
138
 
139
139
  server_thread = Thread.new { Thread.main['response'] = web_server.serve_one }
140
- browser_thread = Thread.new { Launchy.open(uri.to_s) }
140
+ Kontena::Cli::BrowserLauncher.open(uri.to_s)
141
141
 
142
142
  spinner "Waiting for browser authorization response" do
143
143
  server_thread.join
144
144
  end
145
- browser_thread.join
146
145
 
147
146
  update_token(Thread.main['response'])
148
147
  end
@@ -146,7 +146,7 @@ module Kontena::Cli::Cloud::Master
146
146
  elsif self.id?
147
147
  puts response['data']['id']
148
148
  else
149
- puts "Registered master.".colorize(:green)
149
+ puts pastel.green("Registered master.")
150
150
  puts "ID: #{response['data']['id']}"
151
151
  puts "Client ID: #{response['data']['attributes']['client-id']}"
152
152
  puts "Client Secret: #{response['data']['attributes']['client-secret']}"
@@ -20,7 +20,7 @@ module Kontena::Cli::Cloud::Master
20
20
  end
21
21
 
22
22
  unless response && response.kind_of?(Hash) && response['data'].kind_of?(Array)
23
- abort "Listing masters failed".colorize(:red)
23
+ abort pastel.red("Listing masters failed")
24
24
  end
25
25
 
26
26
  return Array(response['data']) if self.return?
@@ -26,7 +26,7 @@ module Kontena::Cli::Cloud::Master
26
26
  spinner "Retrieving a list of registered masters on Kontena Cloud" do
27
27
  response = cloud_client.get('user/masters')
28
28
  unless response && response.kind_of?(Hash) && response['data'].kind_of?(Array)
29
- abort 'Listing masters failed'.colorize(:red)
29
+ abort pastel.red('Listing masters failed')
30
30
  end
31
31
  end
32
32
 
@@ -25,7 +25,7 @@ module Kontena::Cli::Cloud::Master
25
25
  def execute
26
26
  attrs = get_attributes
27
27
  unless attrs
28
- puts "Failed to obtain master credentials".colorize(:red)
28
+ puts pastel.red("Failed to obtain master credentials")
29
29
  exit 1
30
30
  end
31
31
 
@@ -154,7 +154,7 @@ module Kontena
154
154
  logger.debug { msg }
155
155
  return
156
156
  end
157
- puts " [#{ success ? 'done'.colorize(:green) : 'fail'.colorize(:red)}] #{msg}"
157
+ puts " [#{ success ? pastel.green('done') : pastel.red('fail')}] #{msg}"
158
158
  end
159
159
 
160
160
  def warning(msg)
@@ -270,7 +270,7 @@ module Kontena
270
270
  exit_with_error 'Command requires --force' unless $stdout.tty? && $stdin.tty?
271
271
  puts "Destructive command. To proceed, type \"#{name}\" or re-run this command with --force option."
272
272
 
273
- ask("Enter '#{name}' to confirm: ") == name || error("Confirmation did not match #{name}. Aborted command.")
273
+ ask("Enter '#{name}' to confirm: ") == name.to_s || error("Confirmation did not match #{name}. Aborted command.")
274
274
  end
275
275
 
276
276
  def confirm(message = 'Destructive command. You can skip this prompt by running this command with --force option. Are you sure?')
@@ -4,7 +4,7 @@ class Kontena::Cli::EtcdCommand < Kontena::Command
4
4
  subcommand "set", "Set a value on the specified key", load_subcommand('etcd/set_command')
5
5
  subcommand ["mkdir", "mk"], "Create a directory", load_subcommand('etcd/mkdir_command')
6
6
  subcommand ["list", "ls"], "List a directory", load_subcommand('etcd/list_command')
7
- subcommand "rm", "Remove a key or a directory", load_subcommand('etcd/remove_command')
7
+ subcommand ["remove", "rm"], "Remove a key or a directory", load_subcommand('etcd/remove_command')
8
8
  subcommand "health", "Check etcd health", load_subcommand('etcd/health_command')
9
9
 
10
10
  def execute
@@ -6,8 +6,8 @@ module Kontena::Cli::ExternalRegistries
6
6
  parameter '[URL]', 'Docker Registry url', default: 'https://index.docker.io/v2/'
7
7
 
8
8
  option ['-u', '--username'], 'USERNAME', 'Username', required: true
9
- option ['-e', '--email'], 'EMAIL', 'Email', required: true
10
9
  option ['-p', '--password'], 'PASSWORD', 'Password', required: true
10
+ option ['-e', '--email'], 'EMAIL', 'Email', required: false
11
11
 
12
12
  def execute
13
13
  require_api_url
@@ -17,7 +17,7 @@ module Kontena::Cli::ExternalRegistries
17
17
  self.url = "https://#{self.url}" unless self.url.start_with?('http')
18
18
 
19
19
  data = { username: username, password: password, email: email, url: url }
20
- spinner "Adding #{url.colorize(:cyan)} to external registries " do
20
+ spinner "Adding #{pastel.cyan(url)} to external registries " do
21
21
  client(token).post("grids/#{current_grid}/external_registries", data)
22
22
  end
23
23
  end
@@ -9,7 +9,7 @@ module Kontena::Cli::ExternalRegistries
9
9
  require_api_url
10
10
  token = require_token
11
11
  confirm_command(name) unless forced?
12
- spinner "Removing #{name.colorize(:cyan)} external-registry from #{current_grid.colorize(:cyan)} grid " do
12
+ spinner "Removing #{pastel.cyan(name)} external-registry from #{pastel.cyan(current_grid)} grid " do
13
13
  client(token).delete("external_registries/#{current_grid}/#{name}")
14
14
  end
15
15
  end
@@ -122,14 +122,24 @@ module Kontena::Cli::Grids
122
122
  def self.included(base)
123
123
  base.option "--default-affinity", "[AFFINITY]", "Default affinity rule for the grid", multivalued: true
124
124
  base.option "--statsd-server", "STATSD_SERVER", "Statsd server address (host:port)"
125
- base.option "--log-forwarder", "LOG_FORWARDER", "Set grid wide log forwarder (set to 'none' to disable)"
125
+ base.option "--log-forwarder", "LOG_FORWARDER", "Set grid wide log forwarder" do |log_forwarder|
126
+ if log_forwarder == 'none'
127
+ warn "[DEPRECATED] --log-forwarder none will be replaced with --no-log-forwarder"
128
+ end
129
+ log_forwarder
130
+ end
131
+ base.option "--no-log-forwarder", :flag, "Disable log forwarding"
126
132
  base.option "--log-opt", "[LOG_OPT]", "Set log options (key=value)", multivalued: true
127
133
  end
128
134
 
129
135
  def validate_log_opts
130
- if !log_opt_list.empty? && log_forwarder.nil?
136
+ if !log_opt_list.empty? && (log_forwarder.nil? || no_log_forwarder?)
131
137
  raise Kontena::Errors::StandardError.new(1, "Need to specify --log-forwarder when using --log-opt")
132
138
  end
139
+
140
+ if no_log_forwarder? && !log_forwarder.nil? && log_forwarder != "none"
141
+ exit_with_error "Can't use --log-forwarder and --no-log-forwarder together"
142
+ end
133
143
  end
134
144
 
135
145
  def parse_log_opts
@@ -156,9 +166,9 @@ module Kontena::Cli::Grids
156
166
  }
157
167
  end
158
168
 
159
- if log_forwarder
169
+ if log_forwarder || no_log_forwarder?
160
170
  payload[:logs] = {
161
- forwarder: log_forwarder,
171
+ forwarder: no_log_forwarder? ? 'none' : log_forwarder,
162
172
  opts: parse_log_opts
163
173
  }
164
174
  end
@@ -37,9 +37,9 @@ module Kontena::Cli::Grids
37
37
 
38
38
  time = log['created_at']
39
39
  if log['severity'] == 2
40
- time = time.colorize(:yellow)
40
+ time = pastel.yellow(time)
41
41
  elsif log['severity'] >= 3
42
- time = time.colorize(:red)
42
+ time = pastel.red(time)
43
43
  end
44
44
 
45
45
  puts '%-25s %-25s %-40s %s' % [