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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/kontena +2 -4
- data/kontena-cli.gemspec +1 -0
- data/lib/kontena/cli/app_command.rb +1 -1
- data/lib/kontena/cli/apps/common.rb +30 -3
- data/lib/kontena/cli/apps/deploy_command.rb +1 -0
- data/lib/kontena/cli/apps/list_command.rb +1 -0
- data/lib/kontena/cli/apps/logs_command.rb +9 -3
- data/lib/kontena/cli/apps/monitor_command.rb +1 -0
- data/lib/kontena/cli/apps/remove_command.rb +2 -0
- data/lib/kontena/cli/apps/scale_command.rb +2 -1
- data/lib/kontena/cli/apps/show_command.rb +1 -0
- data/lib/kontena/cli/apps/start_command.rb +1 -0
- data/lib/kontena/cli/apps/stop_command.rb +1 -0
- data/lib/kontena/cli/common.rb +5 -1
- data/lib/kontena/cli/containers/exec_command.rb +1 -0
- data/lib/kontena/cli/containers/inspect_command.rb +1 -0
- data/lib/kontena/cli/etcd/get_command.rb +2 -1
- data/lib/kontena/cli/etcd/list_command.rb +1 -0
- data/lib/kontena/cli/etcd/mkdir_command.rb +2 -1
- data/lib/kontena/cli/etcd/remove_command.rb +2 -1
- data/lib/kontena/cli/etcd/set_command.rb +2 -1
- data/lib/kontena/cli/etcd_command.rb +2 -2
- data/lib/kontena/cli/external_registries/add_command.rb +1 -0
- data/lib/kontena/cli/external_registries/delete_command.rb +2 -0
- data/lib/kontena/cli/external_registries/list_command.rb +1 -0
- data/lib/kontena/cli/external_registries/remove_command.rb +13 -0
- data/lib/kontena/cli/external_registry_command.rb +4 -3
- data/lib/kontena/cli/grid_command.rb +5 -1
- data/lib/kontena/cli/grid_options.rb +12 -0
- data/lib/kontena/cli/grids/add_user_command.rb +1 -0
- data/lib/kontena/cli/grids/cloud_config_command.rb +41 -0
- data/lib/kontena/cli/grids/common.rb +65 -4
- data/lib/kontena/cli/grids/logs_command.rb +9 -4
- data/lib/kontena/cli/grids/remove_user_command.rb +1 -0
- data/lib/kontena/cli/grids/update_command.rb +27 -0
- data/lib/kontena/cli/master/use_command.rb +12 -2
- data/lib/kontena/cli/master/users/add_role_command.rb +26 -0
- data/lib/kontena/cli/master/users/invite_command.rb +24 -0
- data/lib/kontena/cli/master/users/list_command.rb +18 -0
- data/lib/kontena/cli/master/users/remove_role_command.rb +26 -0
- data/lib/kontena/cli/master/users_command.rb +14 -0
- data/lib/kontena/cli/master_command.rb +2 -1
- data/lib/kontena/cli/node_command.rb +7 -1
- data/lib/kontena/cli/nodes/add_label_command.rb +19 -0
- data/lib/kontena/cli/nodes/aws/create_command.rb +2 -1
- data/lib/kontena/cli/nodes/aws/restart_command.rb +1 -0
- data/lib/kontena/cli/nodes/aws/terminate_command.rb +1 -0
- data/lib/kontena/cli/nodes/azure/create_command.rb +1 -0
- data/lib/kontena/cli/nodes/azure/restart_command.rb +1 -0
- data/lib/kontena/cli/nodes/azure/terminate_command.rb +1 -0
- data/lib/kontena/cli/nodes/digital_ocean/create_command.rb +1 -0
- data/lib/kontena/cli/nodes/digital_ocean/restart_command.rb +1 -0
- data/lib/kontena/cli/nodes/digital_ocean/terminate_command.rb +1 -0
- data/lib/kontena/cli/nodes/list_command.rb +10 -14
- data/lib/kontena/cli/nodes/remove_command.rb +1 -0
- data/lib/kontena/cli/nodes/remove_label_command.rb +23 -0
- data/lib/kontena/cli/nodes/show_command.rb +1 -0
- data/lib/kontena/cli/nodes/ssh_command.rb +1 -0
- data/lib/kontena/cli/nodes/update_command.rb +1 -0
- data/lib/kontena/cli/nodes/vagrant/create_command.rb +1 -0
- data/lib/kontena/cli/nodes/vagrant/restart_command.rb +1 -0
- data/lib/kontena/cli/nodes/vagrant/ssh_command.rb +1 -0
- data/lib/kontena/cli/nodes/vagrant/start_command.rb +1 -0
- data/lib/kontena/cli/nodes/vagrant/stop_command.rb +1 -0
- data/lib/kontena/cli/nodes/vagrant/terminate_command.rb +1 -0
- data/lib/kontena/cli/registry/create_command.rb +80 -30
- data/lib/kontena/cli/registry/delete_command.rb +3 -0
- data/lib/kontena/cli/registry/remove_command.rb +15 -0
- data/lib/kontena/cli/registry_command.rb +3 -1
- data/lib/kontena/cli/service_command.rb +20 -4
- data/lib/kontena/cli/services/add_env_command.rb +1 -0
- data/lib/kontena/cli/services/add_secret_command.rb +24 -0
- data/lib/kontena/cli/services/containers_command.rb +1 -0
- data/lib/kontena/cli/services/create_command.rb +3 -2
- data/lib/kontena/cli/services/delete_command.rb +2 -0
- data/lib/kontena/cli/services/deploy_command.rb +1 -0
- data/lib/kontena/cli/services/envs_command.rb +1 -0
- data/lib/kontena/cli/services/link_command.rb +26 -0
- data/lib/kontena/cli/services/list_command.rb +13 -10
- data/lib/kontena/cli/services/logs_command.rb +13 -5
- data/lib/kontena/cli/services/monitor_command.rb +1 -0
- data/lib/kontena/cli/services/remove_command.rb +17 -0
- data/lib/kontena/cli/services/remove_env_command.rb +1 -0
- data/lib/kontena/cli/services/remove_secret_command.rb +28 -0
- data/lib/kontena/cli/services/restart_command.rb +1 -0
- data/lib/kontena/cli/services/scale_command.rb +2 -1
- data/lib/kontena/cli/services/show_command.rb +1 -0
- data/lib/kontena/cli/services/start_command.rb +1 -0
- data/lib/kontena/cli/services/stats_command.rb +5 -4
- data/lib/kontena/cli/services/stop_command.rb +1 -0
- data/lib/kontena/cli/services/unlink_command.rb +25 -0
- data/lib/kontena/cli/services/update_command.rb +4 -3
- data/lib/kontena/cli/users_command.rb +15 -0
- data/lib/kontena/cli/vault/list_command.rb +1 -0
- data/lib/kontena/cli/vault/read_command.rb +1 -0
- data/lib/kontena/cli/vault/remove_command.rb +1 -0
- data/lib/kontena/cli/vault/write_command.rb +1 -0
- data/lib/kontena/cli/version_command.rb +9 -1
- data/lib/kontena/cli/vpn/config_command.rb +1 -0
- data/lib/kontena/cli/vpn/create_command.rb +1 -0
- data/lib/kontena/cli/vpn/delete_command.rb +2 -0
- data/lib/kontena/cli/vpn/remove_command.rb +15 -0
- data/lib/kontena/cli/vpn_command.rb +3 -1
- data/lib/kontena/machine/aws/node_destroyer.rb +1 -1
- data/lib/kontena/machine/cloud_config/cloudinit.yml +70 -0
- data/lib/kontena/machine/cloud_config/node_generator.rb +28 -0
- data/lib/kontena/machine/digital_ocean/cloudinit.yml +22 -0
- data/lib/kontena/machine/digital_ocean/node_destroyer.rb +4 -2
- data/lib/kontena/machine/random_name.rb +3 -3
- data/lib/kontena/scripts/completer +7 -3
- data/spec/fixtures/docker-compose.yml +8 -0
- data/spec/fixtures/kontena.yml +17 -0
- data/spec/fixtures/mysql.yml +3 -0
- data/spec/fixtures/wordpress-scaled.yml +3 -0
- data/spec/fixtures/wordpress.yml +2 -0
- data/spec/kontena/cli/app/common_spec.rb +42 -0
- data/spec/kontena/cli/app/deploy_command_spec.rb +4 -31
- data/spec/kontena/cli/app/scale_spec.rb +4 -23
- data/spec/kontena/cli/master/use_command_spec.rb +12 -3
- data/spec/kontena/cli/master/users/add_role_command_spec.rb +35 -0
- data/spec/kontena/cli/master/users/invite_command_spec.rb +35 -0
- data/spec/kontena/cli/master/users/remove_role_command_spec.rb +35 -0
- data/spec/kontena/cli/services/add_secret_command_spec.rb +61 -0
- data/spec/kontena/cli/services/link_command_spec.rb +43 -0
- data/spec/kontena/cli/services/remove_secret_command_spec.rb +48 -0
- data/spec/kontena/cli/services/restart_command_spec.rb +1 -23
- data/spec/kontena/cli/services/unlink_command_spec.rb +43 -0
- data/spec/kontena/cli/version_command_spec.rb +17 -0
- data/spec/spec_helper.rb +6 -1
- data/spec/support/client_helpers.rb +31 -0
- data/spec/support/fixtures_helpers.rb +7 -0
- metadata +67 -6
- data/lib/kontena/cli/deploy_command.rb +0 -164
- data/lib/kontena/cli/invite_command.rb +0 -13
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09a43f90d845f6046491b8b9636cae6201fc0602
|
4
|
+
data.tar.gz: 357fcf2a78efd43d5371056837a188b7225bd016
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 076aa681b8e39964cbe93b9ae29279ee443f36fa0e73e6a054aef32852f93e5bb1502a318c556da5505eb6aaa13ec1b80a0d6d617b00466c8529c8f3cbeb80ba
|
7
|
+
data.tar.gz: 40fe038531ef0e8cda9fa1af4c1a1df6f25a79088e7f8311b3d1c29b833762d145d26441e09f9ddc105419ae414866cd077a88dfd9a51fbc0b087c2cfad64e85
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
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
@@ -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
|
-
|
37
|
-
|
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
|
-
|
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'))
|
@@ -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", "--
|
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
|
-
|
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
|
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'
|
data/lib/kontena/cli/common.rb
CHANGED
@@ -95,7 +95,11 @@ module Kontena
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def current_grid
|
98
|
-
|
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
|
@@ -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 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,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}")
|