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
@@ -1,6 +1,6 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'stack_data_set'
|
2
2
|
|
3
|
-
module Kontena::
|
3
|
+
module Kontena::Stacks
|
4
4
|
class ChangeResolver
|
5
5
|
|
6
6
|
attr_reader :old_data, :new_data
|
@@ -8,11 +8,11 @@ module Kontena::Cli::Stacks
|
|
8
8
|
# Creates a change analysis from two sets of stack data.
|
9
9
|
# The format is a flat hash of all related stacks.
|
10
10
|
#
|
11
|
-
# @param old_data [Hash]
|
12
|
-
# @param new_data [Hash]
|
11
|
+
# @param old_data [DataSet,Hash]
|
12
|
+
# @param new_data [DataSet,Hash]
|
13
13
|
def initialize(old_data, new_data)
|
14
|
-
@old_data = old_data
|
15
|
-
@new_data = new_data
|
14
|
+
@old_data = old_data.is_a?(StackDataSet) ? old_data : StackDataSet.new(old_data)
|
15
|
+
@new_data = new_data.is_a?(StackDataSet) ? new_data : StackDataSet.new(new_data)
|
16
16
|
analyze
|
17
17
|
end
|
18
18
|
|
@@ -56,41 +56,63 @@ module Kontena::Cli::Stacks
|
|
56
56
|
@remaining_stacks ||= added_stacks + upgraded_stacks
|
57
57
|
end
|
58
58
|
|
59
|
+
# @return [Boolean]
|
60
|
+
def safe?
|
61
|
+
removed_stacks.empty? && replaced_stacks.empty? && removed_services.empty?
|
62
|
+
end
|
63
|
+
|
59
64
|
def analyze
|
60
|
-
old_names = old_data.
|
61
|
-
new_names = new_data.
|
65
|
+
old_names = old_data.stack_names
|
66
|
+
new_names = new_data.stack_names
|
62
67
|
|
63
68
|
removed_stacks.concat(old_names - new_names)
|
64
69
|
added_stacks.concat(new_names - old_names)
|
65
|
-
|
70
|
+
(new_names & old_names).each do |candidate|
|
71
|
+
upgraded_stacks << candidate if stack_upgraded?(candidate)
|
72
|
+
end
|
66
73
|
|
67
74
|
removed_stacks.each do |removed_stack|
|
68
75
|
removed_services.concat(
|
69
|
-
old_data
|
76
|
+
old_data.stack(removed_stack).service_names.map { |name| "#{removed_stack}/#{name}"}
|
70
77
|
)
|
71
78
|
end
|
72
79
|
|
73
80
|
added_stacks.each do |added_stack|
|
74
81
|
added_services.concat(
|
75
|
-
new_data
|
82
|
+
new_data.stack(added_stack).service_names.map { |name| "#{added_stack}/#{name}"}
|
76
83
|
)
|
77
84
|
end
|
78
85
|
|
79
86
|
upgraded_stacks.each do |upgraded_stack|
|
80
|
-
old_stack = old_data
|
81
|
-
new_stack = new_data
|
87
|
+
old_stack = old_data.stack(upgraded_stack).stack_name
|
88
|
+
new_stack = new_data.stack(upgraded_stack).stack_name
|
82
89
|
|
83
90
|
unless old_stack == new_stack
|
84
91
|
replaced_stacks[upgraded_stack] = { from: old_stack, to: new_stack }
|
85
92
|
end
|
86
93
|
|
87
|
-
old_services = old_data
|
88
|
-
new_services = new_data
|
94
|
+
old_services = old_data.stack(upgraded_stack).service_names.map { |name| "#{upgraded_stack}/#{name}" }
|
95
|
+
new_services = new_data.stack(upgraded_stack).service_names.map { |name| "#{upgraded_stack}/#{name}" }
|
89
96
|
|
90
97
|
removed_services.concat(old_services - new_services)
|
91
98
|
added_services.concat(new_services - old_services)
|
92
99
|
upgraded_services.concat(new_services & old_services)
|
93
100
|
end
|
94
101
|
end
|
102
|
+
|
103
|
+
# Stack is upgraded if version, stack name, variables change or stack is root
|
104
|
+
#
|
105
|
+
# @param name [String]
|
106
|
+
# @return [Boolean]
|
107
|
+
def stack_upgraded?(name)
|
108
|
+
old_stack = old_data.stack(name)
|
109
|
+
new_stack = new_data.stack(name)
|
110
|
+
return true if new_stack.root?
|
111
|
+
return true if old_stack.version != new_stack.version
|
112
|
+
return true if old_stack.stack_name != new_stack.stack_name
|
113
|
+
return true if old_stack.variables != new_stack.variables
|
114
|
+
|
115
|
+
false
|
116
|
+
end
|
95
117
|
end
|
96
|
-
end
|
118
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Kontena::Stacks
|
2
|
+
class StackData
|
3
|
+
|
4
|
+
attr_reader :loader
|
5
|
+
|
6
|
+
# @param data [Hash]
|
7
|
+
# @param loader [StackFileLoader,NilClass]
|
8
|
+
def initialize(data, loader = nil)
|
9
|
+
@data = data
|
10
|
+
@loader = loader
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [String]
|
14
|
+
def name
|
15
|
+
@data['name']
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [String]
|
19
|
+
def stack_name
|
20
|
+
@data['stack']
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [String]
|
24
|
+
def version
|
25
|
+
@data['version']
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [Boolean]
|
29
|
+
def root?
|
30
|
+
parent.nil?
|
31
|
+
end
|
32
|
+
|
33
|
+
# @return [String]
|
34
|
+
def parent
|
35
|
+
@data.dig('parent', 'name')
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [Hash]
|
39
|
+
def variables
|
40
|
+
@data['variables']
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [Array<Hash>]
|
44
|
+
def services
|
45
|
+
@data['services']
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [Array<String>]
|
49
|
+
def service_names
|
50
|
+
@data['services'].map { |s| s['name']}
|
51
|
+
end
|
52
|
+
|
53
|
+
# @return [Hash]
|
54
|
+
def data
|
55
|
+
@data.dup
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative 'stack_data'
|
2
|
+
|
3
|
+
module Kontena::Stacks
|
4
|
+
class StackDataSet
|
5
|
+
|
6
|
+
# @param data [Hash]
|
7
|
+
def initialize(data)
|
8
|
+
@data = data
|
9
|
+
end
|
10
|
+
|
11
|
+
# @param name [String]
|
12
|
+
# @return [StackData,NilClass]
|
13
|
+
def stack(name)
|
14
|
+
data = @data[name]
|
15
|
+
StackData.new(data[:stack_data], data[:loader]) if data
|
16
|
+
end
|
17
|
+
|
18
|
+
alias_method :[], :stack
|
19
|
+
|
20
|
+
# @return [Array<StackData>]
|
21
|
+
def stacks
|
22
|
+
stack_names.map do |name|
|
23
|
+
stack(name)
|
24
|
+
end.compact
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Array<String>]
|
28
|
+
def stack_names
|
29
|
+
@data.keys
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [Integer]
|
33
|
+
def size
|
34
|
+
@data.size
|
35
|
+
end
|
36
|
+
|
37
|
+
# @param name [String]
|
38
|
+
# @return [StackData,NilClass]
|
39
|
+
def delete(name)
|
40
|
+
data = @data.delete(name)
|
41
|
+
StackData.new(data[:stack_data], data[:loader]) if data
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [Array<StackData>]
|
45
|
+
def remove_dependencies
|
46
|
+
stacks.map do |stack|
|
47
|
+
delete(stack.name) unless stack.root?
|
48
|
+
end.compact
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/kontena_cli.rb
CHANGED
data/omnibus/Gemfile.lock
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
GIT
|
2
2
|
remote: git://github.com/opscode/omnibus-software.git
|
3
|
-
revision:
|
3
|
+
revision: 4ef2d1a5b9162f4f5f52617d2a0122796b4f3c43
|
4
4
|
specs:
|
5
5
|
omnibus-software (4.0.0)
|
6
6
|
chef-sugar (>= 3.4.0)
|
@@ -9,22 +9,27 @@ GIT
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
+
addressable (2.5.2)
|
13
|
+
public_suffix (>= 2.0.2, < 4.0)
|
12
14
|
awesome_print (1.8.0)
|
13
|
-
aws-sdk (2.10.
|
14
|
-
aws-sdk-resources (= 2.10.
|
15
|
-
aws-sdk-core (2.10.
|
15
|
+
aws-sdk (2.10.130)
|
16
|
+
aws-sdk-resources (= 2.10.130)
|
17
|
+
aws-sdk-core (2.10.130)
|
16
18
|
aws-sigv4 (~> 1.0)
|
17
19
|
jmespath (~> 1.0)
|
18
|
-
aws-sdk-resources (2.10.
|
19
|
-
aws-sdk-core (= 2.10.
|
20
|
-
aws-sigv4 (1.0.
|
21
|
-
chef-config (
|
20
|
+
aws-sdk-resources (2.10.130)
|
21
|
+
aws-sdk-core (= 2.10.130)
|
22
|
+
aws-sigv4 (1.0.2)
|
23
|
+
chef-config (13.7.16)
|
24
|
+
addressable
|
22
25
|
fuzzyurl
|
23
26
|
mixlib-config (~> 2.0)
|
24
27
|
mixlib-shellout (~> 2.0)
|
25
|
-
|
28
|
+
tomlrb (~> 1.2)
|
29
|
+
chef-sugar (3.6.0)
|
30
|
+
citrus (3.0.2)
|
26
31
|
cleanroom (1.0.0)
|
27
|
-
ffi (1.9.
|
32
|
+
ffi (1.9.21)
|
28
33
|
ffi-yajl (2.3.1)
|
29
34
|
libyajl2 (~> 1.2)
|
30
35
|
fuzzyurl (0.9.0)
|
@@ -32,16 +37,17 @@ GEM
|
|
32
37
|
ipaddress (0.8.3)
|
33
38
|
jmespath (1.3.1)
|
34
39
|
libyajl2 (1.2.0)
|
35
|
-
license_scout (0.
|
40
|
+
license_scout (1.0.0)
|
36
41
|
ffi-yajl (~> 2.2)
|
37
42
|
mixlib-shellout (~> 2.2)
|
43
|
+
toml-rb (~> 1.0)
|
38
44
|
mixlib-cli (1.7.0)
|
39
|
-
mixlib-config (2.2.
|
45
|
+
mixlib-config (2.2.5)
|
40
46
|
mixlib-log (1.7.1)
|
41
|
-
mixlib-shellout (2.2
|
42
|
-
mixlib-versioning (1.
|
47
|
+
mixlib-shellout (2.3.2)
|
48
|
+
mixlib-versioning (1.2.2)
|
43
49
|
multipart-post (2.0.0)
|
44
|
-
ohai (8.
|
50
|
+
ohai (8.26.1)
|
45
51
|
chef-config (>= 12.5.0.alpha.1, < 14)
|
46
52
|
ffi (~> 1.9)
|
47
53
|
ffi-yajl (~> 2.2)
|
@@ -53,12 +59,12 @@ GEM
|
|
53
59
|
plist (~> 3.1)
|
54
60
|
systemu (~> 2.6.4)
|
55
61
|
wmi-lite (~> 1.0)
|
56
|
-
omnibus (5.6.
|
62
|
+
omnibus (5.6.8)
|
57
63
|
aws-sdk (~> 2)
|
58
64
|
chef-sugar (~> 3.3)
|
59
65
|
cleanroom (~> 1.0)
|
60
66
|
ffi-yajl (~> 2.2)
|
61
|
-
license_scout
|
67
|
+
license_scout (~> 1.0)
|
62
68
|
mixlib-shellout (~> 2.0)
|
63
69
|
mixlib-versioning
|
64
70
|
ohai (~> 8.0)
|
@@ -71,11 +77,15 @@ GEM
|
|
71
77
|
multipart-post (~> 2.0.0)
|
72
78
|
progressbar
|
73
79
|
zhexdump (>= 0.0.2)
|
74
|
-
plist (3.
|
75
|
-
progressbar (1.
|
76
|
-
|
80
|
+
plist (3.4.0)
|
81
|
+
progressbar (1.9.0)
|
82
|
+
public_suffix (3.0.2)
|
83
|
+
ruby-progressbar (1.9.0)
|
77
84
|
systemu (2.6.5)
|
78
|
-
thor (0.
|
85
|
+
thor (0.20.0)
|
86
|
+
toml-rb (1.1.1)
|
87
|
+
citrus (~> 3.0, > 3.0)
|
88
|
+
tomlrb (1.2.6)
|
79
89
|
wmi-lite (1.0.0)
|
80
90
|
zhexdump (0.0.2)
|
81
91
|
|
@@ -87,4 +97,4 @@ DEPENDENCIES
|
|
87
97
|
omnibus-software!
|
88
98
|
|
89
99
|
BUNDLED WITH
|
90
|
-
1.
|
100
|
+
1.16.0
|
@@ -11,6 +11,8 @@ description "Command-line tool for the Kontena Platform"
|
|
11
11
|
maintainer "Kontena, Inc."
|
12
12
|
homepage "https://kontena.io"
|
13
13
|
|
14
|
+
override :ruby, version: "2.5.0"
|
15
|
+
|
14
16
|
# Defaults to C:/kontena on Windows
|
15
17
|
# and /opt/kontena on all other platforms
|
16
18
|
install_dir "#{default_root}/#{name}"
|
@@ -9,9 +9,11 @@ dependency "libxml2"
|
|
9
9
|
dependency "libxslt"
|
10
10
|
whitelist_file "./wrappers/sh/kontena"
|
11
11
|
build do
|
12
|
-
|
13
|
-
gem "install
|
14
|
-
gem "install
|
15
|
-
gem "
|
12
|
+
env = with_standard_compiler_flags(with_embedded_path)
|
13
|
+
gem "install rb-readline -v 0.5.4 -N", env: env
|
14
|
+
gem "install nokogiri -v 1.8.2 -N", env: env
|
15
|
+
gem "build kontena-cli.gemspec", env: env, cwd: File.expand_path('..', Omnibus::Config.project_root)
|
16
|
+
gem "install -N #{Dir[File.expand_path('../kontena-cli-%s.gem' % default_version, Omnibus::Config.project_root)].first}", env: env
|
17
|
+
gem "install kontena-plugin-cloud -N", env: env
|
16
18
|
copy "sh/kontena", "#{install_dir}/bin/kontena"
|
17
19
|
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# after package is installed.
|
5
5
|
#
|
6
6
|
chown $USER /opt/kontena/embedded/bin
|
7
|
-
chown $USER -R /opt/kontena/embedded/lib/ruby/gems/2.
|
7
|
+
chown $USER -R /opt/kontena/embedded/lib/ruby/gems/2.5.0
|
8
8
|
|
9
9
|
mkdir -p /usr/local/bin
|
10
10
|
ln -s /opt/kontena/bin/kontena /usr/local/bin/kontena
|
data/omnibus/wrappers/sh/kontena
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
stack: user/stackname
|
2
|
+
version: 0.1.1
|
3
|
+
services:
|
4
|
+
wordpress:
|
5
|
+
extends:
|
6
|
+
stack: registrystack/compose:1.0.0
|
7
|
+
service: wordpress
|
8
|
+
stateful: true
|
9
|
+
environment:
|
10
|
+
WORDPRESS_DB_PASSWORD: ${STACK}_secret
|
11
|
+
instances: 2
|
12
|
+
deploy:
|
13
|
+
strategy: ha
|
14
|
+
mysql:
|
15
|
+
extends:
|
16
|
+
stack: registrystack/compose:1.0.0
|
17
|
+
service: mysql
|
18
|
+
stateful: true
|
19
|
+
environment:
|
20
|
+
- MYSQL_ROOT_PASSWORD=${STACK}_secret
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'kontena/cli/certificate/authorize_command'
|
2
|
+
|
3
|
+
describe Kontena::Cli::Certificate::AuthorizeCommand do
|
4
|
+
include ClientHelpers
|
5
|
+
include OutputHelpers
|
6
|
+
|
7
|
+
let(:subject) { described_class.new("kontena") }
|
8
|
+
|
9
|
+
let(:challenge_opts) { {} }
|
10
|
+
let(:linked_service) { {} }
|
11
|
+
let(:domain_authorization) {
|
12
|
+
{
|
13
|
+
'id' => 'test/example.com',
|
14
|
+
'domain' => 'example.com',
|
15
|
+
'challenge_opts' => challenge_opts,
|
16
|
+
'linked_service' => linked_service,
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
describe '--type=dns-01' do
|
21
|
+
let(:challenge_opts) {
|
22
|
+
{
|
23
|
+
'record_name' => '_acme-challenge',
|
24
|
+
'record_type' => 'TXT',
|
25
|
+
'record_content' => 'qyANS...sqXm4',
|
26
|
+
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
it "requests domain authorization and shows the record contents" do
|
31
|
+
allow(client).to receive(:post).with('grids/test-grid/domain_authorizations', {domain: 'example.com', authorization_type: 'dns-01'}).and_return(domain_authorization)
|
32
|
+
|
33
|
+
expect{subject.run(['--type=dns-01', 'example.com'])}.to output(<<-EOM
|
34
|
+
Authorization successfully created. Use the following details to create necessary validations:
|
35
|
+
Record name: _acme-challenge.example.com
|
36
|
+
Record type: TXT
|
37
|
+
Record content: qyANS...sqXm4
|
38
|
+
EOM
|
39
|
+
).to_stdout
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '--type=http-01' do
|
44
|
+
let(:challenge_opts) {
|
45
|
+
{
|
46
|
+
'token' => 'LoqXcYV8q5ONbJQxbmR7SCTNo3tiAXDfowyjxAjEuX0',
|
47
|
+
'content' => 'LoqXcYV8q5ONbJQxbmR7SCTNo3tiAXDfowyjxAjEuX0.9jg46WB3rR_AHD-EBXdN7cBkH1WOu0tA3M9fm21mqTI',
|
48
|
+
}
|
49
|
+
}
|
50
|
+
let(:linked_service) { { 'id' => 'test-grid/test/lb' } }
|
51
|
+
|
52
|
+
it "fails without --linked-service" do
|
53
|
+
expect{subject.run(["--type=http-01", 'example.com'])}.to exit_with_error.and output(/--linked-service is required with --type=http-01/).to_stderr
|
54
|
+
end
|
55
|
+
|
56
|
+
it "requests domain authorization" do
|
57
|
+
allow(client).to receive(:post).with('grids/test-grid/domain_authorizations', {domain: 'example.com', authorization_type: 'http-01', linked_service: 'test/lb'}).and_return(domain_authorization)
|
58
|
+
allow(subject).to receive(:wait_for_domain_auth_deployed).with(domain_authorization).and_return(domain_authorization)
|
59
|
+
|
60
|
+
expect{subject.run(['--type=http-01', '--linked-service=test/lb', 'example.com'])}.to output(/Waiting for http-01 challenge to be deployed into .*\nHTTP challenge is deployed, you can now request the actual certificate/m).to_stdout
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '--type=tls-sni-01' do
|
65
|
+
let(:challenge_opts) {
|
66
|
+
{ }
|
67
|
+
}
|
68
|
+
let(:linked_service) { { 'id' => 'test-grid/test/lb' } }
|
69
|
+
|
70
|
+
it "fails without --linked-service" do
|
71
|
+
expect{subject.run(["--type=tls-sni-01", 'example.com'])}.to exit_with_error.and output(/--linked-service is required with --type=tls-sni-01/).to_stderr
|
72
|
+
end
|
73
|
+
|
74
|
+
it "requests domain authorization and waits for deploy" do
|
75
|
+
allow(client).to receive(:post).with('grids/test-grid/domain_authorizations', {domain: 'example.com', authorization_type: 'tls-sni-01', linked_service: 'test/lb'}).and_return(domain_authorization)
|
76
|
+
allow(subject).to receive(:wait_for_domain_auth_deployed).with(domain_authorization).and_return(domain_authorization)
|
77
|
+
|
78
|
+
expect{subject.run(['--type=tls-sni-01', '--linked-service=test/lb', 'example.com'])}.to output(/Waiting for tls-sni-01 challenge to be deployed into .*\nTLS-SNI challenge certificate is deployed, you can now request the actual certificate/m).to_stdout
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|