kontena-cli 0.11.7 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/bin/kontena +2 -4
  4. data/kontena-cli.gemspec +1 -0
  5. data/lib/kontena/cli/app_command.rb +1 -1
  6. data/lib/kontena/cli/apps/common.rb +30 -3
  7. data/lib/kontena/cli/apps/deploy_command.rb +1 -0
  8. data/lib/kontena/cli/apps/list_command.rb +1 -0
  9. data/lib/kontena/cli/apps/logs_command.rb +9 -3
  10. data/lib/kontena/cli/apps/monitor_command.rb +1 -0
  11. data/lib/kontena/cli/apps/remove_command.rb +2 -0
  12. data/lib/kontena/cli/apps/scale_command.rb +2 -1
  13. data/lib/kontena/cli/apps/show_command.rb +1 -0
  14. data/lib/kontena/cli/apps/start_command.rb +1 -0
  15. data/lib/kontena/cli/apps/stop_command.rb +1 -0
  16. data/lib/kontena/cli/common.rb +5 -1
  17. data/lib/kontena/cli/containers/exec_command.rb +1 -0
  18. data/lib/kontena/cli/containers/inspect_command.rb +1 -0
  19. data/lib/kontena/cli/etcd/get_command.rb +2 -1
  20. data/lib/kontena/cli/etcd/list_command.rb +1 -0
  21. data/lib/kontena/cli/etcd/mkdir_command.rb +2 -1
  22. data/lib/kontena/cli/etcd/remove_command.rb +2 -1
  23. data/lib/kontena/cli/etcd/set_command.rb +2 -1
  24. data/lib/kontena/cli/etcd_command.rb +2 -2
  25. data/lib/kontena/cli/external_registries/add_command.rb +1 -0
  26. data/lib/kontena/cli/external_registries/delete_command.rb +2 -0
  27. data/lib/kontena/cli/external_registries/list_command.rb +1 -0
  28. data/lib/kontena/cli/external_registries/remove_command.rb +13 -0
  29. data/lib/kontena/cli/external_registry_command.rb +4 -3
  30. data/lib/kontena/cli/grid_command.rb +5 -1
  31. data/lib/kontena/cli/grid_options.rb +12 -0
  32. data/lib/kontena/cli/grids/add_user_command.rb +1 -0
  33. data/lib/kontena/cli/grids/cloud_config_command.rb +41 -0
  34. data/lib/kontena/cli/grids/common.rb +65 -4
  35. data/lib/kontena/cli/grids/logs_command.rb +9 -4
  36. data/lib/kontena/cli/grids/remove_user_command.rb +1 -0
  37. data/lib/kontena/cli/grids/update_command.rb +27 -0
  38. data/lib/kontena/cli/master/use_command.rb +12 -2
  39. data/lib/kontena/cli/master/users/add_role_command.rb +26 -0
  40. data/lib/kontena/cli/master/users/invite_command.rb +24 -0
  41. data/lib/kontena/cli/master/users/list_command.rb +18 -0
  42. data/lib/kontena/cli/master/users/remove_role_command.rb +26 -0
  43. data/lib/kontena/cli/master/users_command.rb +14 -0
  44. data/lib/kontena/cli/master_command.rb +2 -1
  45. data/lib/kontena/cli/node_command.rb +7 -1
  46. data/lib/kontena/cli/nodes/add_label_command.rb +19 -0
  47. data/lib/kontena/cli/nodes/aws/create_command.rb +2 -1
  48. data/lib/kontena/cli/nodes/aws/restart_command.rb +1 -0
  49. data/lib/kontena/cli/nodes/aws/terminate_command.rb +1 -0
  50. data/lib/kontena/cli/nodes/azure/create_command.rb +1 -0
  51. data/lib/kontena/cli/nodes/azure/restart_command.rb +1 -0
  52. data/lib/kontena/cli/nodes/azure/terminate_command.rb +1 -0
  53. data/lib/kontena/cli/nodes/digital_ocean/create_command.rb +1 -0
  54. data/lib/kontena/cli/nodes/digital_ocean/restart_command.rb +1 -0
  55. data/lib/kontena/cli/nodes/digital_ocean/terminate_command.rb +1 -0
  56. data/lib/kontena/cli/nodes/list_command.rb +10 -14
  57. data/lib/kontena/cli/nodes/remove_command.rb +1 -0
  58. data/lib/kontena/cli/nodes/remove_label_command.rb +23 -0
  59. data/lib/kontena/cli/nodes/show_command.rb +1 -0
  60. data/lib/kontena/cli/nodes/ssh_command.rb +1 -0
  61. data/lib/kontena/cli/nodes/update_command.rb +1 -0
  62. data/lib/kontena/cli/nodes/vagrant/create_command.rb +1 -0
  63. data/lib/kontena/cli/nodes/vagrant/restart_command.rb +1 -0
  64. data/lib/kontena/cli/nodes/vagrant/ssh_command.rb +1 -0
  65. data/lib/kontena/cli/nodes/vagrant/start_command.rb +1 -0
  66. data/lib/kontena/cli/nodes/vagrant/stop_command.rb +1 -0
  67. data/lib/kontena/cli/nodes/vagrant/terminate_command.rb +1 -0
  68. data/lib/kontena/cli/registry/create_command.rb +80 -30
  69. data/lib/kontena/cli/registry/delete_command.rb +3 -0
  70. data/lib/kontena/cli/registry/remove_command.rb +15 -0
  71. data/lib/kontena/cli/registry_command.rb +3 -1
  72. data/lib/kontena/cli/service_command.rb +20 -4
  73. data/lib/kontena/cli/services/add_env_command.rb +1 -0
  74. data/lib/kontena/cli/services/add_secret_command.rb +24 -0
  75. data/lib/kontena/cli/services/containers_command.rb +1 -0
  76. data/lib/kontena/cli/services/create_command.rb +3 -2
  77. data/lib/kontena/cli/services/delete_command.rb +2 -0
  78. data/lib/kontena/cli/services/deploy_command.rb +1 -0
  79. data/lib/kontena/cli/services/envs_command.rb +1 -0
  80. data/lib/kontena/cli/services/link_command.rb +26 -0
  81. data/lib/kontena/cli/services/list_command.rb +13 -10
  82. data/lib/kontena/cli/services/logs_command.rb +13 -5
  83. data/lib/kontena/cli/services/monitor_command.rb +1 -0
  84. data/lib/kontena/cli/services/remove_command.rb +17 -0
  85. data/lib/kontena/cli/services/remove_env_command.rb +1 -0
  86. data/lib/kontena/cli/services/remove_secret_command.rb +28 -0
  87. data/lib/kontena/cli/services/restart_command.rb +1 -0
  88. data/lib/kontena/cli/services/scale_command.rb +2 -1
  89. data/lib/kontena/cli/services/show_command.rb +1 -0
  90. data/lib/kontena/cli/services/start_command.rb +1 -0
  91. data/lib/kontena/cli/services/stats_command.rb +5 -4
  92. data/lib/kontena/cli/services/stop_command.rb +1 -0
  93. data/lib/kontena/cli/services/unlink_command.rb +25 -0
  94. data/lib/kontena/cli/services/update_command.rb +4 -3
  95. data/lib/kontena/cli/users_command.rb +15 -0
  96. data/lib/kontena/cli/vault/list_command.rb +1 -0
  97. data/lib/kontena/cli/vault/read_command.rb +1 -0
  98. data/lib/kontena/cli/vault/remove_command.rb +1 -0
  99. data/lib/kontena/cli/vault/write_command.rb +1 -0
  100. data/lib/kontena/cli/version_command.rb +9 -1
  101. data/lib/kontena/cli/vpn/config_command.rb +1 -0
  102. data/lib/kontena/cli/vpn/create_command.rb +1 -0
  103. data/lib/kontena/cli/vpn/delete_command.rb +2 -0
  104. data/lib/kontena/cli/vpn/remove_command.rb +15 -0
  105. data/lib/kontena/cli/vpn_command.rb +3 -1
  106. data/lib/kontena/machine/aws/node_destroyer.rb +1 -1
  107. data/lib/kontena/machine/cloud_config/cloudinit.yml +70 -0
  108. data/lib/kontena/machine/cloud_config/node_generator.rb +28 -0
  109. data/lib/kontena/machine/digital_ocean/cloudinit.yml +22 -0
  110. data/lib/kontena/machine/digital_ocean/node_destroyer.rb +4 -2
  111. data/lib/kontena/machine/random_name.rb +3 -3
  112. data/lib/kontena/scripts/completer +7 -3
  113. data/spec/fixtures/docker-compose.yml +8 -0
  114. data/spec/fixtures/kontena.yml +17 -0
  115. data/spec/fixtures/mysql.yml +3 -0
  116. data/spec/fixtures/wordpress-scaled.yml +3 -0
  117. data/spec/fixtures/wordpress.yml +2 -0
  118. data/spec/kontena/cli/app/common_spec.rb +42 -0
  119. data/spec/kontena/cli/app/deploy_command_spec.rb +4 -31
  120. data/spec/kontena/cli/app/scale_spec.rb +4 -23
  121. data/spec/kontena/cli/master/use_command_spec.rb +12 -3
  122. data/spec/kontena/cli/master/users/add_role_command_spec.rb +35 -0
  123. data/spec/kontena/cli/master/users/invite_command_spec.rb +35 -0
  124. data/spec/kontena/cli/master/users/remove_role_command_spec.rb +35 -0
  125. data/spec/kontena/cli/services/add_secret_command_spec.rb +61 -0
  126. data/spec/kontena/cli/services/link_command_spec.rb +43 -0
  127. data/spec/kontena/cli/services/remove_secret_command_spec.rb +48 -0
  128. data/spec/kontena/cli/services/restart_command_spec.rb +1 -23
  129. data/spec/kontena/cli/services/unlink_command_spec.rb +43 -0
  130. data/spec/kontena/cli/version_command_spec.rb +17 -0
  131. data/spec/spec_helper.rb +6 -1
  132. data/spec/support/client_helpers.rb +31 -0
  133. data/spec/support/fixtures_helpers.rb +7 -0
  134. metadata +67 -6
  135. data/lib/kontena/cli/deploy_command.rb +0 -164
  136. data/lib/kontena/cli/invite_command.rb +0 -13
  137. data/spec/kontena/cli/deploy_command_spec.rb +0 -239
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05d019eab615b4a8cef10906bae09f8858ab486c
4
- data.tar.gz: b2818cb57bc09a5fbfd6986b9a2f0816eeedf103
3
+ metadata.gz: 09a43f90d845f6046491b8b9636cae6201fc0602
4
+ data.tar.gz: 357fcf2a78efd43d5371056837a188b7225bd016
5
5
  SHA512:
6
- metadata.gz: 5adefb5a60bd0444f254f6faf63faa2cfa5600e1e9694209e54f1549b039b648ecb72695d6707f472ce04de56c0658641a8fc82bfc173e1cdc50f661395bf029
7
- data.tar.gz: b85ae888626bbc54797da140843d51d4e6709377ba46cd11c019fd297f7ddf6dc22dad8d72983ff35ce55a9b768f2ae7a7e9f6bb59e44f72f706961af11a9376
6
+ metadata.gz: 076aa681b8e39964cbe93b9ae29279ee443f36fa0e73e6a054aef32852f93e5bb1502a318c556da5505eb6aaa13ec1b80a0d6d617b00466c8529c8f3cbeb80ba
7
+ data.tar.gz: 40fe038531ef0e8cda9fa1af4c1a1df6f25a79088e7f8311b3d1c29b833762d145d26441e09f9ddc105419ae414866cd077a88dfd9a51fbc0b087c2cfad64e85
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.7
1
+ 0.12.0
data/bin/kontena CHANGED
@@ -11,15 +11,16 @@ $:.unshift File.expand_path('../../lib', bin_file)
11
11
  STDOUT.sync = true
12
12
 
13
13
  require 'clamp'
14
+ require 'ruby_dig'
14
15
  require 'kontena/client'
15
16
  require 'kontena/cli/common'
17
+ require 'kontena/cli/grid_options'
16
18
  require 'kontena/cli/app_command'
17
19
  require 'kontena/cli/register_command'
18
20
  require 'kontena/cli/login_command'
19
21
  require 'kontena/cli/logout_command'
20
22
  require 'kontena/cli/whoami_command'
21
23
  require 'kontena/cli/verify_account_command'
22
- require 'kontena/cli/invite_command'
23
24
  require 'kontena/cli/forgot_password_command'
24
25
  require 'kontena/cli/reset_password_command'
25
26
  require 'kontena/cli/container_command'
@@ -30,7 +31,6 @@ require 'kontena/cli/service_command'
30
31
  require 'kontena/cli/vpn_command'
31
32
  require 'kontena/cli/registry_command'
32
33
  require 'kontena/cli/external_registry_command'
33
- require 'kontena/cli/deploy_command'
34
34
  require 'kontena/cli/app_command'
35
35
  require 'kontena/cli/etcd_command'
36
36
  require 'kontena/cli/vault_command'
@@ -42,7 +42,6 @@ class MainCommand < Clamp::Command
42
42
  subcommand "app", "App specific commands", Kontena::Cli::AppCommand
43
43
  subcommand "service", "Service specific commands", Kontena::Cli::ServiceCommand
44
44
  subcommand "vault", "Vault specific commands", Kontena::Cli::VaultCommand
45
- subcommand "deploy", "Create and deploy multiple services from YAML file", Kontena::Cli::DeployCommand
46
45
  subcommand "node", "Node specific commands", Kontena::Cli::NodeCommand
47
46
  subcommand "master", "Master specific commands", Kontena::Cli::MasterCommand
48
47
  subcommand "vpn", "VPN specific commands", Kontena::Cli::VpnCommand
@@ -55,7 +54,6 @@ class MainCommand < Clamp::Command
55
54
  subcommand "logout", "Logout from Kontena Master", Kontena::Cli::LogoutCommand
56
55
  subcommand "whoami", "Shows current logged in user", Kontena::Cli::WhoamiCommand
57
56
  subcommand "verify-account", "Verify registered account", Kontena::Cli::VerifyAccountCommand
58
- subcommand "invite", "Invite user to Kontena Master", Kontena::Cli::InviteCommand
59
57
  subcommand "forgot-password", "Request password reset for Kontena account", Kontena::Cli::ForgotPasswordCommand
60
58
  subcommand "reset-password", "Reset Kontena account password", Kontena::Cli::ResetPasswordCommand
61
59
  subcommand "version", "Show version", Kontena::Cli::VersionCommand
data/kontena-cli.gemspec CHANGED
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_runtime_dependency 'clamp'
28
28
  spec.add_runtime_dependency 'highline'
29
29
  spec.add_runtime_dependency 'shell-spinner'
30
+ spec.add_runtime_dependency 'ruby_dig'
30
31
  end
@@ -21,7 +21,7 @@ class Kontena::Cli::AppCommand < Clamp::Command
21
21
  subcommand "stop", "Stop services", Kontena::Cli::Apps::StopCommand
22
22
  subcommand "restart", "Restart services", Kontena::Cli::Apps::RestartCommand
23
23
  subcommand "show", "Show service details", Kontena::Cli::Apps::ShowCommand
24
- subcommand ["ps", "list"], "List services", Kontena::Cli::Apps::ListCommand
24
+ subcommand ["ps", "list", "ls"], "List services", Kontena::Cli::Apps::ListCommand
25
25
  subcommand ["logs"], "Show service logs", Kontena::Cli::Apps::LogsCommand
26
26
  subcommand "monitor", "Monitor services", Kontena::Cli::Apps::MonitorCommand
27
27
  subcommand ["remove","rm"], "Remove services", Kontena::Cli::Apps::RemoveCommand
@@ -9,32 +9,46 @@ module Kontena::Cli::Apps
9
9
  abort("File #{filename} does not exist") unless File.exists?(filename)
10
10
  end
11
11
 
12
+ # @param [String] filename
13
+ # @param [Array<String>] service_list
14
+ # @param [String] prefix
15
+ # @return [Hash]
12
16
  def load_services(filename, service_list, prefix)
13
17
  services = parse_services(filename, nil, prefix)
14
18
  services.delete_if { |name, service| !service_list.include?(name)} unless service_list.empty?
15
19
  services
16
20
  end
17
21
 
22
+ # @return [String]
18
23
  def token
19
24
  @token ||= require_token
20
25
  end
21
26
 
27
+ # @param [String] name
28
+ # @return [String]
22
29
  def prefixed_name(name)
23
30
  return name if service_prefix.strip == ""
24
31
 
25
32
  "#{service_prefix}-#{name}"
26
33
  end
27
34
 
35
+ # @return [String]
28
36
  def current_dir
29
37
  File.basename(Dir.getwd)
30
38
  end
31
39
 
40
+ # @param [String] name
41
+ # @return [Boolean]
32
42
  def service_exists?(name)
33
43
  get_service(token, prefixed_name(name)) rescue false
34
44
  end
35
45
 
36
- def parse_services(file, name = nil, prefix='')
37
- services = YAML.load(File.read(File.expand_path(file)) % {project: prefix})
46
+ # @param [String] file
47
+ # @param [String,NilClass] name
48
+ # @param [String] prefix
49
+ # @return [Hash]
50
+ def parse_services(file, name = nil, prefix = '')
51
+ services = YAML.load(File.read(File.expand_path(file)) % {project: prefix, grid: current_grid})
38
52
  Dir.chdir(File.dirname(File.expand_path(file))) do
39
53
  services.each do |name, options|
40
54
  normalize_env_vars(options)
@@ -49,22 +63,32 @@ module Kontena::Cli::Apps
49
63
  if name.nil?
50
64
  services
51
65
  else
66
+ abort("Service #{name} not found in #{file}") unless services.has_key?(name)
52
67
  services[name]
53
68
  end
54
69
  end
55
70
 
71
+ # @param [Hash] options
72
+ # @param [String] file
73
+ # @param [String] service_name
74
+ # @param [String] prefix
75
+ # @return [Hash]
56
76
  def extend_options(options, file, service_name, prefix)
57
77
  parent_options = parse_services(file, service_name, prefix)
58
78
  options['environment'] = extend_env_vars(parent_options, options)
59
79
  parent_options.merge(options)
60
80
  end
61
81
 
82
+ # @param [Hash] options
62
83
  def normalize_env_vars(options)
63
84
  if options['environment'].is_a?(Hash)
64
85
  options['environment'] = options['environment'].map{|k, v| "#{k}=#{v}"}
65
86
  end
66
87
  end
67
88
 
89
+ # @param [Hash] from
90
+ # @param [Hash] to
91
+ # @return [Array]
68
92
  def extend_env_vars(from, to)
69
93
  env_vars = to['environment'] || []
70
94
  if from['environment']
@@ -75,12 +99,15 @@ module Kontena::Cli::Apps
75
99
  env_vars
76
100
  end
77
101
 
78
- def create_yml(services, file='kontena.yml')
102
+ # @param [Hash] services
103
+ # @param [String] file
104
+ def create_yml(services, file = 'kontena.yml')
79
105
  yml = File.new(file, 'w')
80
106
  yml.puts services.to_yaml
81
107
  yml.close
82
108
  end
83
109
 
110
+ # @return [Hash]
84
111
  def app_json
85
112
  if !@app_json && File.exist?('app.json')
86
113
  @app_json = JSON.parse(File.read('app.json'))
@@ -5,6 +5,7 @@ require_relative 'docker_helper'
5
5
  module Kontena::Cli::Apps
6
6
  class DeployCommand < Clamp::Command
7
7
  include Kontena::Cli::Common
8
+ include Kontena::Cli::GridOptions
8
9
  include Common
9
10
  include DockerHelper
10
11
 
@@ -3,6 +3,7 @@ require_relative 'common'
3
3
  module Kontena::Cli::Apps
4
4
  class ListCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
+ include Kontena::Cli::GridOptions
6
7
  include Common
7
8
 
8
9
  option ['-f', '--file'], 'FILE', 'Specify an alternate Kontena compose file', attribute_name: :filename, default: 'kontena.yml'
@@ -3,12 +3,15 @@ require_relative 'common'
3
3
  module Kontena::Cli::Apps
4
4
  class LogsCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
+ include Kontena::Cli::GridOptions
6
7
  include Common
7
8
 
8
9
  option ['-f', '--file'], 'FILE', 'Specify an alternate Kontena compose file', attribute_name: :filename, default: 'kontena.yml'
9
10
  option ['-p', '--project-name'], 'NAME', 'Specify an alternate project name (default: directory name)'
11
+ option ["-l", "--lines"], "LINES", "How many lines to show", default: '100'
12
+ option "--since", "SINCE", "Show logs since given timestamp"
10
13
  option ["-s", "--search"], "SEARCH", "Search from logs"
11
- option ["-t", "--follow"], :flag, "Follow (tail) logs", default: false
14
+ option ["-t", "--tail"], :flag, "Tail (follow) logs", default: false
12
15
  parameter "[SERVICE] ...", "Show only specified service logs"
13
16
 
14
17
  attr_reader :services, :service_prefix
@@ -31,6 +34,8 @@ module Kontena::Cli::Apps
31
34
  loop do
32
35
  query_params = []
33
36
  query_params << "from=#{last_id}" unless last_id.nil?
37
+ query_params << "limit=#{lines}"
38
+ query_params << "since=#{since}" if !since.nil? && last_id.nil?
34
39
  query_params << "search=#{search}" if search
35
40
  logs = []
36
41
  services.each do |service_name, opts|
@@ -41,10 +46,11 @@ module Kontena::Cli::Apps
41
46
  logs.sort!{|x,y| DateTime.parse(x['created_at']) <=> DateTime.parse(y['created_at'])}
42
47
  logs.each do |log|
43
48
  color = color_for_container(log['name'])
44
- puts "#{log['name'].colorize(color)} | #{log['data']}"
49
+ prefix = "#{log['created_at']} #{log['name']}:".colorize(color)
50
+ puts "#{prefix} #{log['data']}"
45
51
  last_id = log['id']
46
52
  end
47
- break unless follow?
53
+ break unless tail?
48
54
  sleep(2)
49
55
  end
50
56
  end
@@ -3,6 +3,7 @@ require_relative 'common'
3
3
  module Kontena::Cli::Apps
4
4
  class MonitorCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
+ include Kontena::Cli::GridOptions
6
7
  include Common
7
8
 
8
9
  option ['-f', '--file'], 'FILE', 'Specify an alternate Kontena compose file', attribute_name: :filename, default: 'kontena.yml'
@@ -3,6 +3,7 @@ require_relative 'common'
3
3
  module Kontena::Cli::Apps
4
4
  class RemoveCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
+ include Kontena::Cli::GridOptions
6
7
  include Common
7
8
 
8
9
  option ['-f', '--file'], 'FILE', 'Specify an alternate Kontena compose file', attribute_name: :filename, default: 'kontena.yml'
@@ -31,6 +32,7 @@ module Kontena::Cli::Apps
31
32
  services.find_all {|service_name, options| options['links'] && options['links'].size > 0 }.each do |service_name, options|
32
33
  delete(service_name, options)
33
34
  services.delete(service_name)
35
+ sleep 1
34
36
  end
35
37
  services.each do |service_name, options|
36
38
  delete(service_name, options)
@@ -3,6 +3,7 @@ require_relative 'common'
3
3
  module Kontena::Cli::Apps
4
4
  class ScaleCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
+ include Kontena::Cli::GridOptions
6
7
  include Common
7
8
 
8
9
  option ['-f', '--file'], 'FILE', 'Specify an alternate Kontena compose file', attribute_name: :filename, default: 'kontena.yml'
@@ -29,4 +30,4 @@ module Kontena::Cli::Apps
29
30
 
30
31
 
31
32
  end
32
- end
33
+ end
@@ -3,6 +3,7 @@ require_relative 'common'
3
3
  module Kontena::Cli::Apps
4
4
  class ShowCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
+ include Kontena::Cli::GridOptions
6
7
  include Common
7
8
 
8
9
  option ['-f', '--file'], 'FILE', 'Specify an alternate Kontena compose file', attribute_name: :filename, default: 'kontena.yml'
@@ -3,6 +3,7 @@ require_relative 'common'
3
3
  module Kontena::Cli::Apps
4
4
  class StartCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
+ include Kontena::Cli::GridOptions
6
7
  include Common
7
8
 
8
9
  option ['-f', '--file'], 'FILE', 'Specify an alternate Kontena compose file', attribute_name: :filename, default: 'kontena.yml'
@@ -3,6 +3,7 @@ require_relative 'common'
3
3
  module Kontena::Cli::Apps
4
4
  class StopCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
+ include Kontena::Cli::GridOptions
6
7
  include Common
7
8
 
8
9
  option ['-f', '--file'], 'FILE', 'Specify an alternate Kontena compose file', attribute_name: :filename, default: 'kontena.yml'
@@ -95,7 +95,11 @@ module Kontena
95
95
  end
96
96
 
97
97
  def current_grid
98
- ENV['KONTENA_GRID'] || current_master['grid']
98
+ if self.respond_to?(:grid)
99
+ ENV['KONTENA_GRID'] || grid || current_master['grid']
100
+ else
101
+ ENV['KONTENA_GRID'] || current_master['grid']
102
+ end
99
103
  end
100
104
 
101
105
  def current_master_index
@@ -1,6 +1,7 @@
1
1
  module Kontena::Cli::Containers
2
2
  class ExecCommand < Clamp::Command
3
3
  include Kontena::Cli::Common
4
+ include Kontena::Cli::GridOptions
4
5
 
5
6
  parameter "CONTAINER_ID", "Container id"
6
7
  parameter "CMD ...", "Command"
@@ -1,6 +1,7 @@
1
1
  module Kontena::Cli::Containers
2
2
  class InspectCommand < Clamp::Command
3
3
  include Kontena::Cli::Common
4
+ include Kontena::Cli::GridOptions
4
5
 
5
6
  parameter "CONTAINER_ID", "Container id"
6
7
 
@@ -3,6 +3,7 @@ require_relative 'common'
3
3
  module Kontena::Cli::Etcd
4
4
  class GetCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
+ include Kontena::Cli::GridOptions
6
7
  include Common
7
8
 
8
9
  parameter "KEY", "Etcd key"
@@ -11,7 +12,7 @@ module Kontena::Cli::Etcd
11
12
  require_api_url
12
13
  token = require_token
13
14
  validate_key
14
-
15
+
15
16
  response = client(token).get("etcd/#{current_grid}/#{key}")
16
17
  if response['value']
17
18
  puts response['value']
@@ -3,6 +3,7 @@ require_relative 'common'
3
3
  module Kontena::Cli::Etcd
4
4
  class ListCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
+ include Kontena::Cli::GridOptions
6
7
  include Common
7
8
 
8
9
  parameter "KEY", "Etcd key"
@@ -3,6 +3,7 @@ require_relative 'common'
3
3
  module Kontena::Cli::Etcd
4
4
  class MkdirCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
+ include Kontena::Cli::GridOptions
6
7
  include Common
7
8
 
8
9
  parameter "KEY", "Etcd key"
@@ -11,7 +12,7 @@ module Kontena::Cli::Etcd
11
12
  require_api_url
12
13
  token = require_token
13
14
  validate_key
14
-
15
+
15
16
  data = {}
16
17
  response = client(token).post("etcd/#{current_grid}/#{key}", data)
17
18
  if response['error']
@@ -3,6 +3,7 @@ require_relative 'common'
3
3
  module Kontena::Cli::Etcd
4
4
  class RemoveCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
+ include Kontena::Cli::GridOptions
6
7
  include Common
7
8
 
8
9
  parameter "KEY", "Etcd key"
@@ -13,7 +14,7 @@ module Kontena::Cli::Etcd
13
14
  require_api_url
14
15
  token = require_token
15
16
  validate_key
16
-
17
+
17
18
  data = {}
18
19
  data[:recursive] = true if recursive?
19
20
  response = client(token).delete("etcd/#{current_grid}/#{key}", data)
@@ -3,6 +3,7 @@ require_relative 'common'
3
3
  module Kontena::Cli::Etcd
4
4
  class SetCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
+ include Kontena::Cli::GridOptions
6
7
  include Common
7
8
 
8
9
  parameter "KEY", "Etcd key"
@@ -12,7 +13,7 @@ module Kontena::Cli::Etcd
12
13
  require_api_url
13
14
  token = require_token
14
15
  validate_key
15
-
16
+
16
17
  data = {value: value}
17
18
  response = client(token).post("etcd/#{current_grid}/#{key}", data)
18
19
  if response['error']
@@ -8,8 +8,8 @@ class Kontena::Cli::EtcdCommand < Clamp::Command
8
8
 
9
9
  subcommand "get", "Get the current value for a single key", Kontena::Cli::Etcd::GetCommand
10
10
  subcommand "set", "Set a value on the specified key", Kontena::Cli::Etcd::SetCommand
11
- subcommand "mk", "Create a directory", Kontena::Cli::Etcd::MkdirCommand
12
- subcommand "ls", "List a directory", Kontena::Cli::Etcd::ListCommand
11
+ subcommand ["mkdir", "mk"], "Create a directory", Kontena::Cli::Etcd::MkdirCommand
12
+ subcommand ["list", "ls"], "List a directory", Kontena::Cli::Etcd::ListCommand
13
13
  subcommand "rm", "Remove a key or a directory", Kontena::Cli::Etcd::RemoveCommand
14
14
 
15
15
  def execute
@@ -1,6 +1,7 @@
1
1
  module Kontena::Cli::ExternalRegistries
2
2
  class AddCommand < Clamp::Command
3
3
  include Kontena::Cli::Common
4
+ include Kontena::Cli::GridOptions
4
5
 
5
6
  parameter '[URL]', 'Docker Registry url', default: 'https://index.docker.io/v2/'
6
7
 
@@ -1,10 +1,12 @@
1
1
  module Kontena::Cli::ExternalRegistries
2
2
  class DeleteCommand < Clamp::Command
3
3
  include Kontena::Cli::Common
4
+ include Kontena::Cli::GridOptions
4
5
 
5
6
  parameter "NAME", "External registry name to delete"
6
7
 
7
8
  def execute
9
+ puts "DEPRECATION WARNING: Support for 'kontena external-registry delete' will be dropped. Use 'kontena external-registry remove' instead.".colorize(:red)
8
10
  require_api_url
9
11
  token = require_token
10
12
  client(token).delete("external_registries/#{current_grid}/#{name}")