kontena-cli 0.12.3 → 0.13.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 +6 -4
- data/lib/kontena/cli/apps/common.rb +21 -7
- data/lib/kontena/cli/apps/deploy_command.rb +11 -4
- data/lib/kontena/cli/apps/docker_helper.rb +12 -0
- data/lib/kontena/cli/apps/logs_command.rb +0 -2
- data/lib/kontena/cli/apps/remove_command.rb +23 -14
- data/lib/kontena/cli/bytes_helper.rb +40 -0
- data/lib/kontena/cli/container_command.rb +0 -1
- data/lib/kontena/cli/grid_command.rb +4 -6
- data/lib/kontena/cli/grids/logs_command.rb +0 -2
- data/lib/kontena/cli/grids/trusted_subnet_command.rb +12 -0
- data/lib/kontena/cli/grids/trusted_subnets/add_command.rb +16 -0
- data/lib/kontena/cli/grids/trusted_subnets/list_command.rb +17 -0
- data/lib/kontena/cli/grids/trusted_subnets/remove_command.rb +20 -0
- data/lib/kontena/cli/grids/user_command.rb +12 -0
- data/lib/kontena/cli/grids/{add_user_command.rb → users/add_command.rb} +4 -4
- data/lib/kontena/cli/grids/{list_users_command.rb → users/list_command.rb} +4 -4
- data/lib/kontena/cli/grids/{remove_user_command.rb → users/remove_command.rb} +4 -4
- data/lib/kontena/cli/login_command.rb +4 -3
- data/lib/kontena/cli/master/aws/create_command.rb +3 -1
- data/lib/kontena/cli/master/current_command.rb +17 -0
- data/lib/kontena/cli/master/digital_ocean/create_command.rb +5 -3
- data/lib/kontena/cli/master/users/role_command.rb +10 -0
- data/lib/kontena/cli/master/users/{add_role_command.rb → roles/add_command.rb} +4 -4
- data/lib/kontena/cli/master/users/{remove_role_command.rb → roles/remove_command.rb} +4 -4
- data/lib/kontena/cli/master/users_command.rb +2 -4
- data/lib/kontena/cli/master_command.rb +2 -0
- data/lib/kontena/cli/node_command.rb +2 -4
- data/lib/kontena/cli/nodes/label_command.rb +14 -0
- data/lib/kontena/cli/nodes/{add_label_command.rb → labels/add_command.rb} +2 -2
- data/lib/kontena/cli/nodes/{remove_label_command.rb → labels/remove_command.rb} +2 -2
- data/lib/kontena/cli/nodes/list_command.rb +2 -1
- data/lib/kontena/cli/nodes/show_command.rb +19 -2
- data/lib/kontena/cli/registry_command.rb +0 -1
- data/lib/kontena/cli/service_command.rb +4 -11
- data/lib/kontena/cli/services/create_command.rb +10 -2
- data/lib/kontena/cli/services/env_command.rb +12 -0
- data/lib/kontena/cli/services/{add_env_command.rb → envs/add_command.rb} +4 -4
- data/lib/kontena/cli/services/{envs_command.rb → envs/list_command.rb} +5 -5
- data/lib/kontena/cli/services/{remove_env_command.rb → envs/remove_command.rb} +4 -4
- data/lib/kontena/cli/services/list_command.rb +3 -2
- data/lib/kontena/cli/services/logs_command.rb +0 -2
- data/lib/kontena/cli/services/secret_command.rb +10 -0
- data/lib/kontena/cli/services/{add_secret_command.rb → secrets/link_command.rb} +4 -4
- data/lib/kontena/cli/services/{remove_secret_command.rb → secrets/unlink_command.rb} +4 -4
- data/lib/kontena/cli/services/services_helper.rb +35 -8
- data/lib/kontena/cli/services/stats_command.rb +6 -1
- data/lib/kontena/cli/services/update_command.rb +4 -0
- data/lib/kontena/cli/user/forgot_password_command.rb +16 -0
- data/lib/kontena/cli/user/reset_password_command.rb +23 -0
- data/lib/kontena/cli/user/verify_command.rb +22 -0
- data/lib/kontena/cli/user_command.rb +13 -0
- data/lib/kontena/cli/vault/list_command.rb +1 -1
- data/lib/kontena/cli/vpn_command.rb +0 -1
- data/lib/kontena/cli/whoami_command.rb +17 -3
- data/lib/kontena/machine/aws/cloudinit_master.yml +13 -4
- data/lib/kontena/machine/aws/common.rb +8 -13
- data/lib/kontena/machine/aws/master_provisioner.rb +6 -5
- data/lib/kontena/machine/azure/cloudinit_master.yml +0 -2
- data/lib/kontena/machine/digital_ocean.rb +1 -0
- data/lib/kontena/machine/digital_ocean/cloudinit.yml +0 -22
- data/lib/kontena/machine/digital_ocean/cloudinit_master.yml +14 -4
- data/lib/kontena/machine/digital_ocean/master_provisioner.rb +12 -9
- data/lib/kontena/machine/vagrant/cloudinit.yml +2 -0
- data/lib/kontena/scripts/completer +4 -4
- data/spec/kontena/cli/app/common_spec.rb +55 -7
- data/spec/kontena/cli/app/docker_helper_spec.rb +74 -0
- data/spec/kontena/cli/grids/trusted_subnets/add_command_spec.rb +38 -0
- data/spec/kontena/cli/grids/trusted_subnets/list_command_spec.rb +31 -0
- data/spec/kontena/cli/grids/trusted_subnets/remove_command_spec.rb +38 -0
- data/spec/kontena/cli/master/current_command_spec.rb +57 -0
- data/spec/kontena/cli/master/users/{add_role_command_spec.rb → roles/add_command_spec.rb} +3 -3
- data/spec/kontena/cli/master/users/{remove_role_command_spec.rb → roles/remove_command_spec.rb} +3 -3
- data/spec/kontena/cli/services/{add_secret_command_spec.rb → secrets/link_command_spec.rb} +4 -3
- data/spec/kontena/cli/services/{remove_secret_command_spec.rb → secrets/unlink_command_spec.rb} +4 -3
- data/spec/kontena/cli/services/services_helper_spec.rb +44 -0
- metadata +45 -26
- data/lib/kontena/cli/forgot_password_command.rb +0 -13
- data/lib/kontena/cli/reset_password_command.rb +0 -19
- data/lib/kontena/cli/users_command.rb +0 -15
- data/lib/kontena/cli/verify_account_command.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 109ecadbdb72e79172f5be44a7c0a38143c6d2a3
|
4
|
+
data.tar.gz: 5198dbcf298ffbcc0e84f4305800b3ed7f64c85a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b385cb691cb135cf2de46abcff1d4784ef8aca31420fab414635f626e88a398946dba7e545f308b54d2951b762a9850a4bc2739ca23ce0d0cf3ef5cbb7caeb6
|
7
|
+
data.tar.gz: d6dfa8ffa29cf4ac9b2641f87ab7322f4455483e63f4e0ab0f64d57c88d26845177a59dfc990c0a7aa86752cde0b1e4590a50f6247d4e4599d66e946953efb2b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.13.0
|
data/bin/kontena
CHANGED
@@ -14,6 +14,7 @@ require 'clamp'
|
|
14
14
|
require 'ruby_dig'
|
15
15
|
require 'kontena/client'
|
16
16
|
require 'kontena/cli/common'
|
17
|
+
require 'kontena/cli/bytes_helper'
|
17
18
|
require 'kontena/cli/grid_options'
|
18
19
|
require 'kontena/cli/app_command'
|
19
20
|
require 'kontena/cli/register_command'
|
@@ -34,6 +35,7 @@ require 'kontena/cli/external_registry_command'
|
|
34
35
|
require 'kontena/cli/app_command'
|
35
36
|
require 'kontena/cli/etcd_command'
|
36
37
|
require 'kontena/cli/vault_command'
|
38
|
+
require 'kontena/cli/user_command'
|
37
39
|
require 'kontena/cli/version_command'
|
38
40
|
|
39
41
|
class MainCommand < Clamp::Command
|
@@ -53,9 +55,7 @@ class MainCommand < Clamp::Command
|
|
53
55
|
subcommand "login", "Login to Kontena Master", Kontena::Cli::LoginCommand
|
54
56
|
subcommand "logout", "Logout from Kontena Master", Kontena::Cli::LogoutCommand
|
55
57
|
subcommand "whoami", "Shows current logged in user", Kontena::Cli::WhoamiCommand
|
56
|
-
subcommand "
|
57
|
-
subcommand "forgot-password", "Request password reset for Kontena account", Kontena::Cli::ForgotPasswordCommand
|
58
|
-
subcommand "reset-password", "Reset Kontena account password", Kontena::Cli::ResetPasswordCommand
|
58
|
+
subcommand "user", "User related commands", Kontena::Cli::UserCommand
|
59
59
|
subcommand "version", "Show version", Kontena::Cli::VersionCommand
|
60
60
|
|
61
61
|
def execute
|
@@ -77,6 +77,8 @@ rescue => exc
|
|
77
77
|
if ENV['DEBUG']
|
78
78
|
raise exc
|
79
79
|
else
|
80
|
-
|
80
|
+
puts "Kontena error: #{exc.message}"
|
81
|
+
puts "Rerun the command with environment DEBUG=true set to get full the exception"
|
82
|
+
abort()
|
81
83
|
end
|
82
84
|
end
|
@@ -75,7 +75,8 @@ module Kontena::Cli::Apps
|
|
75
75
|
# @return [Hash]
|
76
76
|
def extend_options(options, file, service_name, prefix)
|
77
77
|
parent_options = parse_services(file, service_name, prefix)
|
78
|
-
options['environment'] = extend_env_vars(parent_options, options)
|
78
|
+
options['environment'] = extend_env_vars(parent_options['environment'], options['environment'])
|
79
|
+
options['secrets'] = extend_secrets(parent_options['secrets'], options['secrets'])
|
79
80
|
parent_options.merge(options)
|
80
81
|
end
|
81
82
|
|
@@ -86,19 +87,32 @@ module Kontena::Cli::Apps
|
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
89
|
-
# @param [
|
90
|
-
# @param [
|
90
|
+
# @param [Array] from
|
91
|
+
# @param [Array] to
|
91
92
|
# @return [Array]
|
92
93
|
def extend_env_vars(from, to)
|
93
|
-
env_vars = to
|
94
|
-
if from
|
95
|
-
from
|
96
|
-
env_vars << env unless to
|
94
|
+
env_vars = to || []
|
95
|
+
if from
|
96
|
+
from.each do |env|
|
97
|
+
env_vars << env unless to && to.find {|key| key.split('=').first == env.split('=').first}
|
97
98
|
end
|
98
99
|
end
|
99
100
|
env_vars
|
100
101
|
end
|
101
102
|
|
103
|
+
# @param [Array] from
|
104
|
+
# @param [Array] to
|
105
|
+
# @return [Array]
|
106
|
+
def extend_secrets(from, to)
|
107
|
+
secrets = to || []
|
108
|
+
if from
|
109
|
+
from.each do |from_secret|
|
110
|
+
secrets << from_secret unless to && to.any? {|to_secret| to_secret['secret'] == from_secret['secret']}
|
111
|
+
end
|
112
|
+
end
|
113
|
+
secrets
|
114
|
+
end
|
115
|
+
|
102
116
|
# @param [Hash] services
|
103
117
|
# @param [String] file
|
104
118
|
def create_yml(services, file = 'kontena.yml')
|
@@ -149,8 +149,8 @@ module Kontena::Cli::Apps
|
|
149
149
|
data[:container_count] = options['instances']
|
150
150
|
data[:links] = parse_links(options['links'] || [])
|
151
151
|
data[:ports] = parse_ports(options['ports'] || [])
|
152
|
-
data[:memory] = parse_memory(options['mem_limit']) if options['mem_limit']
|
153
|
-
data[:memory_swap] = parse_memory(options['memswap_limit']) if options['memswap_limit']
|
152
|
+
data[:memory] = parse_memory(options['mem_limit'].to_s) if options['mem_limit']
|
153
|
+
data[:memory_swap] = parse_memory(options['memswap_limit'].to_s) if options['memswap_limit']
|
154
154
|
data[:cpu_shares] = options['cpu_shares'] if options['cpu_shares']
|
155
155
|
data[:volumes] = options['volumes'] || []
|
156
156
|
data[:volumes_from] = options['volumes_from'] || []
|
@@ -169,8 +169,15 @@ module Kontena::Cli::Apps
|
|
169
169
|
deploy_opts = options['deploy'] || {}
|
170
170
|
data[:strategy] = deploy_opts['strategy'] if deploy_opts['strategy']
|
171
171
|
deploy = {}
|
172
|
-
|
173
|
-
|
172
|
+
if deploy_opts.has_key?('wait_for_port')
|
173
|
+
deploy[:wait_for_port] = deploy_opts['wait_for_port']
|
174
|
+
end
|
175
|
+
if deploy_opts.has_key?('min_health')
|
176
|
+
deploy[:min_health] = deploy_opts['min_health']
|
177
|
+
end
|
178
|
+
if deploy_opts.has_key?('interval')
|
179
|
+
deploy[:interval] = parse_relative_time(deploy_opts['interval'])
|
180
|
+
end
|
174
181
|
unless deploy.empty?
|
175
182
|
data[:deploy_opts] = deploy
|
176
183
|
end
|
@@ -15,6 +15,10 @@ module Kontena::Cli::Apps
|
|
15
15
|
dockerfile = service['dockerfile'] || 'Dockerfile'
|
16
16
|
abort("'#{service['image']}' is not valid Docker image name") unless validate_image_name(service['image'])
|
17
17
|
abort("'#{service['build']}' does not have #{dockerfile}") unless dockerfile_exist?(service['build'], dockerfile)
|
18
|
+
if service['hooks'] && service['hooks']['pre_build']
|
19
|
+
puts "Running pre_build hook".colorize(:cyan)
|
20
|
+
run_pre_build_hook(service['hooks']['pre_build'])
|
21
|
+
end
|
18
22
|
puts "Building image #{service['image'].colorize(:cyan)}"
|
19
23
|
build_docker_image(service['image'], service['build'], dockerfile, no_cache)
|
20
24
|
puts "Pushing image #{service['image'].colorize(:cyan)} to registry"
|
@@ -65,5 +69,13 @@ module Kontena::Cli::Apps
|
|
65
69
|
file = File.join(File.expand_path(path), dockerfile)
|
66
70
|
File.exist?(file)
|
67
71
|
end
|
72
|
+
|
73
|
+
# @param [Hash] hook
|
74
|
+
def run_pre_build_hook(hook)
|
75
|
+
hook.each do |h|
|
76
|
+
ret = system(h['cmd'])
|
77
|
+
abort("Failed to run pre_build hook: #{h['name']}!".colorize(:red)) unless ret
|
78
|
+
end
|
79
|
+
end
|
68
80
|
end
|
69
81
|
end
|
@@ -10,7 +10,6 @@ module Kontena::Cli::Apps
|
|
10
10
|
option ['-p', '--project-name'], 'NAME', 'Specify an alternate project name (default: directory name)'
|
11
11
|
option ["-l", "--lines"], "LINES", "How many lines to show", default: '100'
|
12
12
|
option "--since", "SINCE", "Show logs since given timestamp"
|
13
|
-
option ["-s", "--search"], "SEARCH", "Search from logs"
|
14
13
|
option ["-t", "--tail"], :flag, "Tail (follow) logs", default: false
|
15
14
|
parameter "[SERVICE] ...", "Show only specified service logs"
|
16
15
|
|
@@ -36,7 +35,6 @@ module Kontena::Cli::Apps
|
|
36
35
|
query_params << "from=#{last_id}" unless last_id.nil?
|
37
36
|
query_params << "limit=#{lines}"
|
38
37
|
query_params << "since=#{since}" if !since.nil? && last_id.nil?
|
39
|
-
query_params << "search=#{search}" if search
|
40
38
|
logs = []
|
41
39
|
services.each do |service_name, opts|
|
42
40
|
service = get_service(token, prefixed_name(service_name)) rescue false
|
@@ -28,34 +28,43 @@ module Kontena::Cli::Apps
|
|
28
28
|
|
29
29
|
end
|
30
30
|
|
31
|
+
private
|
31
32
|
def remove_services(services)
|
32
33
|
services.find_all {|service_name, options| options['links'] && options['links'].size > 0 }.each do |service_name, options|
|
33
|
-
delete(service_name, options)
|
34
|
+
delete(service_name, options, false)
|
34
35
|
services.delete(service_name)
|
35
|
-
sleep 1
|
36
36
|
end
|
37
37
|
services.each do |service_name, options|
|
38
38
|
delete(service_name, options)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def delete(name, options)
|
42
|
+
def delete(name, options, async = true)
|
43
43
|
unless deleted_services.include?(name)
|
44
|
-
print "deleting #{name}"
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
44
|
+
print "deleting #{name.colorize(:cyan)}"
|
45
|
+
ShellSpinner " " do
|
46
|
+
service = get_service(token, prefixed_name(name)) rescue nil
|
47
|
+
if(service)
|
48
|
+
delete_service(token, prefixed_name(name))
|
49
|
+
unless async
|
50
|
+
wait_for_delete_to_finish(service)
|
51
|
+
end
|
52
|
+
deleted_services << name
|
53
|
+
else
|
54
|
+
puts "No such service: #{name}".colorize(:red)
|
55
|
+
end
|
55
56
|
end
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
60
|
+
def wait_for_delete_to_finish(service)
|
61
|
+
until service.nil?
|
62
|
+
service = get_service(token, service['name']) rescue nil
|
63
|
+
sleep 0.5
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
59
68
|
##
|
60
69
|
#
|
61
70
|
# @return [Array]
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Kontena
|
2
|
+
module Cli
|
3
|
+
module BytesHelper
|
4
|
+
|
5
|
+
KILOBYTE = 1024
|
6
|
+
MEGABYTE = KILOBYTE * 1024
|
7
|
+
GIGABYTE = MEGABYTE * 1024
|
8
|
+
TERABYTE = GIGABYTE * 1024
|
9
|
+
|
10
|
+
def to_kilobytes(bytes, ndigits=nil)
|
11
|
+
return 0.0 if bytes.nil?
|
12
|
+
round(bytes.to_f / KILOBYTE, ndigits)
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_megabytes(bytes, ndigits=nil)
|
16
|
+
return 0.0 if bytes.nil?
|
17
|
+
round(bytes.to_f / MEGABYTE, ndigits)
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_gigabytes(bytes, ndigits=nil)
|
21
|
+
return 0.0 if bytes.nil?
|
22
|
+
round(bytes.to_f / GIGABYTE, ndigits)
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_terabytes(bytes, ndigits)
|
26
|
+
return 0.0 if bytes.nil?
|
27
|
+
round(bytes.to_f / TERABYTE, ndigits)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
def round(value, ndigits=nil)
|
32
|
+
if ndigits.nil?
|
33
|
+
return value
|
34
|
+
end
|
35
|
+
value.round(ndigits)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -4,7 +4,6 @@ require_relative 'containers/inspect_command'
|
|
4
4
|
class Kontena::Cli::ContainerCommand < Clamp::Command
|
5
5
|
|
6
6
|
subcommand "exec", "Execute command inside a container", Kontena::Cli::Containers::ExecCommand
|
7
|
-
|
8
7
|
subcommand "inspect", "Inspect the container", Kontena::Cli::Containers::InspectCommand
|
9
8
|
|
10
9
|
def execute
|
@@ -8,10 +8,9 @@ require_relative 'grids/remove_command'
|
|
8
8
|
require_relative 'grids/current_command'
|
9
9
|
require_relative 'grids/env_command'
|
10
10
|
require_relative 'grids/audit_log_command'
|
11
|
-
require_relative 'grids/
|
12
|
-
require_relative 'grids/add_user_command'
|
13
|
-
require_relative 'grids/remove_user_command'
|
11
|
+
require_relative 'grids/user_command'
|
14
12
|
require_relative 'grids/cloud_config_command'
|
13
|
+
require_relative 'grids/trusted_subnet_command'
|
15
14
|
|
16
15
|
class Kontena::Cli::GridCommand < Clamp::Command
|
17
16
|
|
@@ -25,10 +24,9 @@ class Kontena::Cli::GridCommand < Clamp::Command
|
|
25
24
|
subcommand "current", "Show current grid details", Kontena::Cli::Grids::CurrentCommand
|
26
25
|
subcommand "env", "Show the current grid environment details", Kontena::Cli::Grids::EnvCommand
|
27
26
|
subcommand "audit-log", "Show audit log of the current grid", Kontena::Cli::Grids::AuditLogCommand
|
28
|
-
subcommand "
|
29
|
-
subcommand "add-user", "Add user to the current grid", Kontena::Cli::Grids::AddUserCommand
|
30
|
-
subcommand "remove-user", "Remove user from the current grid", Kontena::Cli::Grids::RemoveUserCommand
|
27
|
+
subcommand "user", "User specific commands", Kontena::Cli::Grids::UserCommand
|
31
28
|
subcommand "cloud-config", "Generate cloud-config", Kontena::Cli::Grids::CloudConfigCommand
|
29
|
+
subcommand "trusted-subnet", "Trusted subnet related commands", Kontena::Cli::Grids::TrustedSubnetCommand
|
32
30
|
|
33
31
|
def execute
|
34
32
|
end
|
@@ -3,7 +3,6 @@ module Kontena::Cli::Grids
|
|
3
3
|
include Kontena::Cli::Common
|
4
4
|
|
5
5
|
option ["-t", "--tail"], :flag, "Tail (follow) logs", default: false
|
6
|
-
option ["-s", "--search"], "SEARCH", "Search from logs"
|
7
6
|
option "--lines", "LINES", "Number of lines to show from the end of the logs"
|
8
7
|
option "--since", "SINCE", "Show logs since given timestamp"
|
9
8
|
option "--node", "NODE", "Filter by node name", multivalued: true
|
@@ -18,7 +17,6 @@ module Kontena::Cli::Grids
|
|
18
17
|
query_params[:nodes] = node_list.join(",") unless node_list.empty?
|
19
18
|
query_params[:services] = service_list.join(",") unless service_list.empty?
|
20
19
|
query_params[:containers] = container_list.join(",") unless container_list.empty?
|
21
|
-
query_params[:search] = search if search
|
22
20
|
query_params[:limit] = lines if lines
|
23
21
|
query_params[:since] = since if since
|
24
22
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Kontena::Cli::Grids
|
2
|
+
|
3
|
+
require_relative 'trusted_subnets/list_command'
|
4
|
+
require_relative 'trusted_subnets/add_command'
|
5
|
+
require_relative 'trusted_subnets/remove_command'
|
6
|
+
|
7
|
+
class TrustedSubnetCommand < Clamp::Command
|
8
|
+
subcommand ["list", "ls"], "List trusted subnets", TrustedSubnets::ListCommand
|
9
|
+
subcommand "add", "Add trusted subnet", TrustedSubnets::AddCommand
|
10
|
+
subcommand ["remove", "rm"], "Remove trusted subnet", TrustedSubnets::RemoveCommand
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Kontena::Cli::Grids::TrustedSubnets
|
2
|
+
class AddCommand < Clamp::Command
|
3
|
+
include Kontena::Cli::Common
|
4
|
+
|
5
|
+
parameter "NAME", "Grid name"
|
6
|
+
parameter "SUBNET", "Trusted subnet"
|
7
|
+
|
8
|
+
def execute
|
9
|
+
require_api_url
|
10
|
+
token = require_token
|
11
|
+
grid = client(token).get("grids/#{name}")
|
12
|
+
data = {trusted_subnets: grid['trusted_subnets'] + [self.subnet]}
|
13
|
+
client(token).put("grids/#{name}", data)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Kontena::Cli::Grids::TrustedSubnets
|
2
|
+
class ListCommand < Clamp::Command
|
3
|
+
include Kontena::Cli::Common
|
4
|
+
|
5
|
+
parameter "NAME", "Grid name"
|
6
|
+
|
7
|
+
def execute
|
8
|
+
require_api_url
|
9
|
+
token = require_token
|
10
|
+
grid = client(token).get("grids/#{current_grid}")
|
11
|
+
trusted_subnets = grid['trusted_subnets'] || []
|
12
|
+
trusted_subnets.each do |subnet|
|
13
|
+
puts subnet
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Kontena::Cli::Grids::TrustedSubnets
|
2
|
+
class RemoveCommand < Clamp::Command
|
3
|
+
include Kontena::Cli::Common
|
4
|
+
|
5
|
+
parameter "NAME", "Grid name"
|
6
|
+
parameter "SUBNET", "Trusted subnet"
|
7
|
+
|
8
|
+
def execute
|
9
|
+
require_api_url
|
10
|
+
token = require_token
|
11
|
+
grid = client(token).get("grids/#{name}")
|
12
|
+
trusted_subnets = grid['trusted_subnets'] || []
|
13
|
+
unless trusted_subnets.delete(self.subnet)
|
14
|
+
abort("Grid does not have trusted subnet #{self.subnet}")
|
15
|
+
end
|
16
|
+
data = {trusted_subnets: trusted_subnets}
|
17
|
+
client(token).put("grids/#{name}", data)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Kontena::Cli::Grids
|
2
|
+
|
3
|
+
require_relative 'users/list_command'
|
4
|
+
require_relative 'users/add_command'
|
5
|
+
require_relative 'users/remove_command'
|
6
|
+
|
7
|
+
class UserCommand < Clamp::Command
|
8
|
+
subcommand ["list", "ls"], "List grid users", Users::ListCommand
|
9
|
+
subcommand "add", "Add user to grid", Users::AddCommand
|
10
|
+
subcommand ["remove", "rm"], "Remove user from grid", Users::RemoveCommand
|
11
|
+
end
|
12
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require_relative 'common'
|
1
|
+
require_relative '../common'
|
2
2
|
|
3
|
-
module Kontena::Cli::Grids
|
4
|
-
class
|
3
|
+
module Kontena::Cli::Grids::Users
|
4
|
+
class AddCommand < Clamp::Command
|
5
5
|
include Kontena::Cli::Common
|
6
6
|
include Kontena::Cli::GridOptions
|
7
|
-
include Common
|
7
|
+
include Kontena::Cli::Grids::Common
|
8
8
|
|
9
9
|
parameter "EMAIL", "Email address"
|
10
10
|
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require_relative 'common'
|
1
|
+
require_relative '../common'
|
2
2
|
|
3
|
-
module Kontena::Cli::Grids
|
4
|
-
class
|
3
|
+
module Kontena::Cli::Grids::Users
|
4
|
+
class ListCommand < Clamp::Command
|
5
5
|
include Kontena::Cli::Common
|
6
|
-
include Common
|
6
|
+
include Kontena::Cli::Grids::Common
|
7
7
|
|
8
8
|
def execute
|
9
9
|
require_api_url
|