kontena-cli 0.13.4 → 0.14.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/kontena-cli.gemspec +2 -0
- data/lib/kontena/cli/app_command.rb +2 -0
- data/lib/kontena/cli/apps/common.rb +80 -74
- data/lib/kontena/cli/apps/config_command.rb +29 -0
- data/lib/kontena/cli/apps/deploy_command.rb +12 -81
- data/lib/kontena/cli/apps/docker_helper.rb +3 -3
- data/lib/kontena/cli/apps/init_command.rb +0 -3
- data/lib/kontena/cli/apps/list_command.rb +2 -3
- data/lib/kontena/cli/apps/logs_command.rb +2 -3
- data/lib/kontena/cli/apps/monitor_command.rb +3 -4
- data/lib/kontena/cli/apps/remove_command.rb +4 -4
- data/lib/kontena/cli/apps/restart_command.rb +2 -3
- data/lib/kontena/cli/apps/scale_command.rb +3 -5
- data/lib/kontena/cli/apps/service_generator.rb +123 -0
- data/lib/kontena/cli/apps/service_generator_v2.rb +26 -0
- data/lib/kontena/cli/apps/show_command.rb +1 -2
- data/lib/kontena/cli/apps/start_command.rb +2 -3
- data/lib/kontena/cli/apps/stop_command.rb +2 -3
- data/lib/kontena/cli/apps/yaml/reader.rb +150 -0
- data/lib/kontena/cli/apps/yaml/service_extender.rb +60 -0
- data/lib/kontena/cli/apps/yaml/validations.rb +79 -0
- data/lib/kontena/cli/apps/yaml/validator.rb +55 -0
- data/lib/kontena/cli/apps/yaml/validator_v2.rb +74 -0
- data/lib/kontena/cli/common.rb +23 -0
- data/lib/kontena/cli/etcd/remove_command.rb +2 -0
- data/lib/kontena/cli/grids/remove_command.rb +2 -0
- data/lib/kontena/cli/grids/users/remove_command.rb +3 -0
- data/lib/kontena/cli/master/azure/create_command.rb +0 -2
- data/lib/kontena/cli/master/packet/create_command.rb +42 -0
- data/lib/kontena/cli/master/packet_command.rb +14 -0
- data/lib/kontena/cli/master/upcloud/create_command.rb +39 -0
- data/lib/kontena/cli/master/upcloud_command.rb +13 -0
- data/lib/kontena/cli/master/users/remove_command.rb +3 -0
- data/lib/kontena/cli/master/users/roles/remove_command.rb +2 -0
- data/lib/kontena/cli/master_command.rb +4 -0
- data/lib/kontena/cli/node_command.rb +4 -0
- data/lib/kontena/cli/nodes/azure/create_command.rb +0 -2
- data/lib/kontena/cli/nodes/list_command.rb +4 -8
- data/lib/kontena/cli/nodes/packet/create_command.rb +35 -0
- data/lib/kontena/cli/nodes/packet/restart_command.rb +17 -0
- data/lib/kontena/cli/nodes/packet/terminate_command.rb +20 -0
- data/lib/kontena/cli/nodes/packet_command.rb +15 -0
- data/lib/kontena/cli/nodes/remove_command.rb +2 -0
- data/lib/kontena/cli/nodes/show_command.rb +3 -1
- data/lib/kontena/cli/nodes/upcloud/create_command.rb +33 -0
- data/lib/kontena/cli/nodes/upcloud/restart_command.rb +20 -0
- data/lib/kontena/cli/nodes/upcloud/terminate_command.rb +20 -0
- data/lib/kontena/cli/nodes/upcloud_command.rb +15 -0
- data/lib/kontena/cli/registry/remove_command.rb +3 -0
- data/lib/kontena/cli/services/remove_command.rb +2 -0
- data/lib/kontena/cli/services/services_helper.rb +1 -0
- data/lib/kontena/cli/vault/list_command.rb +2 -0
- data/lib/kontena/cli/vault/read_command.rb +2 -0
- data/lib/kontena/cli/vault/remove_command.rb +4 -0
- data/lib/kontena/cli/vault/update_command.rb +8 -1
- data/lib/kontena/cli/vault/write_command.rb +2 -0
- data/lib/kontena/cli/vpn/remove_command.rb +3 -0
- data/lib/kontena/machine/azure/master_provisioner.rb +2 -2
- data/lib/kontena/machine/azure/node_provisioner.rb +7 -4
- data/lib/kontena/machine/digital_ocean/node_provisioner.rb +1 -1
- data/lib/kontena/machine/packet.rb +17 -0
- data/lib/kontena/machine/packet/cloudinit.yml +66 -0
- data/lib/kontena/machine/packet/cloudinit_master.yml +118 -0
- data/lib/kontena/machine/packet/master_provisioner.rb +93 -0
- data/lib/kontena/machine/packet/node_destroyer.rb +42 -0
- data/lib/kontena/machine/packet/node_provisioner.rb +77 -0
- data/lib/kontena/machine/packet/node_restarter.rb +41 -0
- data/lib/kontena/machine/packet/packet_common.rb +89 -0
- data/lib/kontena/machine/upcloud.rb +9 -0
- data/lib/kontena/machine/upcloud/cloudinit.yml +64 -0
- data/lib/kontena/machine/upcloud/cloudinit_master.yml +118 -0
- data/lib/kontena/machine/upcloud/master_provisioner.rb +136 -0
- data/lib/kontena/machine/upcloud/node_destroyer.rb +82 -0
- data/lib/kontena/machine/upcloud/node_provisioner.rb +119 -0
- data/lib/kontena/machine/upcloud/node_restarter.rb +47 -0
- data/lib/kontena/machine/upcloud/upcloud_common.rb +70 -0
- data/lib/kontena/scripts/completer +8 -3
- data/spec/fixtures/docker-compose_v2.yml +10 -0
- data/spec/fixtures/kontena-invalid.yml +4 -0
- data/spec/fixtures/kontena-with-variables.yml +19 -0
- data/spec/fixtures/kontena.yml +2 -2
- data/spec/fixtures/kontena_v2.yml +35 -0
- data/spec/kontena/cli/app/common_spec.rb +39 -101
- data/spec/kontena/cli/app/deploy_command_spec.rb +37 -388
- data/spec/kontena/cli/app/docker_helper_spec.rb +4 -4
- data/spec/kontena/cli/app/service_generator_spec.rb +374 -0
- data/spec/kontena/cli/app/service_generator_v2_spec.rb +74 -0
- data/spec/kontena/cli/app/yaml/reader_spec.rb +249 -0
- data/spec/kontena/cli/app/yaml/service_extender_spec.rb +104 -0
- data/spec/kontena/cli/app/yaml/validator_spec.rb +263 -0
- data/spec/kontena/cli/app/yaml/validator_v2_spec.rb +309 -0
- data/spec/kontena/cli/common_spec.rb +39 -1
- data/spec/kontena/cli/master/users/remove_command_spec.rb +9 -0
- data/spec/kontena/cli/master/users/roles/remove_command_spec.rb +2 -0
- metadata +86 -2
@@ -5,10 +5,13 @@ module Kontena::Cli::Master::Users
|
|
5
5
|
include Kontena::Cli::Common
|
6
6
|
|
7
7
|
parameter "EMAIL ...", "List of emails"
|
8
|
+
option "--force", :flag, "Force remove", default: false, attribute_name: :forced
|
8
9
|
|
9
10
|
def execute
|
10
11
|
require_api_url
|
11
12
|
token = require_token
|
13
|
+
confirm unless forced?
|
14
|
+
|
12
15
|
email_list.each do |email|
|
13
16
|
begin
|
14
17
|
client(token).delete("users/#{email}")
|
@@ -6,11 +6,13 @@ module Kontena::Cli::Master::Users::Roles
|
|
6
6
|
|
7
7
|
parameter "ROLE", "Role name"
|
8
8
|
parameter "USER ...", "List of users"
|
9
|
+
option "--force", :flag, "Force remove", default: false, attribute_name: :forced
|
9
10
|
|
10
11
|
|
11
12
|
def execute
|
12
13
|
require_api_url
|
13
14
|
token = require_token
|
15
|
+
confirm unless forced?
|
14
16
|
|
15
17
|
user_list.each do |email|
|
16
18
|
begin
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require_relative 'master/vagrant_command'
|
2
2
|
require_relative 'master/aws_command'
|
3
3
|
require_relative 'master/digital_ocean_command'
|
4
|
+
require_relative 'master/packet_command'
|
5
|
+
require_relative 'master/upcloud_command'
|
4
6
|
require_relative 'master/azure_command'
|
5
7
|
require_relative 'master/use_command'
|
6
8
|
require_relative 'master/list_command'
|
@@ -12,6 +14,8 @@ class Kontena::Cli::MasterCommand < Clamp::Command
|
|
12
14
|
subcommand "vagrant", "Vagrant specific commands", Kontena::Cli::Master::VagrantCommand
|
13
15
|
subcommand "aws", "AWS specific commands", Kontena::Cli::Master::AwsCommand
|
14
16
|
subcommand "digitalocean", "DigitalOcean specific commands", Kontena::Cli::Master::DigitalOceanCommand
|
17
|
+
subcommand "packet", "Packet specific commands", Kontena::Cli::Master::PacketCommand
|
18
|
+
subcommand "upcloud", "Upcloud specific commands", Kontena::Cli::Master::UpcloudCommand
|
15
19
|
subcommand "azure", "Azure specific commands", Kontena::Cli::Master::AzureCommand
|
16
20
|
subcommand ["list", "ls"], "List masters where client has logged in", Kontena::Cli::Master::ListCommand
|
17
21
|
subcommand "use", "Switch to use selected master", Kontena::Cli::Master::UseCommand
|
@@ -8,6 +8,8 @@ require_relative 'nodes/label_command'
|
|
8
8
|
|
9
9
|
require_relative 'nodes/vagrant_command'
|
10
10
|
require_relative 'nodes/digital_ocean_command'
|
11
|
+
require_relative 'nodes/packet_command'
|
12
|
+
require_relative 'nodes/upcloud_command'
|
11
13
|
require_relative 'nodes/aws_command'
|
12
14
|
require_relative 'nodes/azure_command'
|
13
15
|
|
@@ -23,6 +25,8 @@ class Kontena::Cli::NodeCommand < Clamp::Command
|
|
23
25
|
|
24
26
|
subcommand "vagrant", "Vagrant specific commands", Kontena::Cli::Nodes::VagrantCommand
|
25
27
|
subcommand "digitalocean", "DigitalOcean specific commands", Kontena::Cli::Nodes::DigitalOceanCommand
|
28
|
+
subcommand "packet", "Packet specific commands", Kontena::Cli::Nodes::PacketCommand
|
29
|
+
subcommand "upcloud", "Upcloud specific commands", Kontena::Cli::Nodes::UpcloudCommand
|
26
30
|
subcommand "aws", "AWS specific commands", Kontena::Cli::Nodes::AwsCommand
|
27
31
|
subcommand "azure", "Azure specific commands", Kontena::Cli::Nodes::AzureCommand
|
28
32
|
|
@@ -9,7 +9,6 @@ module Kontena::Cli::Nodes::Azure
|
|
9
9
|
option "--network", "NETWORK", "Virtual Network name"
|
10
10
|
option "--subnet", "SUBNET", "Subnet name"
|
11
11
|
option "--ssh-key", "SSH KEY", "SSH private key file", required: true
|
12
|
-
option "--password", "PASSWORD", "Password"
|
13
12
|
option "--location", "LOCATION", "Location", default: 'West Europe'
|
14
13
|
option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
|
15
14
|
|
@@ -26,7 +25,6 @@ module Kontena::Cli::Nodes::Azure
|
|
26
25
|
master_uri: api_url,
|
27
26
|
grid_token: grid['token'],
|
28
27
|
grid: current_grid,
|
29
|
-
password: password,
|
30
28
|
ssh_key: ssh_key,
|
31
29
|
name: name,
|
32
30
|
size: size,
|
@@ -31,17 +31,13 @@ module Kontena::Cli::Nodes
|
|
31
31
|
end
|
32
32
|
else
|
33
33
|
nodes = client(token).get("grids/#{current_grid}/nodes")
|
34
|
-
puts "%-70s %-10s %-40s" % ['Name', 'Status', 'Labels']
|
34
|
+
puts "%-70s %-10s %-10s %-40s" % ['Name', 'Status', 'Initial', 'Labels']
|
35
35
|
nodes = nodes['nodes'].sort_by{|n| n['node_number'] }
|
36
36
|
nodes.each do |node|
|
37
|
-
|
38
|
-
status = 'online'
|
39
|
-
else
|
40
|
-
status = 'offline'
|
41
|
-
end
|
42
|
-
puts "%-70.70s %-10s %-40s" % [
|
37
|
+
puts "%-70.70s %-10s %-10s %-40s" % [
|
43
38
|
node['name'],
|
44
|
-
|
39
|
+
node['connected'] ? 'online' : 'offline',
|
40
|
+
node['initial_member'] ? 'yes' : 'no',
|
45
41
|
(node['labels'] || ['-']).join(",")
|
46
42
|
]
|
47
43
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Kontena::Cli::Nodes::Packet
|
2
|
+
class CreateCommand < Clamp::Command
|
3
|
+
include Kontena::Cli::Common
|
4
|
+
include Kontena::Cli::GridOptions
|
5
|
+
|
6
|
+
parameter "[NAME]", "Node name"
|
7
|
+
option "--token", "TOKEN", "Packet API token", required: true
|
8
|
+
option "--project", "PROJECT ID", "Packet project id", required: true
|
9
|
+
option "--type", "TYPE", "Server type (baremetal_0, baremetal_1, ..)", default: 'baremetal_0', attribute_name: :plan
|
10
|
+
option "--facility", "FACILITY CODE", "Facility", default: 'ams1'
|
11
|
+
option "--billing", "BILLING", "Billing cycle", default: 'hourly'
|
12
|
+
option "--ssh-key", "PATH", "Path to ssh public key (optional)"
|
13
|
+
option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
|
14
|
+
|
15
|
+
def execute
|
16
|
+
require_api_url
|
17
|
+
require_current_grid
|
18
|
+
|
19
|
+
require 'kontena/machine/packet'
|
20
|
+
grid = client(require_token).get("grids/#{current_grid}")
|
21
|
+
provisioner = Kontena::Machine::Packet::NodeProvisioner.new(client(require_token), token)
|
22
|
+
provisioner.run!(
|
23
|
+
master_uri: api_url,
|
24
|
+
grid_token: grid['token'],
|
25
|
+
grid: current_grid,
|
26
|
+
project: project,
|
27
|
+
billing: billing,
|
28
|
+
ssh_key: ssh_key,
|
29
|
+
plan: plan,
|
30
|
+
facility: facility,
|
31
|
+
version: version
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Kontena::Cli::Nodes::Packet
|
2
|
+
class RestartCommand < Clamp::Command
|
3
|
+
include Kontena::Cli::Common
|
4
|
+
include Kontena::Cli::GridOptions
|
5
|
+
|
6
|
+
parameter "NAME", "Node name"
|
7
|
+
option "--token", "TOKEN", "Packet API token", required: true
|
8
|
+
option "--project", "PROJECT ID", "Packet project id", required: true
|
9
|
+
|
10
|
+
def execute
|
11
|
+
require 'kontena/machine/packet'
|
12
|
+
|
13
|
+
restarter = Kontena::Machine::Packet::NodeRestarter.new(token)
|
14
|
+
restarter.run!(project, name)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Kontena::Cli::Nodes::Packet
|
2
|
+
class TerminateCommand < Clamp::Command
|
3
|
+
include Kontena::Cli::Common
|
4
|
+
include Kontena::Cli::GridOptions
|
5
|
+
|
6
|
+
parameter "NAME", "Node name"
|
7
|
+
option "--token", "TOKEN", "Packet API token", required: true
|
8
|
+
option "--project", "PROJECT ID", "Packet project id", required: true
|
9
|
+
|
10
|
+
def execute
|
11
|
+
require_api_url
|
12
|
+
require_current_grid
|
13
|
+
|
14
|
+
require 'kontena/machine/packet'
|
15
|
+
grid = client(require_token).get("grids/#{current_grid}")
|
16
|
+
destroyer = Kontena::Machine::Packet::NodeDestroyer.new(client(require_token), token)
|
17
|
+
destroyer.run!(grid, project, name)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative 'packet/create_command'
|
2
|
+
require_relative 'packet/restart_command'
|
3
|
+
require_relative 'packet/terminate_command'
|
4
|
+
|
5
|
+
module Kontena::Cli::Nodes
|
6
|
+
class PacketCommand < Clamp::Command
|
7
|
+
|
8
|
+
subcommand "create", "Create a new Packet node", Packet::CreateCommand
|
9
|
+
subcommand "restart", "Restart a Packet node", Packet::RestartCommand
|
10
|
+
subcommand "terminate", "Terminate a Packet node", Packet::TerminateCommand
|
11
|
+
|
12
|
+
def execute
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -4,11 +4,13 @@ module Kontena::Cli::Nodes
|
|
4
4
|
include Kontena::Cli::GridOptions
|
5
5
|
|
6
6
|
parameter "NODE_ID", "Node id"
|
7
|
+
option "--force", :flag, "Force remove", default: false, attribute_name: :forced
|
7
8
|
|
8
9
|
def execute
|
9
10
|
require_api_url
|
10
11
|
require_current_grid
|
11
12
|
token = require_token
|
13
|
+
confirm_command(node_id) unless forced?
|
12
14
|
|
13
15
|
client(token).delete("grids/#{current_grid}/nodes/#{node_id}")
|
14
16
|
end
|
@@ -14,15 +14,17 @@ module Kontena::Cli::Nodes
|
|
14
14
|
node = client(token).get("grids/#{current_grid}/nodes/#{node_id}")
|
15
15
|
puts "#{node['name']}:"
|
16
16
|
puts " id: #{node['id']}"
|
17
|
+
puts " agent version: #{node['agent_version']}"
|
17
18
|
puts " connected: #{node['connected'] ? 'yes': 'no'}"
|
18
19
|
puts " last connect: #{node['updated_at']}"
|
19
20
|
puts " last seen: #{node['last_seen_at']}"
|
20
21
|
puts " public ip: #{node['public_ip']}"
|
21
22
|
puts " private ip: #{node['private_ip']}"
|
22
|
-
puts " overlay
|
23
|
+
puts " overlay ip: 10.81.0.#{node['node_number']}"
|
23
24
|
puts " os: #{node['os']}"
|
24
25
|
puts " driver: #{node['driver']}"
|
25
26
|
puts " kernel: #{node['kernel_version']}"
|
27
|
+
puts " initial node: #{node['initial_member'] ? 'yes' : 'no'}"
|
26
28
|
puts " labels:"
|
27
29
|
if node['labels']
|
28
30
|
node['labels'].each{|l| puts " - #{l}"}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Kontena::Cli::Nodes::Upcloud
|
2
|
+
class CreateCommand < Clamp::Command
|
3
|
+
include Kontena::Cli::Common
|
4
|
+
include Kontena::Cli::GridOptions
|
5
|
+
|
6
|
+
parameter "[NAME]", "Node name"
|
7
|
+
option "--username", "USER", "Upcloud username", required: true
|
8
|
+
option "--password", "PASS", "Upcloud password", required: true
|
9
|
+
option "--ssh-key", "SSH_KEY", "Path to ssh public key", required: true
|
10
|
+
option "--plan", "PLAN", "Server size", default: '1xCPU-1GB'
|
11
|
+
option "--zone", "ZONE", "Zone", default: 'fi-hel1'
|
12
|
+
option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
|
13
|
+
|
14
|
+
def execute
|
15
|
+
require_api_url
|
16
|
+
require_current_grid
|
17
|
+
|
18
|
+
require 'kontena/machine/upcloud'
|
19
|
+
grid = client(require_token).get("grids/#{current_grid}")
|
20
|
+
provisioner = Kontena::Machine::Upcloud::NodeProvisioner.new(client(require_token), username, password)
|
21
|
+
provisioner.run!(
|
22
|
+
master_uri: api_url,
|
23
|
+
grid_token: grid['token'],
|
24
|
+
grid: current_grid,
|
25
|
+
ssh_key: ssh_key,
|
26
|
+
name: name,
|
27
|
+
plan: plan,
|
28
|
+
zone: zone,
|
29
|
+
version: version
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Kontena::Cli::Nodes::Upcloud
|
2
|
+
class RestartCommand < Clamp::Command
|
3
|
+
include Kontena::Cli::Common
|
4
|
+
include Kontena::Cli::GridOptions
|
5
|
+
|
6
|
+
parameter "NAME", "Node name"
|
7
|
+
option "--username", "USER", "Upcloud username", required: true
|
8
|
+
option "--password", "PASS", "Upcloud password", required: true
|
9
|
+
|
10
|
+
def execute
|
11
|
+
require_api_url
|
12
|
+
require_current_grid
|
13
|
+
|
14
|
+
require 'kontena/machine/upcloud'
|
15
|
+
|
16
|
+
restarter = Kontena::Machine::Upcloud::NodeRestarter.new(username, password)
|
17
|
+
restarter.run!(name)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Kontena::Cli::Nodes::Upcloud
|
2
|
+
class TerminateCommand < Clamp::Command
|
3
|
+
include Kontena::Cli::Common
|
4
|
+
include Kontena::Cli::GridOptions
|
5
|
+
|
6
|
+
parameter "NAME", "Node name"
|
7
|
+
option "--username", "USER", "Upcloud username", required: true
|
8
|
+
option "--password", "PASS", "Upcloud password", required: true
|
9
|
+
|
10
|
+
def execute
|
11
|
+
require_api_url
|
12
|
+
require_current_grid
|
13
|
+
|
14
|
+
require 'kontena/machine/upcloud'
|
15
|
+
grid = client(require_token).get("grids/#{current_grid}")
|
16
|
+
destroyer = Kontena::Machine::Upcloud::NodeDestroyer.new(client(require_token), username, password)
|
17
|
+
destroyer.run!(grid, name)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative 'upcloud/create_command'
|
2
|
+
require_relative 'upcloud/restart_command'
|
3
|
+
require_relative 'upcloud/terminate_command'
|
4
|
+
|
5
|
+
module Kontena::Cli::Nodes
|
6
|
+
class UpcloudCommand < Clamp::Command
|
7
|
+
|
8
|
+
subcommand "create", "Create a new Upcloud node", Upcloud::CreateCommand
|
9
|
+
subcommand "restart", "Restart Upcloud node", Upcloud::RestartCommand
|
10
|
+
subcommand "terminate", "Terminate Upcloud node", Upcloud::TerminateCommand
|
11
|
+
|
12
|
+
def execute
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -2,9 +2,12 @@ module Kontena::Cli::Registry
|
|
2
2
|
class RemoveCommand < Clamp::Command
|
3
3
|
include Kontena::Cli::Common
|
4
4
|
|
5
|
+
option "--force", :flag, "Force remove", default: false, attribute_name: :forced
|
6
|
+
|
5
7
|
def execute
|
6
8
|
require_api_url
|
7
9
|
token = require_token
|
10
|
+
confirm unless forced?
|
8
11
|
|
9
12
|
registry = client(token).get("services/#{current_grid}/registry") rescue nil
|
10
13
|
abort("Docker Registry service does not exist") if registry.nil?
|
@@ -6,10 +6,12 @@ module Kontena::Cli::Services
|
|
6
6
|
include ServicesHelper
|
7
7
|
|
8
8
|
parameter "NAME", "Service name"
|
9
|
+
option "--force", :flag, "Force remove", default: false, attribute_name: :forced
|
9
10
|
|
10
11
|
def execute
|
11
12
|
require_api_url
|
12
13
|
token = require_token
|
14
|
+
confirm_command(name) unless forced?
|
13
15
|
|
14
16
|
result = client(token).delete("services/#{parse_service_id(name)}")
|
15
17
|
end
|
@@ -202,6 +202,7 @@ module Kontena
|
|
202
202
|
# @param [String] name
|
203
203
|
def wait_for_deploy_to_finish(token, name)
|
204
204
|
ShellSpinner " " do
|
205
|
+
sleep 1 # wait for master to process deploy request and change state to 'deploying'
|
205
206
|
until client(token).get("services/#{name}")['state'] != 'deploying' do
|
206
207
|
sleep 1
|
207
208
|
end
|
@@ -4,9 +4,13 @@ module Kontena::Cli::Vault
|
|
4
4
|
include Kontena::Cli::GridOptions
|
5
5
|
|
6
6
|
parameter "NAME", "Secret name"
|
7
|
+
option "--force", :flag, "Force remove", default: false, attribute_name: :forced
|
7
8
|
|
8
9
|
def execute
|
9
10
|
require_api_url
|
11
|
+
require_current_grid
|
12
|
+
confirm_command(name) unless forced?
|
13
|
+
|
10
14
|
token = require_token
|
11
15
|
client(token).delete("secrets/#{current_grid}/#{name}")
|
12
16
|
end
|
@@ -4,16 +4,23 @@ module Kontena::Cli::Vault
|
|
4
4
|
|
5
5
|
parameter 'NAME', 'Secret name'
|
6
6
|
parameter '[VALUE]', 'Secret value'
|
7
|
+
option ['-u', '--upsert'], :flag, 'Create secret unless already exists', default: false
|
7
8
|
|
8
9
|
def execute
|
9
10
|
require_api_url
|
11
|
+
require_current_grid
|
12
|
+
|
10
13
|
token = require_token
|
11
14
|
secret = value
|
12
15
|
if secret.to_s == ''
|
13
16
|
secret = STDIN.read
|
14
17
|
end
|
15
18
|
abort('No value provided') if secret.to_s == ''
|
16
|
-
data = {
|
19
|
+
data = {
|
20
|
+
name: name,
|
21
|
+
value: secret,
|
22
|
+
upsert: upsert?
|
23
|
+
}
|
17
24
|
client(token).put("grids/#{current_grid}/secrets/#{name}", data)
|
18
25
|
end
|
19
26
|
end
|