kontena-cli 1.1.6 → 1.2.0.dev1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/VERSION +1 -1
- data/bin/kontena +8 -28
- data/kontena-cli.gemspec +2 -2
- data/lib/kontena/cli/app_command.rb +14 -27
- data/lib/kontena/cli/certificate_command.rb +4 -7
- data/lib/kontena/cli/cloud/master_command.rb +5 -12
- data/lib/kontena/cli/cloud_command.rb +4 -7
- data/lib/kontena/cli/container_command.rb +4 -9
- data/lib/kontena/cli/etcd/health_command.rb +1 -0
- data/lib/kontena/cli/etcd_command.rb +6 -13
- data/lib/kontena/cli/external_registry_command.rb +3 -7
- data/lib/kontena/cli/grid_command.rb +14 -29
- data/lib/kontena/cli/grids/cloud_config_command.rb +1 -0
- data/lib/kontena/cli/grids/common.rb +2 -0
- data/lib/kontena/cli/grids/create_command.rb +5 -0
- data/lib/kontena/cli/grids/trusted_subnet_command.rb +6 -8
- data/lib/kontena/cli/grids/user_command.rb +3 -6
- data/lib/kontena/cli/master/config_command.rb +6 -12
- data/lib/kontena/cli/master/token_command.rb +6 -11
- data/lib/kontena/cli/master/users/role_command.rb +2 -4
- data/lib/kontena/cli/master/users_command.rb +4 -8
- data/lib/kontena/cli/master_command.rb +14 -33
- data/lib/kontena/cli/node_command.rb +7 -15
- data/lib/kontena/cli/nodes/health_command.rb +1 -1
- data/lib/kontena/cli/nodes/label_command.rb +3 -9
- data/lib/kontena/cli/nodes/show_command.rb +1 -1
- data/lib/kontena/cli/nodes/ssh_command.rb +13 -4
- data/lib/kontena/cli/plugin_command.rb +5 -9
- data/lib/kontena/cli/registry_command.rb +2 -5
- data/lib/kontena/cli/service_command.rb +22 -45
- data/lib/kontena/cli/services/container_command.rb +2 -3
- data/lib/kontena/cli/services/env_command.rb +3 -6
- data/lib/kontena/cli/services/secret_command.rb +2 -4
- data/lib/kontena/cli/stack_command.rb +11 -24
- data/lib/kontena/cli/stacks/registry_command.rb +5 -12
- data/lib/kontena/cli/stacks/upgrade_command.rb +6 -0
- data/lib/kontena/cli/stacks/yaml/reader.rb +17 -2
- data/lib/kontena/cli/subcommand_loader.rb +82 -0
- data/lib/kontena/cli/vault_command.rb +7 -15
- data/lib/kontena/cli/version.rb +6 -1
- data/lib/kontena/cli/vpn_command.rb +3 -7
- data/lib/kontena/command.rb +28 -1
- data/lib/kontena/machine/cloud_config/cloudinit.yml +1 -1
- data/lib/kontena/main_command.rb +22 -38
- data/lib/kontena/scripts/completer +2 -233
- data/lib/kontena/scripts/completer.rb +230 -0
- data/lib/kontena/scripts/init +5 -8
- data/lib/kontena/scripts/kontena.bash +8 -0
- data/lib/kontena/scripts/kontena.zsh +11 -0
- data/lib/kontena_cli.rb +9 -1
- data/omnibus/wrappers/sh/kontena +1 -1
- data/spec/fixtures/stack-with-liquid-optional.yml +14 -0
- data/spec/fixtures/stack-with-liquid-undefined.yml +12 -0
- data/spec/kontena/cli/app/build_command_spec.rb +1 -2
- data/spec/kontena/cli/app/common_spec.rb +1 -2
- data/spec/kontena/cli/app/config_command_spec.rb +0 -1
- data/spec/kontena/cli/app/deploy_command_spec.rb +2 -3
- data/spec/kontena/cli/app/docker_helper_spec.rb +0 -1
- data/spec/kontena/cli/app/init_command_spec.rb +0 -1
- data/spec/kontena/cli/app/logs_command_spec.rb +0 -1
- data/spec/kontena/cli/app/scale_spec.rb +2 -3
- data/spec/kontena/cli/app/service_generator_spec.rb +1 -2
- data/spec/kontena/cli/app/service_generator_v2_spec.rb +0 -1
- data/spec/kontena/cli/app/yaml/reader_spec.rb +0 -1
- data/spec/kontena/cli/app/yaml/service_extender_spec.rb +0 -1
- data/spec/kontena/cli/app/yaml/validator_spec.rb +0 -1
- data/spec/kontena/cli/app/yaml/validator_v2_spec.rb +0 -1
- data/spec/kontena/cli/cloud/login_command_spec.rb +0 -1
- data/spec/kontena/cli/cloud/logout_command_spec.rb +0 -1
- data/spec/kontena/cli/cloud/master/add_command_spec.rb +0 -1
- data/spec/kontena/cli/common_spec.rb +0 -1
- data/spec/kontena/cli/containers/list_command_spec.rb +0 -1
- data/spec/kontena/cli/containers/logs_command_spec.rb +0 -1
- data/spec/kontena/cli/etcd/health_command_spec.rb +2 -0
- data/spec/kontena/cli/grids/trusted_subnets/add_command_spec.rb +0 -11
- data/spec/kontena/cli/grids/trusted_subnets/list_command_spec.rb +4 -13
- data/spec/kontena/cli/grids/trusted_subnets/remove_command_spec.rb +0 -11
- data/spec/kontena/cli/grids/use_command_spec.rb +0 -1
- data/spec/kontena/cli/helpers/log_helper_spec.rb +0 -1
- data/spec/kontena/cli/main_command_spec.rb +2 -3
- data/spec/kontena/cli/master/current_command_spec.rb +5 -15
- data/spec/kontena/cli/master/init_cloud_command_spec.rb +0 -1
- data/spec/kontena/cli/master/login_command_spec.rb +0 -1
- data/spec/kontena/cli/master/logout_command_spec.rb +0 -1
- data/spec/kontena/cli/master/use_command_spec.rb +0 -1
- data/spec/kontena/cli/master/users/invite_command_spec.rb +1 -5
- data/spec/kontena/cli/master/users/remove_command_spec.rb +2 -14
- data/spec/kontena/cli/master/users/roles/add_command_spec.rb +0 -1
- data/spec/kontena/cli/master/users/roles/remove_command_spec.rb +0 -1
- data/spec/kontena/cli/nodes/list_command_spec.rb +2 -0
- data/spec/kontena/cli/services/containers_command_spec.rb +0 -18
- data/spec/kontena/cli/services/exec_command_spec.rb +6 -4
- data/spec/kontena/cli/services/link_command_spec.rb +5 -19
- data/spec/kontena/cli/services/restart_command_spec.rb +0 -16
- data/spec/kontena/cli/services/secrets/link_command_spec.rb +0 -11
- data/spec/kontena/cli/services/secrets/unlink_command_spec.rb +1 -12
- data/spec/kontena/cli/services/services_helper_spec.rb +0 -1
- data/spec/kontena/cli/services/unlink_command_spec.rb +7 -21
- data/spec/kontena/cli/services/update_command_spec.rb +0 -15
- data/spec/kontena/cli/stacks/build_command_spec.rb +0 -1
- data/spec/kontena/cli/stacks/deploy_command_spec.rb +10 -13
- data/spec/kontena/cli/stacks/install_command_spec.rb +0 -15
- data/spec/kontena/cli/stacks/list_command_spec.rb +4 -10
- data/spec/kontena/cli/stacks/remove_command_spec.rb +1 -16
- data/spec/kontena/cli/stacks/service_generator_spec.rb +0 -1
- data/spec/kontena/cli/stacks/service_generator_v2_spec.rb +0 -1
- data/spec/kontena/cli/stacks/show_command_spec.rb +1 -14
- data/spec/kontena/cli/stacks/upgrade_command_spec.rb +19 -1
- data/spec/kontena/cli/stacks/yaml/reader_spec.rb +163 -130
- data/spec/kontena/cli/stacks/yaml/service_extender_spec.rb +0 -1
- data/spec/kontena/cli/stacks/yaml/validator_v3_spec.rb +0 -1
- data/spec/kontena/cli/vault/export_spec.rb +0 -1
- data/spec/kontena/cli/vault/import_spec.rb +4 -5
- data/spec/kontena/cli/version_command_spec.rb +8 -6
- data/spec/kontena/cli/vpn/create_command_spec.rb +3 -4
- data/spec/kontena/client_spec.rb +0 -1
- data/spec/kontena/config_spec.rb +0 -1
- data/spec/kontena/kontena_cli_spec.rb +1 -1
- data/spec/kontena/main_command_spec.rb +0 -1
- data/spec/kontena/plugin_manager_spec.rb +0 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/client_helpers.rb +1 -1
- data/spec/support/exit_with_error_helper.rb +36 -0
- data/spec/support/fixtures_helpers.rb +5 -2
- metadata +18 -7
@@ -1,10 +1,8 @@
|
|
1
1
|
module Kontena::Cli::Master::Users
|
2
2
|
|
3
|
-
require_relative 'roles/add_command'
|
4
|
-
require_relative 'roles/remove_command'
|
5
3
|
|
6
4
|
class RoleCommand < Kontena::Command
|
7
|
-
subcommand "add", "Add role to user",
|
8
|
-
subcommand ["remove", "rm"], "Remove role from user",
|
5
|
+
subcommand "add", "Add role to user", load_subcommand('master/users/roles/add_command')
|
6
|
+
subcommand ["remove", "rm"], "Remove role from user", load_subcommand('master/users/roles/remove_command')
|
9
7
|
end
|
10
8
|
end
|
@@ -1,14 +1,10 @@
|
|
1
1
|
module Kontena::Cli::Master
|
2
2
|
|
3
|
-
require_relative 'users/invite_command'
|
4
|
-
require_relative 'users/remove_command'
|
5
|
-
require_relative 'users/list_command'
|
6
|
-
require_relative 'users/role_command'
|
7
3
|
|
8
4
|
class UsersCommand < Kontena::Command
|
9
|
-
subcommand "invite", "Invite user to Kontena Master",
|
10
|
-
subcommand ["remove", "rm"], "Remove user from Kontena Master",
|
11
|
-
subcommand ["list", "ls"], "List users",
|
12
|
-
subcommand "role", "User role specific commands",
|
5
|
+
subcommand "invite", "Invite user to Kontena Master", load_subcommand('master/users/invite_command')
|
6
|
+
subcommand ["remove", "rm"], "Remove user from Kontena Master", load_subcommand('master/users/remove_command')
|
7
|
+
subcommand ["list", "ls"], "List users", load_subcommand('master/users/list_command')
|
8
|
+
subcommand "role", "User role specific commands", load_subcommand('master/users/role_command')
|
13
9
|
end
|
14
10
|
end
|
@@ -1,39 +1,20 @@
|
|
1
|
-
require_relative '../main_command'
|
2
|
-
require_relative 'master/use_command'
|
3
|
-
require_relative 'master/remove_command'
|
4
|
-
require_relative 'master/list_command'
|
5
|
-
require_relative 'master/users_command'
|
6
|
-
require_relative 'master/current_command'
|
7
|
-
require_relative 'master/config_command'
|
8
|
-
require_relative 'master/login_command'
|
9
|
-
require_relative 'master/logout_command'
|
10
|
-
require_relative 'master/join_command'
|
11
|
-
require_relative 'master/audit_log_command'
|
12
|
-
require_relative 'master/token_command'
|
13
|
-
require_relative 'master/init_cloud_command'
|
14
|
-
require_relative 'master/ssh_command'
|
15
|
-
|
16
1
|
class Kontena::Cli::MasterCommand < Kontena::Command
|
17
2
|
include Kontena::Util
|
18
3
|
|
19
|
-
subcommand ["list", "ls"], "List masters where client has logged in",
|
20
|
-
subcommand ["remove", "rm"], "Remove a master from configuration
|
21
|
-
subcommand ["config", "cfg"], "Configure master settings",
|
22
|
-
subcommand "use", "Switch to use selected master",
|
23
|
-
subcommand "users", "Users specific commands",
|
24
|
-
subcommand "current", "Show current master details",
|
25
|
-
subcommand "login", "Authenticate to Kontena Master",
|
26
|
-
subcommand "logout", "Log out of Kontena Master",
|
27
|
-
subcommand "token", "Manage Kontena Master access tokens",
|
28
|
-
subcommand "join", "Join Kontena Master using an invitation code",
|
29
|
-
subcommand "audit-log", "Show master audit logs",
|
30
|
-
subcommand "
|
31
|
-
subcommand "
|
32
|
-
|
33
|
-
if experimental?
|
34
|
-
require_relative 'master/create_command'
|
35
|
-
subcommand "create", "Install a new Kontena Master", Kontena::Cli::Master::CreateCommand
|
36
|
-
end
|
4
|
+
subcommand ["list", "ls"], "List masters where client has logged in", load_subcommand('master/list_command')
|
5
|
+
subcommand ["remove", "rm"], "Remove a master from configuration", load_subcommand('master/remove_command')
|
6
|
+
subcommand ["config", "cfg"], "Configure master settings", load_subcommand('master/config_command')
|
7
|
+
subcommand "use", "Switch to use selected master", load_subcommand('master/use_command')
|
8
|
+
subcommand "users", "Users specific commands", load_subcommand('master/users_command')
|
9
|
+
subcommand "current", "Show current master details", load_subcommand('master/current_command')
|
10
|
+
subcommand "login", "Authenticate to Kontena Master", load_subcommand('master/login_command')
|
11
|
+
subcommand "logout", "Log out of Kontena Master", load_subcommand('master/logout_command')
|
12
|
+
subcommand "token", "Manage Kontena Master access tokens", load_subcommand('master/token_command')
|
13
|
+
subcommand "join", "Join Kontena Master using an invitation code", load_subcommand('master/join_command')
|
14
|
+
subcommand "audit-log", "Show master audit logs", load_subcommand('master/audit_log_command')
|
15
|
+
subcommand "create", "Install a new Kontena Master", load_subcommand('master/create_command') if experimental?
|
16
|
+
subcommand "init-cloud", "Configure current master to use Kontena Cloud services", load_subcommand('master/init_cloud_command')
|
17
|
+
subcommand "ssh", "Connect to the master via SSH", load_subcommand('master/ssh_command')
|
37
18
|
|
38
19
|
def execute
|
39
20
|
end
|
@@ -1,20 +1,12 @@
|
|
1
|
-
require_relative 'nodes/list_command'
|
2
|
-
require_relative 'nodes/remove_command'
|
3
|
-
require_relative 'nodes/show_command'
|
4
|
-
require_relative 'nodes/update_command'
|
5
|
-
require_relative 'nodes/ssh_command'
|
6
|
-
require_relative 'nodes/label_command'
|
7
|
-
require_relative 'nodes/health_command'
|
8
|
-
|
9
1
|
class Kontena::Cli::NodeCommand < Kontena::Command
|
10
2
|
|
11
|
-
subcommand ["list","ls"], "List grid nodes",
|
12
|
-
subcommand "show", "Show node",
|
13
|
-
subcommand "ssh", "Ssh into node",
|
14
|
-
subcommand "update", "Update node",
|
15
|
-
subcommand ["remove","rm"], "Remove node",
|
16
|
-
subcommand "label", "Node label specific commands",
|
17
|
-
subcommand "health", "Check node health",
|
3
|
+
subcommand ["list","ls"], "List grid nodes", load_subcommand('nodes/list_command')
|
4
|
+
subcommand "show", "Show node", load_subcommand('nodes/show_command')
|
5
|
+
subcommand "ssh", "Ssh into node", load_subcommand('nodes/ssh_command')
|
6
|
+
subcommand "update", "Update node", load_subcommand('nodes/update_command')
|
7
|
+
subcommand ["remove","rm"], "Remove node", load_subcommand('nodes/remove_command')
|
8
|
+
subcommand "label", "Node label specific commands", load_subcommand('nodes/label_command')
|
9
|
+
subcommand "health", "Check node health", load_subcommand('nodes/health_command')
|
18
10
|
|
19
11
|
def execute
|
20
12
|
end
|
@@ -1,14 +1,8 @@
|
|
1
1
|
module Kontena::Cli::Nodes
|
2
|
-
|
3
|
-
require_relative 'labels/add_command'
|
4
|
-
require_relative 'labels/remove_command'
|
5
|
-
require_relative 'labels/list_command'
|
6
|
-
|
7
2
|
class LabelCommand < Kontena::Command
|
8
|
-
|
9
|
-
subcommand
|
10
|
-
subcommand "
|
11
|
-
subcommand ["remove", "rm"], "Remove label from node", Labels::RemoveCommand
|
3
|
+
subcommand ["list", "ls"], "List node labels", load_subcommand('nodes/labels/list_command')
|
4
|
+
subcommand "add", "Add label to node", load_subcommand('nodes/labels/add_command')
|
5
|
+
subcommand ["remove", "rm"], "Remove label from node", load_subcommand('nodes/labels/remove_command')
|
12
6
|
|
13
7
|
def execute
|
14
8
|
end
|
@@ -21,7 +21,7 @@ module Kontena::Cli::Nodes
|
|
21
21
|
puts " last seen: #{node['last_seen_at']}"
|
22
22
|
puts " public ip: #{node['public_ip']}"
|
23
23
|
puts " private ip: #{node['private_ip']}"
|
24
|
-
puts " overlay ip:
|
24
|
+
puts " overlay ip: #{node['overlay_ip']}"
|
25
25
|
puts " os: #{node['os']}"
|
26
26
|
puts " driver: #{node['driver']}"
|
27
27
|
puts " kernel: #{node['kernel_version']}"
|
@@ -3,9 +3,9 @@ module Kontena::Cli::Nodes
|
|
3
3
|
include Kontena::Cli::Common
|
4
4
|
include Kontena::Cli::GridOptions
|
5
5
|
|
6
|
-
parameter "NODE_ID", "
|
6
|
+
parameter "[NODE_ID]", "SSH to Grid node. Use --any to connect to the first available node"
|
7
7
|
parameter "[COMMANDS] ...", "Run command on host"
|
8
|
-
|
8
|
+
option ["-a", "--any"], :flag, "Connect to first available node"
|
9
9
|
option ["-i", "--identity-file"], "IDENTITY_FILE", "Path to ssh private key"
|
10
10
|
option ["-u", "--user"], "USER", "Login as a user", default: "core"
|
11
11
|
option "--private-ip", :flag, "Connect to node's private IP address"
|
@@ -15,7 +15,16 @@ module Kontena::Cli::Nodes
|
|
15
15
|
requires_current_grid
|
16
16
|
|
17
17
|
def execute
|
18
|
-
node
|
18
|
+
exit_with_error "Cannot combine --any with a node name" if node_id && any?
|
19
|
+
|
20
|
+
if node_id
|
21
|
+
node = client.get("grids/#{current_grid}/nodes/#{node_id}")
|
22
|
+
elsif any?
|
23
|
+
nodes = client.get("grids/#{current_grid}/nodes")['nodes']
|
24
|
+
node = nodes.select{ |node| node['connected'] }.first
|
25
|
+
else
|
26
|
+
exit_with_error "No node name given. Use --any to connect to the first available node"
|
27
|
+
end
|
19
28
|
|
20
29
|
provider = Array(node["labels"]).find{ |l| l.start_with?('provider=')}.to_s.split('=').last
|
21
30
|
|
@@ -31,7 +40,7 @@ module Kontena::Cli::Nodes
|
|
31
40
|
cmd = ['ssh']
|
32
41
|
cmd += ["-i", identity_file] if identity_file
|
33
42
|
if internal_ip?
|
34
|
-
ip =
|
43
|
+
ip = node['overlay_ip']
|
35
44
|
elsif private_ip?
|
36
45
|
ip = node['private_ip']
|
37
46
|
else
|
@@ -1,15 +1,11 @@
|
|
1
|
-
require_relative 'plugins/list_command'
|
2
|
-
require_relative 'plugins/search_command'
|
3
|
-
require_relative 'plugins/install_command'
|
4
|
-
require_relative 'plugins/uninstall_command'
|
5
1
|
|
6
2
|
class Kontena::Cli::PluginCommand < Kontena::Command
|
7
3
|
|
8
|
-
subcommand ["list","ls"], "List plugins",
|
9
|
-
subcommand "search", "Search plugins",
|
10
|
-
subcommand "install", "Install a plugin",
|
11
|
-
subcommand "uninstall", "Uninstall a plugin",
|
4
|
+
subcommand ["list","ls"], "List plugins", load_subcommand('plugins/list_command')
|
5
|
+
subcommand "search", "Search plugins", load_subcommand('plugins/search_command')
|
6
|
+
subcommand "install", "Install a plugin", load_subcommand('plugins/install_command')
|
7
|
+
subcommand "uninstall", "Uninstall a plugin", load_subcommand('plugins/uninstall_command')
|
12
8
|
|
13
9
|
def execute
|
14
10
|
end
|
15
|
-
end
|
11
|
+
end
|
@@ -1,10 +1,7 @@
|
|
1
|
-
require_relative 'registry/create_command'
|
2
|
-
require_relative 'registry/remove_command'
|
3
|
-
|
4
1
|
class Kontena::Cli::RegistryCommand < Kontena::Command
|
5
2
|
|
6
|
-
subcommand "create", "Create Docker image registry service",
|
7
|
-
subcommand ["remove","rm"], "Remove Docker image registry service",
|
3
|
+
subcommand "create", "Create Docker image registry service", load_subcommand('registry/create_command')
|
4
|
+
subcommand ["remove","rm"], "Remove Docker image registry service", load_subcommand('registry/remove_command')
|
8
5
|
|
9
6
|
def execute
|
10
7
|
end
|
@@ -1,49 +1,26 @@
|
|
1
|
-
require_relative 'services/list_command'
|
2
|
-
require_relative 'services/show_command'
|
3
|
-
require_relative 'services/update_command'
|
4
|
-
require_relative 'services/deploy_command'
|
5
|
-
require_relative 'services/stop_command'
|
6
|
-
require_relative 'services/start_command'
|
7
|
-
require_relative 'services/restart_command'
|
8
|
-
require_relative 'services/create_command'
|
9
|
-
require_relative 'services/scale_command'
|
10
|
-
require_relative 'services/remove_command'
|
11
|
-
require_relative 'services/containers_command'
|
12
|
-
require_relative 'services/logs_command'
|
13
|
-
require_relative 'services/stats_command'
|
14
|
-
require_relative 'services/monitor_command'
|
15
|
-
|
16
|
-
require_relative 'services/env_command'
|
17
|
-
require_relative 'services/secret_command'
|
18
|
-
|
19
|
-
require_relative 'services/link_command'
|
20
|
-
require_relative 'services/unlink_command'
|
21
|
-
require_relative 'services/exec_command'
|
22
|
-
|
23
1
|
class Kontena::Cli::ServiceCommand < Kontena::Command
|
24
|
-
|
25
|
-
subcommand
|
26
|
-
subcommand "
|
27
|
-
subcommand "
|
28
|
-
subcommand "
|
29
|
-
subcommand "
|
30
|
-
subcommand "
|
31
|
-
subcommand "
|
32
|
-
subcommand "
|
33
|
-
subcommand "
|
34
|
-
subcommand
|
35
|
-
subcommand "
|
36
|
-
subcommand "
|
37
|
-
subcommand "
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
subcommand "
|
45
|
-
subcommand "
|
46
|
-
subcommand "exec", "Execute commands in service containers", Kontena::Cli::Services::ExecCommand
|
2
|
+
subcommand ["list","ls"], "List services", load_subcommand('services/list_command')
|
3
|
+
subcommand "create", "Create a new service", load_subcommand('services/create_command')
|
4
|
+
subcommand "show", "Show service details", load_subcommand('services/show_command')
|
5
|
+
subcommand "update", "Update service configuration", load_subcommand('services/update_command')
|
6
|
+
subcommand "deploy", "Deploy service", load_subcommand('services/deploy_command')
|
7
|
+
subcommand "stop", "Stop service", load_subcommand('services/stop_command')
|
8
|
+
subcommand "start", "Start service", load_subcommand('services/start_command')
|
9
|
+
subcommand "restart", "Restart service", load_subcommand('services/restart_command')
|
10
|
+
subcommand "scale", "Scale service", load_subcommand('services/scale_command')
|
11
|
+
subcommand ["remove", "rm"], "Remove service", load_subcommand('services/remove_command')
|
12
|
+
subcommand "containers", "List service containers", load_subcommand('services/containers_command')
|
13
|
+
subcommand "logs", "Show service logs", load_subcommand('services/logs_command')
|
14
|
+
subcommand "stats", "Show service statistics", load_subcommand('services/stats_command')
|
15
|
+
subcommand "monitor", "Monitor", load_subcommand('services/monitor_command')
|
16
|
+
|
17
|
+
subcommand "env", "Environment variable specific commands", load_subcommand('services/env_command')
|
18
|
+
|
19
|
+
subcommand "secret", "Secret specific commands", load_subcommand('services/secret_command')
|
20
|
+
|
21
|
+
subcommand "link", "Link service to another service", load_subcommand('services/link_command')
|
22
|
+
subcommand "unlink", "Unlink service from another service", load_subcommand('services/unlink_command')
|
23
|
+
subcommand "exec", "Execute commands in service containers", load_subcommand('services/exec_command')
|
47
24
|
|
48
25
|
def execute
|
49
26
|
end
|
@@ -1,9 +1,8 @@
|
|
1
|
-
require_relative 'containers/exec_command'
|
2
1
|
|
3
2
|
class Kontena::Cli::ContainerCommand < Kontena::Command
|
4
3
|
|
5
|
-
subcommand "exec", "Execute command inside a container",
|
4
|
+
subcommand "exec", "Execute command inside a container", load_subcommand('containers/exec_command')
|
6
5
|
|
7
6
|
def execute
|
8
7
|
end
|
9
|
-
end
|
8
|
+
end
|
@@ -1,12 +1,9 @@
|
|
1
1
|
module Kontena::Cli::Services
|
2
2
|
|
3
|
-
require_relative 'envs/add_command'
|
4
|
-
require_relative 'envs/list_command'
|
5
|
-
require_relative 'envs/remove_command'
|
6
3
|
|
7
4
|
class EnvCommand < Kontena::Command
|
8
|
-
subcommand ["list", "ls"], "List service environment variables",
|
9
|
-
subcommand "add", "Add environment variable",
|
10
|
-
subcommand ["remove", "rm"], "Remove environment variable",
|
5
|
+
subcommand ["list", "ls"], "List service environment variables", load_subcommand('services/envs/list_command')
|
6
|
+
subcommand "add", "Add environment variable", load_subcommand('services/envs/add_command')
|
7
|
+
subcommand ["remove", "rm"], "Remove environment variable", load_subcommand('services/envs/remove_command')
|
11
8
|
end
|
12
9
|
end
|
@@ -1,10 +1,8 @@
|
|
1
1
|
module Kontena::Cli::Services
|
2
2
|
|
3
|
-
require_relative 'secrets/link_command'
|
4
|
-
require_relative 'secrets/unlink_command'
|
5
3
|
|
6
4
|
class SecretCommand < Kontena::Command
|
7
|
-
subcommand "link", "Link secret from Vault",
|
8
|
-
subcommand "unlink", "Unlink secret from Vault",
|
5
|
+
subcommand "link", "Link secret from Vault", load_subcommand('services/secrets/link_command')
|
6
|
+
subcommand "unlink", "Unlink secret from Vault", load_subcommand('services/secrets/unlink_command')
|
9
7
|
end
|
10
8
|
end
|
@@ -1,28 +1,15 @@
|
|
1
|
-
require_relative 'stacks/install_command'
|
2
|
-
require_relative 'stacks/remove_command'
|
3
|
-
require_relative 'stacks/deploy_command'
|
4
|
-
require_relative 'stacks/upgrade_command'
|
5
|
-
require_relative 'stacks/list_command'
|
6
|
-
require_relative 'stacks/show_command'
|
7
|
-
require_relative 'stacks/build_command'
|
8
|
-
require_relative 'stacks/monitor_command'
|
9
|
-
require_relative 'stacks/logs_command'
|
10
|
-
require_relative 'stacks/registry_command'
|
11
|
-
require_relative 'stacks/validate_command'
|
12
|
-
|
13
1
|
class Kontena::Cli::StackCommand < Kontena::Command
|
14
|
-
|
15
|
-
subcommand "
|
16
|
-
subcommand ["
|
17
|
-
subcommand
|
18
|
-
subcommand "
|
19
|
-
subcommand "
|
20
|
-
subcommand
|
21
|
-
subcommand "
|
22
|
-
subcommand "
|
23
|
-
subcommand "
|
24
|
-
subcommand
|
25
|
-
subcommand "validate", "Process and validate a stack file", Kontena::Cli::Stacks::ValidateCommand
|
2
|
+
subcommand "install", "Install a stack to a grid", load_subcommand('stacks/install_command')
|
3
|
+
subcommand ["ls", "list"], "List installed stacks in a grid", load_subcommand('stacks/list_command')
|
4
|
+
subcommand ["remove","rm"], "Remove a deployed stack from a grid", load_subcommand('stacks/remove_command')
|
5
|
+
subcommand "show", "Show details about a stack in a grid", load_subcommand('stacks/show_command')
|
6
|
+
subcommand "upgrade", "Upgrade a stack in a grid", load_subcommand('stacks/upgrade_command')
|
7
|
+
subcommand ["start", "deploy"], "Deploy an installed stack in a grid", load_subcommand('stacks/deploy_command')
|
8
|
+
subcommand "logs", "Show logs from services in a stack", load_subcommand('stacks/logs_command')
|
9
|
+
subcommand "monitor", "Monitor services in a stack", load_subcommand('stacks/monitor_command')
|
10
|
+
subcommand "build", "Build images listed in a stack file and push them to an image registry", load_subcommand('stacks/build_command')
|
11
|
+
subcommand ["reg", "registry"], "Stack registry related commands", load_subcommand('stacks/registry_command')
|
12
|
+
subcommand "validate", "Process and validate a stack file", load_subcommand('stacks/validate_command')
|
26
13
|
|
27
14
|
def execute
|
28
15
|
end
|
@@ -1,17 +1,10 @@
|
|
1
1
|
module Kontena::Cli::Stacks
|
2
|
-
|
3
|
-
require_relative 'registry/push_command'
|
4
|
-
require_relative 'registry/pull_command'
|
5
|
-
require_relative 'registry/search_command'
|
6
|
-
require_relative 'registry/show_command'
|
7
|
-
require_relative 'registry/remove_command'
|
8
|
-
|
9
2
|
class RegistryCommand < Kontena::Command
|
10
3
|
|
11
|
-
subcommand "push", "Push a stack into the stacks registry",
|
12
|
-
subcommand "pull", "Pull a stack from the stacks registry",
|
13
|
-
subcommand "search", "Search for stacks in the stacks registry",
|
14
|
-
subcommand "show", "Show info about a stack in the stacks registry",
|
15
|
-
subcommand ["remove", "rm"], "Remove a stack (or version) from the stacks registry",
|
4
|
+
subcommand "push", "Push a stack into the stacks registry", load_subcommand('stacks/registry/push_command')
|
5
|
+
subcommand "pull", "Pull a stack from the stacks registry", load_subcommand('stacks/registry/pull_command')
|
6
|
+
subcommand "search", "Search for stacks in the stacks registry", load_subcommand('stacks/registry/search_command')
|
7
|
+
subcommand "show", "Show info about a stack in the stacks registry", load_subcommand('stacks/registry/show_command')
|
8
|
+
subcommand ["remove", "rm"], "Remove a stack (or version) from the stacks registry", load_subcommand('stacks/registry/remove_command')
|
16
9
|
end
|
17
10
|
end
|
@@ -15,6 +15,8 @@ module Kontena::Cli::Stacks
|
|
15
15
|
|
16
16
|
option '--[no-]deploy', :flag, 'Trigger deploy after upgrade', default: true
|
17
17
|
|
18
|
+
option '--force', :flag, 'Force upgrade'
|
19
|
+
|
18
20
|
requires_current_master
|
19
21
|
requires_current_master_token
|
20
22
|
|
@@ -25,6 +27,10 @@ module Kontena::Cli::Stacks
|
|
25
27
|
|
26
28
|
stack = stack_from_yaml(filename, name: name, values: values, defaults: master_data['variables'])
|
27
29
|
|
30
|
+
unless force? || master_data['stack'] == stack['stack']
|
31
|
+
confirm "Replacing stack #{Kontena.pastel.cyan(master_data['stack'])} on master with #{Kontena.pastel.cyan(stack['stack'])} from #{Kontena.pastel.yellow(filename)}. Are you sure?"
|
32
|
+
end
|
33
|
+
|
28
34
|
spinner "Upgrading stack #{pastel.cyan(name)}" do |spin|
|
29
35
|
update_stack(stack) || spin.fail!
|
30
36
|
end
|
@@ -7,6 +7,16 @@ module Kontena::Cli::Stacks
|
|
7
7
|
module Setters; end
|
8
8
|
end
|
9
9
|
|
10
|
+
# Workaround for nil-valued variables in Liquid templates:
|
11
|
+
# https://github.com/Shopify/liquid/issues/749
|
12
|
+
# This is something that we can pass in to `Liquid::Template.render` that gets evaluated as nil.
|
13
|
+
# If we pass in a nil value directly, then Liquid ignores it and considers the variable to be undefined.
|
14
|
+
class LiquidNull
|
15
|
+
def to_liquid
|
16
|
+
nil
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
10
20
|
class Reader
|
11
21
|
include Kontena::Util
|
12
22
|
include Kontena::Cli::Common
|
@@ -102,7 +112,7 @@ module Kontena::Cli::Stacks
|
|
102
112
|
)
|
103
113
|
if defaults
|
104
114
|
defaults.each do |key, val|
|
105
|
-
var = variables.option(key)
|
115
|
+
var = @variables.option(key)
|
106
116
|
var.default = val if var
|
107
117
|
end
|
108
118
|
end
|
@@ -147,10 +157,15 @@ module Kontena::Cli::Stacks
|
|
147
157
|
raise RuntimeError, "Variable validation failed: #{variables.errors.inspect}" unless variables.valid?
|
148
158
|
end
|
149
159
|
|
160
|
+
# @raise [Liquid::Error]
|
150
161
|
def interpolate_liquid(content, vars)
|
151
162
|
Liquid::Template.error_mode = :strict
|
152
163
|
template = Liquid::Template.parse(content)
|
153
|
-
|
164
|
+
|
165
|
+
# Wrap nil values in LiquidNull to not have Liquid consider them as undefined
|
166
|
+
vars = Hash[vars.map {|key, value| [key, value.nil? ? LiquidNull.new : value]}]
|
167
|
+
|
168
|
+
template.render!(vars, strict_variables: true, strict_filters: true)
|
154
169
|
end
|
155
170
|
|
156
171
|
def stack_name
|