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.
- checksums.yaml +4 -4
- data/Dockerfile +7 -3
- data/Gemfile +7 -3
- data/README.md +1 -1
- data/VERSION +1 -1
- data/bin/kontena +1 -0
- data/kontena-cli.gemspec +5 -6
- data/lib/kontena/cli/browser_launcher.rb +61 -0
- data/lib/kontena/cli/certificate/authorize_command.rb +40 -16
- data/lib/kontena/cli/certificate/get_command.rb +1 -1
- data/lib/kontena/cli/cloud/login_command.rb +3 -4
- data/lib/kontena/cli/cloud/master/add_command.rb +1 -1
- data/lib/kontena/cli/cloud/master/list_command.rb +1 -1
- data/lib/kontena/cli/cloud/master/remove_command.rb +1 -1
- data/lib/kontena/cli/cloud/master/update_command.rb +1 -1
- data/lib/kontena/cli/common.rb +2 -2
- data/lib/kontena/cli/etcd_command.rb +1 -1
- data/lib/kontena/cli/external_registries/add_command.rb +2 -2
- data/lib/kontena/cli/external_registries/remove_command.rb +1 -1
- data/lib/kontena/cli/grids/common.rb +14 -4
- data/lib/kontena/cli/grids/events_command.rb +2 -2
- data/lib/kontena/cli/grids/list_command.rb +1 -1
- data/lib/kontena/cli/grids/logs_command.rb +1 -1
- data/lib/kontena/cli/grids/remove_command.rb +12 -10
- data/lib/kontena/cli/grids/trusted_subnets/add_command.rb +1 -1
- data/lib/kontena/cli/grids/trusted_subnets/remove_command.rb +12 -10
- data/lib/kontena/cli/grids/use_command.rb +1 -1
- data/lib/kontena/cli/helpers/log_helper.rb +1 -1
- data/lib/kontena/cli/logout_command.rb +1 -1
- data/lib/kontena/cli/master/login_command.rb +2 -3
- data/lib/kontena/cli/master/logout_command.rb +2 -2
- data/lib/kontena/cli/master/token/common.rb +2 -1
- data/lib/kontena/cli/master/token/create_command.rb +5 -2
- data/lib/kontena/cli/master/token/current_command.rb +9 -4
- data/lib/kontena/cli/master/token/list_command.rb +1 -1
- data/lib/kontena/cli/master/token/show_command.rb +11 -1
- data/lib/kontena/cli/master/user/invite_command.rb +1 -1
- data/lib/kontena/cli/master_command.rb +0 -1
- data/lib/kontena/cli/nodes/create_command.rb +1 -1
- data/lib/kontena/cli/nodes/labels/remove_command.rb +17 -3
- data/lib/kontena/cli/nodes/remove_command.rb +12 -10
- data/lib/kontena/cli/nodes/reset_token_command.rb +1 -1
- data/lib/kontena/cli/nodes/update_command.rb +1 -1
- data/lib/kontena/cli/plugin_command.rb +2 -1
- data/lib/kontena/cli/plugins/install_command.rb +2 -2
- data/lib/kontena/cli/plugins/uninstall_command.rb +19 -10
- data/lib/kontena/cli/plugins/upgrade_command.rb +60 -0
- data/lib/kontena/cli/registry/create_command.rb +1 -1
- data/lib/kontena/cli/registry/remove_command.rb +2 -2
- data/lib/kontena/cli/services/containers_command.rb +1 -1
- data/lib/kontena/cli/services/create_command.rb +1 -1
- data/lib/kontena/cli/services/deploy_command.rb +1 -1
- data/lib/kontena/cli/services/envs/add_command.rb +1 -1
- data/lib/kontena/cli/services/envs/remove_command.rb +5 -3
- data/lib/kontena/cli/services/link_command.rb +1 -1
- data/lib/kontena/cli/services/logs_command.rb +1 -1
- data/lib/kontena/cli/services/monitor_command.rb +1 -1
- data/lib/kontena/cli/services/remove_command.rb +11 -9
- data/lib/kontena/cli/services/restart_command.rb +1 -1
- data/lib/kontena/cli/services/secrets/link_command.rb +1 -1
- data/lib/kontena/cli/services/services_helper.rb +6 -12
- data/lib/kontena/cli/services/start_command.rb +5 -3
- data/lib/kontena/cli/services/stop_command.rb +5 -3
- data/lib/kontena/cli/services/unlink_command.rb +1 -1
- data/lib/kontena/cli/services/update_command.rb +1 -1
- data/lib/kontena/cli/spinner.rb +10 -10
- data/lib/kontena/cli/stack_command.rb +1 -0
- data/lib/kontena/cli/stacks/build_command.rb +6 -6
- data/lib/kontena/cli/stacks/deploy_command.rb +12 -10
- data/lib/kontena/cli/stacks/inspect_command.rb +17 -0
- data/lib/kontena/cli/stacks/install_command.rb +15 -4
- data/lib/kontena/cli/stacks/list_command.rb +2 -3
- data/lib/kontena/cli/stacks/logs_command.rb +1 -1
- data/lib/kontena/cli/stacks/monitor_command.rb +2 -2
- data/lib/kontena/cli/stacks/remove_command.rb +28 -19
- data/lib/kontena/cli/stacks/restart_command.rb +5 -4
- data/lib/kontena/cli/stacks/stop_command.rb +6 -5
- data/lib/kontena/cli/stacks/upgrade_command.rb +84 -64
- data/lib/kontena/cli/stacks/yaml/reader.rb +9 -4
- data/lib/kontena/cli/vault/remove_command.rb +7 -5
- data/lib/kontena/cli/vault/update_command.rb +1 -1
- data/lib/kontena/cli/vault/write_command.rb +1 -1
- data/lib/kontena/cli/volumes/remove_command.rb +6 -4
- data/lib/kontena/cli/vpn/create_command.rb +1 -1
- data/lib/kontena/cli/vpn/remove_command.rb +1 -1
- data/lib/kontena/client.rb +23 -14
- data/lib/kontena/command.rb +2 -2
- data/lib/kontena/debug_instrumentor.rb +11 -2
- data/lib/kontena/plugin_manager/common.rb +5 -2
- data/lib/kontena/plugin_manager/installer.rb +34 -10
- data/lib/kontena/scripts/completer.rb +91 -43
- data/lib/kontena/{cli/stacks → stacks}/change_resolver.rb +38 -16
- data/lib/kontena/stacks/stack_data.rb +58 -0
- data/lib/kontena/stacks/stack_data_set.rb +51 -0
- data/lib/kontena_cli.rb +1 -0
- data/omnibus/Gemfile.lock +32 -22
- data/omnibus/config/projects/kontena.rb +2 -0
- data/omnibus/config/software/kontena-cli.rb +6 -4
- data/omnibus/package-scripts/kontena/postinstall +1 -1
- data/omnibus/wrappers/sh/kontena +1 -1
- data/spec/fixtures/kontena_v3_with_registry_extends.yml +20 -0
- data/spec/kontena/cli/certificates/authorize_command_spec.rb +81 -0
- data/spec/kontena/cli/cloud/login_command_spec.rb +4 -4
- data/spec/kontena/cli/common_spec.rb +8 -1
- data/spec/kontena/cli/grids/update_command_spec.rb +13 -0
- data/spec/kontena/cli/master/join_command_spec.rb +1 -4
- data/spec/kontena/cli/master/login_command_spec.rb +4 -4
- data/spec/kontena/cli/master/token/create_command_spec.rb +132 -0
- data/spec/kontena/cli/master/token/show_command_spec.rb +90 -0
- data/spec/kontena/cli/nodes/labels/remove_command_spec.rb +35 -5
- data/spec/kontena/cli/stacks/install_command_spec.rb +16 -6
- data/spec/kontena/cli/stacks/remove_command_spec.rb +23 -2
- data/spec/kontena/cli/stacks/validate_command_spec.rb +1 -1
- data/spec/kontena/cli/stacks/yaml/reader_spec.rb +33 -1
- data/spec/kontena/client_spec.rb +38 -1
- data/spec/kontena/stacks/change_resolver_spec.rb +44 -0
- data/spec/kontena/stacks/stack_data_set_spec.rb +59 -0
- metadata +36 -34
- data/lib/kontena/cli/master/users_command.rb +0 -13
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'kontena/plugin_manager'
|
2
|
+
require_relative 'common'
|
3
|
+
|
4
|
+
module Kontena::Cli::Plugins
|
5
|
+
class UpgradeCommand < Kontena::Command
|
6
|
+
include Kontena::Cli::Common
|
7
|
+
include Common
|
8
|
+
include Kontena::PluginManager::Common
|
9
|
+
|
10
|
+
option '--pre', :flag, 'Include pre-release versions'
|
11
|
+
option '--silent', :flag, 'Less verbose output'
|
12
|
+
|
13
|
+
def running_verbose?
|
14
|
+
!silent?
|
15
|
+
end
|
16
|
+
|
17
|
+
def cleanup(*plugins)
|
18
|
+
return if plugins.empty?
|
19
|
+
vspinner "Running cleanup" do
|
20
|
+
plugins.each do |name|
|
21
|
+
Kontena::PluginManager::Cleaner.new(name).cleanup
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def installer(name, version: nil)
|
27
|
+
Kontena::PluginManager::Installer.new(name, pre: pre?, version: version)
|
28
|
+
end
|
29
|
+
|
30
|
+
def upgrade(name, from, to)
|
31
|
+
vspinner "Upgrading #{pastel.cyan(name)} from #{pastel.cyan(from)} to #{pastel.cyan(to)}" do
|
32
|
+
installer(name, version: to).install
|
33
|
+
end
|
34
|
+
sputs "Upgraded #{name} from #{from} to #{to}" if silent?
|
35
|
+
end
|
36
|
+
|
37
|
+
def execute
|
38
|
+
upgradable = {}
|
39
|
+
|
40
|
+
vspinner "Checking for upgrades" do
|
41
|
+
plugins.each do |plugin|
|
42
|
+
short = short_name(plugin.name)
|
43
|
+
available_upgrade = installer(short).available_upgrade
|
44
|
+
unless available_upgrade.nil?
|
45
|
+
upgradable[short] = { from: plugin.version.to_s, to: available_upgrade }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
if upgradable.empty?
|
51
|
+
vputs "Nothing upgraded"
|
52
|
+
else
|
53
|
+
upgradable.each do |name, data|
|
54
|
+
upgrade(name, data[:from], data[:to])
|
55
|
+
end
|
56
|
+
cleanup(upgradable.keys)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -111,7 +111,7 @@ module Kontena::Cli::Registry
|
|
111
111
|
|
112
112
|
client(token).post("grids/#{current_grid}/stacks", data)
|
113
113
|
deployment = client(token).post("stacks/#{current_grid}/registry/deploy", {})
|
114
|
-
spinner "Deploying #{data[:name]
|
114
|
+
spinner "Deploying #{pastel.cyan(data[:name])} stack " do
|
115
115
|
wait_for_deploy_to_finish(deployment)
|
116
116
|
end
|
117
117
|
puts "\n"
|
@@ -11,9 +11,9 @@ module Kontena::Cli::Registry
|
|
11
11
|
name = 'registry'
|
12
12
|
|
13
13
|
registry = client(token).get("stacks/#{current_grid}/#{name}") rescue nil
|
14
|
-
exit_with_error("Stack #{
|
14
|
+
exit_with_error("Stack #{pastel.cyan(name)} does not exist") if registry.nil?
|
15
15
|
|
16
|
-
spinner "Removing #{
|
16
|
+
spinner "Removing #{pastel.cyan(name)} stack " do
|
17
17
|
client(token).delete("stacks/#{current_grid}/#{name}")
|
18
18
|
end
|
19
19
|
end
|
@@ -28,7 +28,7 @@ module Kontena::Cli::Services
|
|
28
28
|
puts " ip: #{container['ip_address']}"
|
29
29
|
puts " public ip: #{container['node']['public_ip']}"
|
30
30
|
if container['status'] == 'unknown'
|
31
|
-
puts " status: #{container['status']
|
31
|
+
puts " status: #{pastel.yellow(container['status'])}"
|
32
32
|
else
|
33
33
|
puts " status: #{container['status']}"
|
34
34
|
end
|
@@ -58,7 +58,7 @@ module Kontena::Cli::Services
|
|
58
58
|
stateful: stateful?
|
59
59
|
}
|
60
60
|
data.merge!(parse_service_data_from_options)
|
61
|
-
spinner "Creating #{
|
61
|
+
spinner "Creating #{pastel.cyan(name)} service " do
|
62
62
|
create_service(token, current_grid, data)
|
63
63
|
end
|
64
64
|
end
|
@@ -16,7 +16,7 @@ module Kontena::Cli::Services
|
|
16
16
|
service_id = name
|
17
17
|
data = {}
|
18
18
|
data[:force] = true if force?
|
19
|
-
spinner "Deploying service #{
|
19
|
+
spinner "Deploying service #{pastel.cyan(name)} " do
|
20
20
|
deployment = deploy_service(token, name, data)
|
21
21
|
wait_for_deploy_to_finish(token, deployment) if wait?
|
22
22
|
end
|
@@ -13,7 +13,7 @@ module Kontena::Cli::Services::Envs
|
|
13
13
|
require_api_url
|
14
14
|
token = require_token
|
15
15
|
data = {env: env}
|
16
|
-
spinner "Adding env variable to #{
|
16
|
+
spinner "Adding env variable to #{pastel.cyan(name)} service " do
|
17
17
|
client(token).post("services/#{parse_service_id(name)}/envs", data)
|
18
18
|
end
|
19
19
|
end
|
@@ -7,13 +7,15 @@ module Kontena::Cli::Services::Envs
|
|
7
7
|
include Kontena::Cli::Services::ServicesHelper
|
8
8
|
|
9
9
|
parameter "NAME", "Service name"
|
10
|
-
parameter "ENV", "Environment variable name"
|
10
|
+
parameter "ENV ...", "Environment variable name", attribute_name: :envs
|
11
11
|
|
12
12
|
def execute
|
13
13
|
require_api_url
|
14
14
|
token = require_token
|
15
|
-
|
16
|
-
|
15
|
+
envs.each do |env|
|
16
|
+
spinner "Removing env variable #{pastel.cyan(env)} from #{pastel.cyan(name)} service " do
|
17
|
+
client(token).delete("services/#{parse_service_id(name)}/envs/#{env}")
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -27,7 +27,7 @@ module Kontena::Cli::Services
|
|
27
27
|
links << {name: target_service.to_s, alias: target.to_s}
|
28
28
|
links.compact!
|
29
29
|
data = {links: links}
|
30
|
-
spinner "Linking #{
|
30
|
+
spinner "Linking #{pastel.cyan(name)} to #{pastel.cyan(target)} " do
|
31
31
|
update_service(token, name, data)
|
32
32
|
end
|
33
33
|
end
|
@@ -26,7 +26,7 @@ module Kontena::Cli::Services
|
|
26
26
|
color = color_for_container(log['name'])
|
27
27
|
instance_number = log['name'].match(/^.+-(\d+)$/)[1]
|
28
28
|
name = instance_number.nil? ? log['name'] : instance_number
|
29
|
-
prefix = "#{log['created_at']} [#{name}]:"
|
29
|
+
prefix = pastel.send(color, "#{log['created_at']} [#{name}]:")
|
30
30
|
puts "#{prefix} #{log['data']}"
|
31
31
|
end
|
32
32
|
end
|
@@ -5,7 +5,7 @@ module Kontena::Cli::Services
|
|
5
5
|
include Kontena::Cli::Common
|
6
6
|
include ServicesHelper
|
7
7
|
|
8
|
-
parameter "NAME", "Service name"
|
8
|
+
parameter "NAME ...", "Service name", attribute_name: :names
|
9
9
|
option "--instance", "INSTANCE", "Remove only given instance"
|
10
10
|
option "--force", :flag, "Force remove", default: false, attribute_name: :forced
|
11
11
|
|
@@ -15,17 +15,19 @@ module Kontena::Cli::Services
|
|
15
15
|
requires_current_master_token
|
16
16
|
|
17
17
|
def execute
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
names.each do |name|
|
19
|
+
if instance
|
20
|
+
remove_instance(name)
|
21
|
+
else
|
22
|
+
remove(name)
|
23
|
+
end
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
25
|
-
def remove
|
27
|
+
def remove(name)
|
26
28
|
confirm_command(name) unless forced?
|
27
29
|
|
28
|
-
spinner "Removing service #{
|
30
|
+
spinner "Removing service #{pastel.cyan(name)} " do
|
29
31
|
client.delete("services/#{parse_service_id(name)}")
|
30
32
|
removed = false
|
31
33
|
until removed == true
|
@@ -43,14 +45,14 @@ module Kontena::Cli::Services
|
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
46
|
-
def remove_instance
|
48
|
+
def remove_instance(name)
|
47
49
|
instance_name = "#{name}/#{instance}"
|
48
50
|
confirm_command("#{name}/#{instance}") unless forced?
|
49
51
|
service_instance = client.get("services/#{parse_service_id(name)}/instances")['instances'].find{ |i|
|
50
52
|
i['instance_number'] == instance.to_i
|
51
53
|
}
|
52
54
|
exit_with_error("Instance not found") unless service_instance
|
53
|
-
spinner "Removing service instance #{
|
55
|
+
spinner "Removing service instance #{pastel.cyan(instance_name)} " do
|
54
56
|
client.delete("services/#{parse_service_id(name)}/instances/#{service_instance['id']}")
|
55
57
|
end
|
56
58
|
end
|
@@ -11,7 +11,7 @@ module Kontena::Cli::Services
|
|
11
11
|
def execute
|
12
12
|
require_api_url
|
13
13
|
token = require_token
|
14
|
-
spinner "Sending restart signal to service #{
|
14
|
+
spinner "Sending restart signal to service #{pastel.cyan(name)} " do
|
15
15
|
restart_service(token, name)
|
16
16
|
end
|
17
17
|
end
|
@@ -12,7 +12,7 @@ module Kontena::Cli::Services::Secrets
|
|
12
12
|
def execute
|
13
13
|
require_api_url
|
14
14
|
token = require_token
|
15
|
-
spinner "Linking #{
|
15
|
+
spinner "Linking #{pastel.cyan(secret)} from Vault to #{pastel.cyan(name)} " do
|
16
16
|
result = client(token).get("services/#{parse_service_id(name)}")
|
17
17
|
secrets = result['secrets']
|
18
18
|
secrets << parse_secrets([secret])[0]
|
@@ -264,7 +264,7 @@ module Kontena
|
|
264
264
|
puts " health: #{container.dig('health_status', 'status')} (#{health_time.to_i}s ago)"
|
265
265
|
end
|
266
266
|
if container['status'] == 'unknown'
|
267
|
-
puts " status: #{container['status']
|
267
|
+
puts " status: #{pastel.yellow(container['status'])}"
|
268
268
|
else
|
269
269
|
puts " status: #{container['status']}"
|
270
270
|
end
|
@@ -547,18 +547,12 @@ module Kontena
|
|
547
547
|
# @param [Symbol] health
|
548
548
|
# @return [String]
|
549
549
|
def health_status_icon(health)
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
icon = '⊙'.freeze
|
555
|
-
icon.colorize(:yellow)
|
556
|
-
elsif health == :healthy
|
557
|
-
icon = '⊛'.freeze
|
558
|
-
icon.colorize(:green)
|
550
|
+
case health
|
551
|
+
when :unhealthy then pastel.red('⊗')
|
552
|
+
when :partial then pastel.yellow('⊙')
|
553
|
+
when :healthy then pastel.green('⊛')
|
559
554
|
else
|
560
|
-
|
561
|
-
icon.colorize(:dim)
|
555
|
+
pastel.dim('⊝')
|
562
556
|
end
|
563
557
|
end
|
564
558
|
|
@@ -6,13 +6,15 @@ module Kontena::Cli::Services
|
|
6
6
|
include Kontena::Cli::GridOptions
|
7
7
|
include ServicesHelper
|
8
8
|
|
9
|
-
parameter "NAME", "Service name"
|
9
|
+
parameter "NAME ...", "Service name", attribute_name: :names
|
10
10
|
|
11
11
|
def execute
|
12
12
|
require_api_url
|
13
13
|
token = require_token
|
14
|
-
|
15
|
-
|
14
|
+
names.each do |name|
|
15
|
+
spinner "Sending start signal to #{pastel.cyan(name)} service " do
|
16
|
+
start_service(token, name)
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
@@ -6,13 +6,15 @@ module Kontena::Cli::Services
|
|
6
6
|
include Kontena::Cli::GridOptions
|
7
7
|
include ServicesHelper
|
8
8
|
|
9
|
-
parameter "NAME", "Service name"
|
9
|
+
parameter "NAME ...", "Service name", attribute_name: :names
|
10
10
|
|
11
11
|
def execute
|
12
12
|
require_api_url
|
13
13
|
token = require_token
|
14
|
-
|
15
|
-
|
14
|
+
names.each do |name|
|
15
|
+
spinner "Sending stop signal to #{pastel.cyan(name)} service " do
|
16
|
+
stop_service(token, name)
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
@@ -22,7 +22,7 @@ module Kontena::Cli::Services
|
|
22
22
|
end
|
23
23
|
links.delete_if { |l| l['id'] == target_id }
|
24
24
|
data = {links: links}
|
25
|
-
spinner "Unlinking #{
|
25
|
+
spinner "Unlinking #{pastel.cyan(name)} from #{pastel.cyan(target)} " do
|
26
26
|
update_service(token, name, data)
|
27
27
|
end
|
28
28
|
end
|
@@ -50,7 +50,7 @@ module Kontena::Cli::Services
|
|
50
50
|
token = require_token
|
51
51
|
|
52
52
|
data = parse_service_data_from_options
|
53
|
-
spinner "Updating #{
|
53
|
+
spinner "Updating #{pastel.cyan(name)} service " do
|
54
54
|
update_service(token, name, data)
|
55
55
|
end
|
56
56
|
end
|
data/lib/kontena/cli/spinner.rb
CHANGED
@@ -47,7 +47,7 @@ module Kontena
|
|
47
47
|
|
48
48
|
def self.spin_no_tty(msg, &block)
|
49
49
|
unless block_given?
|
50
|
-
Kernel.puts "\r [" + "done"
|
50
|
+
Kernel.puts "\r [" + Kontena.pastel.green("done") + "] #{msg}"
|
51
51
|
return
|
52
52
|
end
|
53
53
|
|
@@ -80,7 +80,7 @@ module Kontena
|
|
80
80
|
return spin_no_tty(msg, &block) unless $stdout.tty?
|
81
81
|
|
82
82
|
unless block_given?
|
83
|
-
Kernel.puts "\r [" + "done"
|
83
|
+
Kernel.puts "\r [" + Kontena.pastel.green("done") + "] #{msg}"
|
84
84
|
return
|
85
85
|
end
|
86
86
|
|
@@ -89,7 +89,7 @@ module Kontena
|
|
89
89
|
Thread.main['spinners'].each do |thread|
|
90
90
|
thread['pause'] = true
|
91
91
|
end
|
92
|
-
Kernel.puts "\r [#{'....'
|
92
|
+
Kernel.puts "\r [#{Kontena.pastel.yellow('....')}] #{Thread.main['spinners'].last['msg']}"
|
93
93
|
end
|
94
94
|
|
95
95
|
Thread.main['spinner_msgs'] = []
|
@@ -139,27 +139,27 @@ module Kontena
|
|
139
139
|
spin_thread.kill
|
140
140
|
case spin_status.result
|
141
141
|
when :warn
|
142
|
-
Kernel.puts "\r [" + "warn"
|
142
|
+
Kernel.puts "\r [" + Kontena.pastel.yellow("warn") + "] #{msg} "
|
143
143
|
when :fail
|
144
|
-
Kernel.puts "\r [" + "fail"
|
144
|
+
Kernel.puts "\r [" + Kontena.pastel.red("fail") + "] #{msg} "
|
145
145
|
else
|
146
|
-
Kernel.puts "\r [" + "done"
|
146
|
+
Kernel.puts "\r [" + Kontena.pastel.green("done") + "] #{msg} "
|
147
147
|
end
|
148
148
|
rescue SystemExit => ex
|
149
149
|
spin_thread.kill
|
150
150
|
if ex.status == 0
|
151
|
-
Kernel.puts "\r [" + "done"
|
151
|
+
Kernel.puts "\r [" + Kontena.pastel.green("done") + "] #{msg} "
|
152
152
|
else
|
153
|
-
Kernel.puts "\r [" + "fail"
|
153
|
+
Kernel.puts "\r [" + Kontena.pastel.red("fail") + "] #{msg} "
|
154
154
|
end
|
155
155
|
status = ex.status
|
156
156
|
rescue SpinAbort
|
157
157
|
spin_thread.kill
|
158
|
-
Kernel.puts "\r [" + "fail"
|
158
|
+
Kernel.puts "\r [" + Kontena.pastel.red("fail") + "] #{msg} "
|
159
159
|
Kontena.logger.debug { "Spin aborted through fail!" }
|
160
160
|
rescue Exception => ex
|
161
161
|
spin_thread.kill
|
162
|
-
Kernel.puts "\r [" + "fail"
|
162
|
+
Kernel.puts "\r [" + Kontena.pastel.red("fail") + "] #{msg} "
|
163
163
|
Kontena.logger.error(ex)
|
164
164
|
raise ex
|
165
165
|
ensure
|
@@ -3,6 +3,7 @@ class Kontena::Cli::StackCommand < Kontena::Command
|
|
3
3
|
subcommand ["ls", "list"], "List installed stacks in a grid", load_subcommand('stacks/list_command')
|
4
4
|
subcommand ["remove","rm"], "Remove a deployed stack from a grid", load_subcommand('stacks/remove_command')
|
5
5
|
subcommand "show", "Show details about a stack in a grid", load_subcommand('stacks/show_command')
|
6
|
+
subcommand "inspect", "Inspect a stack in a grid", load_subcommand('stacks/inspect_command')
|
6
7
|
subcommand "upgrade", "Upgrade a stack in a grid", load_subcommand('stacks/upgrade_command')
|
7
8
|
subcommand ["start", "deploy"], "Deploy an installed stack in a grid", load_subcommand('stacks/deploy_command')
|
8
9
|
subcommand "logs", "Show logs from services in a stack", load_subcommand('stacks/logs_command')
|
@@ -35,7 +35,7 @@ module Kontena::Cli::Stacks
|
|
35
35
|
end
|
36
36
|
|
37
37
|
if services.none?{ |service| service['build'] }
|
38
|
-
abort 'Not found any service with a build option'
|
38
|
+
abort pastel.red('Not found any service with a build option')
|
39
39
|
end
|
40
40
|
build_docker_images(services)
|
41
41
|
push_docker_images(services) unless no_push?
|
@@ -49,10 +49,10 @@ module Kontena::Cli::Stacks
|
|
49
49
|
abort("'#{service['image']}' is not valid Docker image name") unless valid_image_name?(service['image'])
|
50
50
|
abort("'#{service['build']['context']}' does not have #{dockerfile}") unless dockerfile_exist?(service['build']['context'], dockerfile)
|
51
51
|
if service['hooks'] && service['hooks']['pre_build']
|
52
|
-
puts "Running pre_build hook"
|
52
|
+
puts pastel.cyan("Running pre_build hook")
|
53
53
|
run_pre_build_hook(service['hooks']['pre_build'])
|
54
54
|
end
|
55
|
-
puts "Building image #{service['image']
|
55
|
+
puts "Building image #{pastel.cyan(service['image'])}"
|
56
56
|
build_docker_image(service)
|
57
57
|
end
|
58
58
|
end
|
@@ -62,7 +62,7 @@ module Kontena::Cli::Stacks
|
|
62
62
|
def push_docker_images(services)
|
63
63
|
services.each do |service|
|
64
64
|
if service['build']
|
65
|
-
puts "Pushing image #{service['image']
|
65
|
+
puts "Pushing image #{pastel.cyan(service['image'])}"
|
66
66
|
push_docker_image(service['image'])
|
67
67
|
end
|
68
68
|
end
|
@@ -85,7 +85,7 @@ module Kontena::Cli::Stacks
|
|
85
85
|
end
|
86
86
|
cmd << build_context
|
87
87
|
ret = system(*cmd.flatten)
|
88
|
-
raise ("Failed to build image #{service['image']
|
88
|
+
raise ("Failed to build image #{pastel.cyan(service['image'])}") unless ret
|
89
89
|
ret
|
90
90
|
end
|
91
91
|
|
@@ -95,7 +95,7 @@ module Kontena::Cli::Stacks
|
|
95
95
|
cmd = ['docker', 'push', image]
|
96
96
|
cmd.unshift('sudo') if sudo?
|
97
97
|
ret = system(*cmd)
|
98
|
-
raise ("Failed to push image #{
|
98
|
+
raise ("Failed to push image #{pastel.cyan(image)}") unless ret
|
99
99
|
ret
|
100
100
|
end
|
101
101
|
|