kontena-cli 1.1.0.rc1 → 1.1.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/kontena/cli/apps/deploy_command.rb +1 -5
- data/lib/kontena/cli/cloud/login_command.rb +9 -1
- data/lib/kontena/cli/common.rb +2 -2
- data/lib/kontena/cli/etcd/health_command.rb +58 -0
- data/lib/kontena/cli/etcd_command.rb +2 -0
- data/lib/kontena/cli/external_registry_command.rb +0 -2
- data/lib/kontena/cli/master/login_command.rb +5 -7
- data/lib/kontena/cli/service_command.rb +2 -2
- data/lib/kontena/cli/services/deploy_command.rb +1 -5
- data/lib/kontena/cli/services/exec_command.rb +84 -0
- data/lib/kontena/cli/services/services_helper.rb +4 -1
- data/lib/kontena/cli/stacks/common.rb +6 -17
- data/lib/kontena/cli/stacks/install_command.rb +2 -10
- data/lib/kontena/cli/stacks/show_command.rb +30 -4
- data/lib/kontena/cli/stacks/upgrade_command.rb +20 -7
- data/lib/kontena/cli/stacks/validate_command.rb +1 -9
- data/lib/kontena/cli/stacks/yaml/opto/service_link_resolver.rb +45 -0
- data/lib/kontena/cli/stacks/yaml/opto/vault_cert_prompt_resolver.rb +15 -0
- data/lib/kontena/cli/stacks/yaml/opto/vault_resolver.rb +1 -0
- data/lib/kontena/cli/stacks/yaml/reader.rb +36 -26
- data/lib/kontena/command.rb +5 -0
- data/lib/kontena/main_command.rb +5 -4
- data/lib/kontena_cli.rb +4 -0
- data/spec/fixtures/stack-with-prompted-variables.yml +5 -1
- data/spec/fixtures/stack-with-variables.yml +5 -1
- data/spec/kontena/cli/cloud/login_command_spec.rb +1 -0
- data/spec/kontena/cli/etcd/health_command_spec.rb +87 -0
- data/spec/kontena/cli/master/login_command_spec.rb +8 -17
- data/spec/kontena/cli/services/exec_command_spec.rb +137 -0
- data/spec/kontena/cli/stacks/install_command_spec.rb +5 -5
- data/spec/kontena/cli/stacks/upgrade_command_spec.rb +39 -32
- data/spec/kontena/cli/stacks/yaml/reader_spec.rb +22 -0
- data/spec/support/client_helpers.rb +6 -2
- data/spec/support/output_helpers.rb +23 -0
- metadata +11 -7
- data/lib/kontena/cli/external_registries/delete_command.rb +0 -15
- data/lib/kontena/cli/login_command.rb +0 -12
- data/lib/kontena/cli/register_command.rb +0 -9
- data/lib/kontena/cli/services/delete_command.rb +0 -19
|
@@ -232,7 +232,7 @@ describe Kontena::Cli::Master::LoginCommand do
|
|
|
232
232
|
it 'goes to web flow when the existing token does not work' do
|
|
233
233
|
expect(client).to receive(:authentication_ok?).and_return(false)
|
|
234
234
|
expect(subject).to receive(:web_flow).and_return(true)
|
|
235
|
-
subject.run(%w(fooserver))
|
|
235
|
+
subject.run(%w(--no-remote fooserver))
|
|
236
236
|
end
|
|
237
237
|
end
|
|
238
238
|
|
|
@@ -265,7 +265,7 @@ describe Kontena::Cli::Master::LoginCommand do
|
|
|
265
265
|
end.and_return({})
|
|
266
266
|
expect(Launchy).to receive(:open).with('http://authprovider.example.com/authplz').and_return(true)
|
|
267
267
|
expect(client).to receive(:exchange_code).with('abcd1234').and_return('access_token' => 'defg456', 'server' => { 'name' => 'foobar' }, 'user' => { 'name' => 'testuser' })
|
|
268
|
-
subject.run(%w(--skip-grid-auto-select http://foobar.example.com))
|
|
268
|
+
subject.run(%w(--no-remote --skip-grid-auto-select http://foobar.example.com))
|
|
269
269
|
expect(subject.config.servers.size).to eq 1
|
|
270
270
|
server = subject.config.servers.first
|
|
271
271
|
expect(server.url).to eq 'http://foobar.example.com'
|
|
@@ -289,25 +289,15 @@ describe Kontena::Cli::Master::LoginCommand do
|
|
|
289
289
|
expect(server.token.expires_at).to be_nil
|
|
290
290
|
end
|
|
291
291
|
|
|
292
|
-
it '
|
|
292
|
+
it 'asks for code when using --remote' do
|
|
293
293
|
expect(client).to receive(:last_response).at_least(:once).and_return(OpenStruct.new(status: 302, headers: { 'Location' => 'http//authprovider.example.com/authplz' }))
|
|
294
294
|
expect(client).to receive(:request) do |opts|
|
|
295
295
|
expect(opts[:path]).to eq "/authenticate?redirect_uri=%2Fcode&expires_in=7200"
|
|
296
296
|
expect(opts[:http_method]).to eq :get
|
|
297
297
|
end.and_return({})
|
|
298
|
-
expect(
|
|
299
|
-
expect(subject
|
|
300
|
-
|
|
301
|
-
expect(ex.status).to eq 1
|
|
302
|
-
end
|
|
303
|
-
expect(subject.config.servers.size).to eq 1
|
|
304
|
-
server = subject.config.servers.first
|
|
305
|
-
expect(server.url).to eq 'http://foobar.example.com'
|
|
306
|
-
expect(server.name).to eq 'kontena-master-2'
|
|
307
|
-
expect(server.username).to be_nil
|
|
308
|
-
expect(server.token.access_token).to be_nil
|
|
309
|
-
expect(server.token.refresh_token).to be_nil
|
|
310
|
-
expect(server.token.expires_at).to be_nil
|
|
298
|
+
expect(Kontena.prompt).to receive(:ask).and_return("abcd")
|
|
299
|
+
expect(subject).to receive(:use_authorization_code).and_return('true')
|
|
300
|
+
subject.run(%w(--remote http://foobar.example.com))
|
|
311
301
|
end
|
|
312
302
|
end
|
|
313
303
|
|
|
@@ -337,6 +327,7 @@ describe Kontena::Cli::Master::LoginCommand do
|
|
|
337
327
|
allow(File).to receive(:readable?).and_return(true)
|
|
338
328
|
allow(Kontena::Client).to receive(:new).and_return(client)
|
|
339
329
|
allow(Kontena::LocalhostWebServer).to receive(:new).and_return(webserver)
|
|
330
|
+
allow(Kontena).to receive(:browserless?).and_return(false)
|
|
340
331
|
allow(webserver).to receive(:port).and_return(12345)
|
|
341
332
|
allow(webserver).to receive(:serve_one).and_return(
|
|
342
333
|
{ 'code' => 'abcd1234' }
|
|
@@ -350,7 +341,7 @@ describe Kontena::Cli::Master::LoginCommand do
|
|
|
350
341
|
allow(client).to receive(:exchange_code).with('abcd1234').and_return('access_token' => 'defg456', 'server' => { 'name' => 'foobar' }, 'user' => { 'name' => 'testuser' })
|
|
351
342
|
subject.config.current_master = 'fooserver'
|
|
352
343
|
subject.config.current_master
|
|
353
|
-
subject.run(%w(--skip-grid-auto-select http://foobar.example.com))
|
|
344
|
+
subject.run(%w(--no-remote --skip-grid-auto-select http://foobar.example.com))
|
|
354
345
|
expect(subject.config.current_master.name).to eq 'foobar'
|
|
355
346
|
end
|
|
356
347
|
end
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
describe Kontena::Cli::Services::ExecCommand do
|
|
2
|
+
include ClientHelpers
|
|
3
|
+
include OutputHelpers
|
|
4
|
+
|
|
5
|
+
let :exec_ok do
|
|
6
|
+
[
|
|
7
|
+
["ok\n"],
|
|
8
|
+
[],
|
|
9
|
+
0, # exit
|
|
10
|
+
]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
let :exec_fail do
|
|
14
|
+
[
|
|
15
|
+
[],
|
|
16
|
+
["error\n"],
|
|
17
|
+
1, # exit
|
|
18
|
+
]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context "For a service with one running instance" do
|
|
22
|
+
let :service_containers do
|
|
23
|
+
{ 'containers' => [
|
|
24
|
+
{
|
|
25
|
+
'id' => 'test-grid/host/test-service.container-1',
|
|
26
|
+
'name' => 'test-service.container-1',
|
|
27
|
+
'instance_number' => 1,
|
|
28
|
+
'status' => 'running',
|
|
29
|
+
},
|
|
30
|
+
] }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
before do
|
|
34
|
+
expect(client).to receive(:get).with('services/test-grid/null/test-service/containers').and_return(service_containers)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "Executes on the running container by default" do
|
|
38
|
+
expect(client).to receive(:post).with('containers/test-grid/host/test-service.container-1/exec', { cmd: ['test'] }).and_return(exec_ok)
|
|
39
|
+
|
|
40
|
+
expect{subject.run(['test-service', 'test'])}.to return_and_output true, [
|
|
41
|
+
'ok',
|
|
42
|
+
]
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context "For a service with multiple running instances" do
|
|
47
|
+
let :service_containers do
|
|
48
|
+
{ 'containers' => [
|
|
49
|
+
{
|
|
50
|
+
'id' => 'test-grid/host/test-service.container-1',
|
|
51
|
+
'name' => 'test-service.container-1',
|
|
52
|
+
'instance_number' => 1,
|
|
53
|
+
'status' => 'running',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
'id' => 'test-grid/host/test-service.container-2',
|
|
57
|
+
'name' => 'test-service.container-2',
|
|
58
|
+
'instance_number' => 2,
|
|
59
|
+
'status' => 'running',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
'id' => 'test-grid/host/test-service.container-3',
|
|
63
|
+
'name' => 'test-service.container-3',
|
|
64
|
+
'instance_number' => 3,
|
|
65
|
+
'status' => 'running',
|
|
66
|
+
},
|
|
67
|
+
] }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "Executes on the first running container by default" do
|
|
71
|
+
expect(client).to receive(:get).with('services/test-grid/null/test-service/containers').and_return(service_containers)
|
|
72
|
+
expect(client).to receive(:post).with('containers/test-grid/host/test-service.container-1/exec', { cmd: ['test'] }).and_return(exec_ok)
|
|
73
|
+
|
|
74
|
+
expect{subject.run(['test-service', 'test'])}.to output_lines ["ok"]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "Executes on the first running container, even if they are ordered differently" do
|
|
78
|
+
expect(client).to receive(:get).with('services/test-grid/null/test-service/containers').and_return({'containers' => service_containers['containers'].reverse })
|
|
79
|
+
expect(client).to receive(:post).with('containers/test-grid/host/test-service.container-1/exec', { cmd: ['test'] }).and_return(exec_ok)
|
|
80
|
+
|
|
81
|
+
expect{subject.run(['test-service', 'test'])}.to output_lines ["ok"]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "Executes on the first running container if given" do
|
|
85
|
+
expect(client).to receive(:get).with('services/test-grid/null/test-service/containers').and_return(service_containers)
|
|
86
|
+
expect(client).to receive(:post).with('containers/test-grid/host/test-service.container-1/exec', { cmd: ['test'] }).and_return(exec_ok)
|
|
87
|
+
|
|
88
|
+
expect{subject.run(['--instance=1', 'test-service', 'test'])}.to output_lines ["ok"]
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "Executes on the second running container if given" do
|
|
92
|
+
expect(client).to receive(:get).with('services/test-grid/null/test-service/containers').and_return(service_containers)
|
|
93
|
+
expect(client).to receive(:post).with('containers/test-grid/host/test-service.container-2/exec', { cmd: ['test'] }).and_return(exec_ok)
|
|
94
|
+
|
|
95
|
+
expect{subject.run(['--instance=2', 'test-service', 'test'])}.to output_lines ["ok"]
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "Errors on a nonexistant container if given" do
|
|
99
|
+
expect(client).to receive(:get).with('services/test-grid/null/test-service/containers').and_return(service_containers)
|
|
100
|
+
|
|
101
|
+
expect{subject.run(['--instance=4', 'test-service', 'test'])}.to output(/Service test-service does not have container instance 4/).to_stderr.and raise_error(SystemExit)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it "Executes on each running container" do
|
|
105
|
+
expect(client).to receive(:get).with('services/test-grid/null/test-service/containers').and_return(service_containers)
|
|
106
|
+
expect(client).to receive(:post).with('containers/test-grid/host/test-service.container-1/exec', { cmd: ['test'] }).and_return(exec_ok)
|
|
107
|
+
expect(client).to receive(:post).with('containers/test-grid/host/test-service.container-2/exec', { cmd: ['test'] }).and_return(exec_ok)
|
|
108
|
+
expect(client).to receive(:post).with('containers/test-grid/host/test-service.container-3/exec', { cmd: ['test'] }).and_return(exec_ok)
|
|
109
|
+
|
|
110
|
+
expect{subject.run(['--silent', '--all', 'test-service', 'test'])}.to output_lines ["ok", "ok", "ok"]
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "Stops if the first container fails" do
|
|
114
|
+
expect(client).to receive(:get).with('services/test-grid/null/test-service/containers').and_return(service_containers)
|
|
115
|
+
expect(client).to receive(:post).with('containers/test-grid/host/test-service.container-1/exec', { cmd: ['test'] }).and_return(exec_fail)
|
|
116
|
+
|
|
117
|
+
expect{subject.run(['--silent', '--all', 'test-service', 'test'])}.to output("error\n").to_stderr.and raise_error(SystemExit)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it "Stops if the second container fails" do
|
|
121
|
+
expect(client).to receive(:get).with('services/test-grid/null/test-service/containers').and_return(service_containers)
|
|
122
|
+
expect(client).to receive(:post).with('containers/test-grid/host/test-service.container-1/exec', { cmd: ['test'] }).and_return(exec_ok)
|
|
123
|
+
expect(client).to receive(:post).with('containers/test-grid/host/test-service.container-2/exec', { cmd: ['test'] }).and_return(exec_fail)
|
|
124
|
+
|
|
125
|
+
expect{subject.run(['--silent', '--all', 'test-service', 'test'])}.to output("ok\n").to_stdout.and output("error\n").to_stderr.and raise_error(SystemExit)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it "Keeps going if the second container fails when using --skip" do
|
|
129
|
+
expect(client).to receive(:get).with('services/test-grid/null/test-service/containers').and_return(service_containers)
|
|
130
|
+
expect(client).to receive(:post).with('containers/test-grid/host/test-service.container-1/exec', { cmd: ['test'] }).and_return(exec_ok)
|
|
131
|
+
expect(client).to receive(:post).with('containers/test-grid/host/test-service.container-2/exec', { cmd: ['test'] }).and_return(exec_fail)
|
|
132
|
+
expect(client).to receive(:post).with('containers/test-grid/host/test-service.container-3/exec', { cmd: ['test'] }).and_return(exec_ok)
|
|
133
|
+
|
|
134
|
+
expect{subject.run(['--silent', '--all', '--skip', 'test-service', 'test'])}.to output("ok\nok\n").to_stdout.and output("error\n").to_stderr.and raise_error(SystemExit)
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
@@ -28,14 +28,14 @@ describe Kontena::Cli::Stacks::InstallCommand do
|
|
|
28
28
|
|
|
29
29
|
it 'requires api url' do
|
|
30
30
|
allow(File).to receive(:exist?).with('kontena.yml').and_return(true)
|
|
31
|
-
allow(subject).to receive(:stack_from_yaml).with('kontena.yml', hash_including(
|
|
31
|
+
allow(subject).to receive(:stack_from_yaml).with('kontena.yml', hash_including(name: nil, values: nil)).and_return(stack)
|
|
32
32
|
expect(described_class.requires_current_master?).to be_truthy
|
|
33
33
|
subject.run([])
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
it 'requires token' do
|
|
37
37
|
allow(File).to receive(:exist?).with('kontena.yml').and_return(true)
|
|
38
|
-
allow(subject).to receive(:stack_from_yaml).with('kontena.yml', hash_including(
|
|
38
|
+
allow(subject).to receive(:stack_from_yaml).with('kontena.yml', hash_including(name: nil, values: nil)).and_return(stack)
|
|
39
39
|
expect(described_class.requires_current_master_token?).to be_truthy
|
|
40
40
|
subject.run([])
|
|
41
41
|
end
|
|
@@ -43,7 +43,7 @@ describe Kontena::Cli::Stacks::InstallCommand do
|
|
|
43
43
|
it 'sends stack to master' do
|
|
44
44
|
allow(File).to receive(:exist?).with('kontena.yml').and_return(true)
|
|
45
45
|
allow(subject).to receive(:require_config_file).with('kontena.yml').and_return(true)
|
|
46
|
-
allow(subject).to receive(:stack_from_yaml).with('kontena.yml', hash_including(
|
|
46
|
+
allow(subject).to receive(:stack_from_yaml).with('kontena.yml', hash_including(name: nil, values: nil)).and_return(stack)
|
|
47
47
|
expect(client).to receive(:post).with(
|
|
48
48
|
'grids/test-grid/stacks', stack
|
|
49
49
|
)
|
|
@@ -53,7 +53,7 @@ describe Kontena::Cli::Stacks::InstallCommand do
|
|
|
53
53
|
it 'allows to override stack name' do
|
|
54
54
|
allow(File).to receive(:exist?).with('kontena.yml').and_return(true)
|
|
55
55
|
allow(subject).to receive(:require_config_file).with('kontena.yml').and_return(true)
|
|
56
|
-
allow(subject).to receive(:stack_from_yaml).with('kontena.yml', hash_including(
|
|
56
|
+
allow(subject).to receive(:stack_from_yaml).with('kontena.yml', hash_including(name: 'stack-b', values: nil)).and_return(stack)
|
|
57
57
|
stack_b = stack
|
|
58
58
|
stack_b[:name] = 'stack-b'
|
|
59
59
|
expect(client).to receive(:post).with(
|
|
@@ -64,7 +64,7 @@ describe Kontena::Cli::Stacks::InstallCommand do
|
|
|
64
64
|
|
|
65
65
|
it 'accepts a stack name as filename' do
|
|
66
66
|
expect(File).to receive(:exist?).with('user/stack:1.0.0').and_return(false)
|
|
67
|
-
expect(subject).to receive(:stack_from_yaml).with('user/stack:1.0.0',
|
|
67
|
+
expect(subject).to receive(:stack_from_yaml).with('user/stack:1.0.0', name: nil, values: nil).and_return(stack)
|
|
68
68
|
expect(client).to receive(:post).with(
|
|
69
69
|
'grids/test-grid/stacks', stack
|
|
70
70
|
)
|
|
@@ -17,6 +17,18 @@ describe Kontena::Cli::Stacks::UpgradeCommand do
|
|
|
17
17
|
}
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
let(:defaults) do
|
|
21
|
+
{ 'foo' => 'bar' }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
let(:stack_response) do
|
|
25
|
+
{
|
|
26
|
+
'name' => 'stack-a',
|
|
27
|
+
'services' => [],
|
|
28
|
+
'variables' => defaults
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
|
|
20
32
|
before(:each) do
|
|
21
33
|
allow(File).to receive(:exist?).with('./path/to/kontena.yml').and_return(true)
|
|
22
34
|
end
|
|
@@ -24,21 +36,16 @@ describe Kontena::Cli::Stacks::UpgradeCommand do
|
|
|
24
36
|
expect_to_require_current_master
|
|
25
37
|
expect_to_require_current_master_token
|
|
26
38
|
|
|
27
|
-
it 'requires stack file' do
|
|
28
|
-
allow(subject).to receive(:stack_from_yaml).with('./path/to/kontena.yml', name: 'stack-name', values: nil, from_registry: false).and_return(stack)
|
|
29
|
-
expect(subject).to receive(:require_config_file).with('./path/to/kontena.yml').at_least(:once).and_return(true)
|
|
30
|
-
subject.run(['stack-name', './path/to/kontena.yml'])
|
|
31
|
-
end
|
|
32
|
-
|
|
33
39
|
it 'uses kontena.yml as default stack file' do
|
|
34
|
-
expect(
|
|
35
|
-
expect(subject).to receive(:stack_from_yaml).with('kontena.yml', name: 'stack-name', values: nil,
|
|
40
|
+
expect(client).to receive(:get).with('stacks/test-grid/stack-name').and_return(stack_response)
|
|
41
|
+
expect(subject).to receive(:stack_from_yaml).with('kontena.yml', name: 'stack-name', values: nil, defaults: defaults).and_return(stack)
|
|
36
42
|
subject.run(['stack-name'])
|
|
37
43
|
end
|
|
38
44
|
|
|
39
45
|
it 'sends stack to master' do
|
|
46
|
+
expect(client).to receive(:get).with('stacks/test-grid/stack-a').and_return(stack_response)
|
|
40
47
|
allow(subject).to receive(:require_config_file).with('./path/to/kontena.yml').and_return(true)
|
|
41
|
-
allow(subject).to receive(:stack_from_yaml).with('./path/to/kontena.yml', name: 'stack-a', values: nil,
|
|
48
|
+
allow(subject).to receive(:stack_from_yaml).with('./path/to/kontena.yml', name: 'stack-a', values: nil, defaults: defaults).and_return(stack)
|
|
42
49
|
expect(client).to receive(:put).with(
|
|
43
50
|
'stacks/test-grid/stack-a', anything
|
|
44
51
|
)
|
|
@@ -46,8 +53,9 @@ describe Kontena::Cli::Stacks::UpgradeCommand do
|
|
|
46
53
|
end
|
|
47
54
|
|
|
48
55
|
it 'allows to override stack name' do
|
|
56
|
+
expect(client).to receive(:get).with('stacks/test-grid/stack-b').and_return(stack_response)
|
|
49
57
|
allow(subject).to receive(:require_config_file).with('./path/to/kontena.yml').and_return(true)
|
|
50
|
-
allow(subject).to receive(:stack_from_yaml).with('./path/to/kontena.yml', name: 'stack-b', values: nil,
|
|
58
|
+
allow(subject).to receive(:stack_from_yaml).with('./path/to/kontena.yml', name: 'stack-b', values: nil, defaults: defaults).and_return(stack)
|
|
51
59
|
stack_b = stack
|
|
52
60
|
stack_b[:name] = 'stack-b'
|
|
53
61
|
expect(client).to receive(:put).with(
|
|
@@ -56,28 +64,27 @@ describe Kontena::Cli::Stacks::UpgradeCommand do
|
|
|
56
64
|
subject.run(['stack-b', './path/to/kontena.yml'])
|
|
57
65
|
end
|
|
58
66
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
end
|
|
67
|
+
it 'triggers deploy by default' do
|
|
68
|
+
expect(client).to receive(:get).with('stacks/test-grid/stack-a').and_return(stack_response)
|
|
69
|
+
allow(subject).to receive(:require_config_file).with('./path/to/kontena.yml').and_return(true)
|
|
70
|
+
allow(subject).to receive(:stack_from_yaml).with('./path/to/kontena.yml', name: 'stack-a', values: nil, defaults: defaults).and_return(stack)
|
|
71
|
+
allow(client).to receive(:put).with(
|
|
72
|
+
'stacks/test-grid/stack-a', anything
|
|
73
|
+
).and_return({})
|
|
74
|
+
expect(Kontena).to receive(:run).with(['stack', 'deploy', 'stack-a']).once
|
|
75
|
+
subject.run(['stack-a', './path/to/kontena.yml'])
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
context '--no-deploy option' do
|
|
79
|
+
it 'does not trigger deploy' do
|
|
80
|
+
expect(client).to receive(:get).with('stacks/test-grid/stack-a').and_return(stack_response)
|
|
81
|
+
allow(subject).to receive(:require_config_file).with('./path/to/kontena.yml').and_return(true)
|
|
82
|
+
allow(subject).to receive(:stack_from_yaml).with('./path/to/kontena.yml', name: 'stack-a', values: nil, defaults: defaults).and_return(stack)
|
|
83
|
+
allow(client).to receive(:put).with(
|
|
84
|
+
'stacks/test-grid/stack-a', anything
|
|
85
|
+
).and_return({})
|
|
86
|
+
expect(Kontena).not_to receive(:run).with(['stack', 'deploy', 'stack-a'])
|
|
87
|
+
subject.run(['--no-deploy', 'stack-a', './path/to/kontena.yml'])
|
|
81
88
|
end
|
|
82
89
|
end
|
|
83
90
|
end
|
|
@@ -392,6 +392,28 @@ describe Kontena::Cli::Stacks::YAML::Reader do
|
|
|
392
392
|
end
|
|
393
393
|
end
|
|
394
394
|
|
|
395
|
+
context 'origins' do
|
|
396
|
+
it 'can read from a file' do
|
|
397
|
+
expect(File).to receive(:read)
|
|
398
|
+
.with(absolute_yaml_path('kontena_v3.yml'))
|
|
399
|
+
.and_return(fixture('stack-with-liquid.yml'))
|
|
400
|
+
expect(subject.from_file?).to be_truthy
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
it 'can read from the registry' do
|
|
404
|
+
expect(Kontena::StacksCache).to receive(:pull)
|
|
405
|
+
.with('foo/foo')
|
|
406
|
+
.and_return(fixture('stack-with-liquid.yml'))
|
|
407
|
+
expect(Kontena::StacksCache).to receive(:registry_url).and_return('foo')
|
|
408
|
+
expect(described_class.new('foo/foo').from_registry?).to be_truthy
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
it 'can read from an url' do
|
|
412
|
+
stub_request(:get, "http://foo.example.com/foo").to_return(:status => 200, :body => fixture('stack-with-liquid.yml'), :headers => {})
|
|
413
|
+
expect(described_class.new('http://foo.example.com/foo').from_url?).to be_truthy
|
|
414
|
+
end
|
|
415
|
+
end
|
|
416
|
+
|
|
395
417
|
context 'liquid' do
|
|
396
418
|
context 'valid' do
|
|
397
419
|
before(:each) do
|
|
@@ -13,12 +13,16 @@ module ClientHelpers
|
|
|
13
13
|
'1234567'
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
base.let(:current_grid) do
|
|
17
|
+
'test-grid'
|
|
18
|
+
end
|
|
19
|
+
|
|
16
20
|
base.let(:settings) do
|
|
17
21
|
{'current_server' => 'alias',
|
|
18
22
|
'current_account' => 'kontena',
|
|
19
23
|
'servers' => [
|
|
20
24
|
{'name' => 'some_master', 'url' => 'some_master'},
|
|
21
|
-
{'name' => 'alias', 'url' => 'someurl', 'token' => token, 'account' => 'master'}
|
|
25
|
+
{'name' => 'alias', 'url' => 'someurl', 'token' => token, 'account' => 'master', 'grid' => current_grid},
|
|
22
26
|
]
|
|
23
27
|
}
|
|
24
28
|
end
|
|
@@ -26,7 +30,7 @@ module ClientHelpers
|
|
|
26
30
|
base.before(:each) do
|
|
27
31
|
RSpec::Mocks.space.proxy_for(File).reset
|
|
28
32
|
allow(subject).to receive(:client).and_return(client)
|
|
29
|
-
allow(subject).to receive(:current_grid).and_return(
|
|
33
|
+
allow(subject).to receive(:current_grid).and_return(current_grid)
|
|
30
34
|
allow(File).to receive(:exist?).with(File.join(Dir.home, '.kontena/certs/.pem')).and_return(false)
|
|
31
35
|
allow(File).to receive(:exist?).with(File.join(Dir.home, '.kontena_client.json')).and_return(true)
|
|
32
36
|
allow(File).to receive(:readable?).with(File.join(Dir.home, '.kontena_client.json')).and_return(true)
|
|
@@ -33,6 +33,29 @@ module OutputHelpers
|
|
|
33
33
|
match do |block|
|
|
34
34
|
stdout = Regexp.new('^' + lines.map{|fields| fields.join('\s+')}.join('\n') + '\n$', Regexp::MULTILINE)
|
|
35
35
|
|
|
36
|
+
|
|
37
|
+
begin
|
|
38
|
+
expect{@return = block.call}.to output(stdout).to_stdout
|
|
39
|
+
rescue Exception => error
|
|
40
|
+
@error = error
|
|
41
|
+
|
|
42
|
+
return false
|
|
43
|
+
else
|
|
44
|
+
return true
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
failure_message do |block|
|
|
49
|
+
return @error
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
matcher :output_lines do |lines|
|
|
54
|
+
supports_block_expectations
|
|
55
|
+
|
|
56
|
+
match do |block|
|
|
57
|
+
stdout = lines.flatten.join("\n") + "\n"
|
|
58
|
+
|
|
36
59
|
begin
|
|
37
60
|
expect{@return = block.call}.to output(stdout).to_stdout
|
|
38
61
|
rescue Exception => error
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kontena-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.0.
|
|
4
|
+
version: 1.1.0.rc2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kontena, Inc
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-02-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -290,13 +290,13 @@ files:
|
|
|
290
290
|
- lib/kontena/cli/containers/logs_command.rb
|
|
291
291
|
- lib/kontena/cli/etcd/common.rb
|
|
292
292
|
- lib/kontena/cli/etcd/get_command.rb
|
|
293
|
+
- lib/kontena/cli/etcd/health_command.rb
|
|
293
294
|
- lib/kontena/cli/etcd/list_command.rb
|
|
294
295
|
- lib/kontena/cli/etcd/mkdir_command.rb
|
|
295
296
|
- lib/kontena/cli/etcd/remove_command.rb
|
|
296
297
|
- lib/kontena/cli/etcd/set_command.rb
|
|
297
298
|
- lib/kontena/cli/etcd_command.rb
|
|
298
299
|
- lib/kontena/cli/external_registries/add_command.rb
|
|
299
|
-
- lib/kontena/cli/external_registries/delete_command.rb
|
|
300
300
|
- lib/kontena/cli/external_registries/list_command.rb
|
|
301
301
|
- lib/kontena/cli/external_registries/remove_command.rb
|
|
302
302
|
- lib/kontena/cli/external_registry_command.rb
|
|
@@ -326,7 +326,6 @@ files:
|
|
|
326
326
|
- lib/kontena/cli/helpers/health_helper.rb
|
|
327
327
|
- lib/kontena/cli/helpers/log_helper.rb
|
|
328
328
|
- lib/kontena/cli/localhost_web_server.rb
|
|
329
|
-
- lib/kontena/cli/login_command.rb
|
|
330
329
|
- lib/kontena/cli/logout_command.rb
|
|
331
330
|
- lib/kontena/cli/master/audit_log_command.rb
|
|
332
331
|
- lib/kontena/cli/master/config/export_command.rb
|
|
@@ -377,7 +376,6 @@ files:
|
|
|
377
376
|
- lib/kontena/cli/plugins/list_command.rb
|
|
378
377
|
- lib/kontena/cli/plugins/search_command.rb
|
|
379
378
|
- lib/kontena/cli/plugins/uninstall_command.rb
|
|
380
|
-
- lib/kontena/cli/register_command.rb
|
|
381
379
|
- lib/kontena/cli/registry/create_command.rb
|
|
382
380
|
- lib/kontena/cli/registry/remove_command.rb
|
|
383
381
|
- lib/kontena/cli/registry_command.rb
|
|
@@ -385,12 +383,12 @@ files:
|
|
|
385
383
|
- lib/kontena/cli/services/container_command.rb
|
|
386
384
|
- lib/kontena/cli/services/containers_command.rb
|
|
387
385
|
- lib/kontena/cli/services/create_command.rb
|
|
388
|
-
- lib/kontena/cli/services/delete_command.rb
|
|
389
386
|
- lib/kontena/cli/services/deploy_command.rb
|
|
390
387
|
- lib/kontena/cli/services/env_command.rb
|
|
391
388
|
- lib/kontena/cli/services/envs/add_command.rb
|
|
392
389
|
- lib/kontena/cli/services/envs/list_command.rb
|
|
393
390
|
- lib/kontena/cli/services/envs/remove_command.rb
|
|
391
|
+
- lib/kontena/cli/services/exec_command.rb
|
|
394
392
|
- lib/kontena/cli/services/link_command.rb
|
|
395
393
|
- lib/kontena/cli/services/list_command.rb
|
|
396
394
|
- lib/kontena/cli/services/logs_command.rb
|
|
@@ -437,6 +435,8 @@ files:
|
|
|
437
435
|
- lib/kontena/cli/stacks/yaml/custom_validators/secrets_validator.rb
|
|
438
436
|
- lib/kontena/cli/stacks/yaml/opto/prompt_resolver.rb
|
|
439
437
|
- lib/kontena/cli/stacks/yaml/opto/service_instances_resolver.rb
|
|
438
|
+
- lib/kontena/cli/stacks/yaml/opto/service_link_resolver.rb
|
|
439
|
+
- lib/kontena/cli/stacks/yaml/opto/vault_cert_prompt_resolver.rb
|
|
440
440
|
- lib/kontena/cli/stacks/yaml/opto/vault_resolver.rb
|
|
441
441
|
- lib/kontena/cli/stacks/yaml/opto/vault_setter.rb
|
|
442
442
|
- lib/kontena/cli/stacks/yaml/reader.rb
|
|
@@ -546,6 +546,7 @@ files:
|
|
|
546
546
|
- spec/kontena/cli/common_spec.rb
|
|
547
547
|
- spec/kontena/cli/containers/list_command_spec.rb
|
|
548
548
|
- spec/kontena/cli/containers/logs_command_spec.rb
|
|
549
|
+
- spec/kontena/cli/etcd/health_command_spec.rb
|
|
549
550
|
- spec/kontena/cli/grids/health_command_spec.rb
|
|
550
551
|
- spec/kontena/cli/grids/trusted_subnets/add_command_spec.rb
|
|
551
552
|
- spec/kontena/cli/grids/trusted_subnets/list_command_spec.rb
|
|
@@ -564,6 +565,7 @@ files:
|
|
|
564
565
|
- spec/kontena/cli/nodes/health_command_spec.rb
|
|
565
566
|
- spec/kontena/cli/nodes/list_command_spec.rb
|
|
566
567
|
- spec/kontena/cli/services/containers_command_spec.rb
|
|
568
|
+
- spec/kontena/cli/services/exec_command_spec.rb
|
|
567
569
|
- spec/kontena/cli/services/link_command_spec.rb
|
|
568
570
|
- spec/kontena/cli/services/restart_command_spec.rb
|
|
569
571
|
- spec/kontena/cli/services/secrets/link_command_spec.rb
|
|
@@ -618,7 +620,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
618
620
|
version: 1.3.1
|
|
619
621
|
requirements: []
|
|
620
622
|
rubyforge_project:
|
|
621
|
-
rubygems_version: 2.
|
|
623
|
+
rubygems_version: 2.6.8
|
|
622
624
|
signing_key:
|
|
623
625
|
specification_version: 4
|
|
624
626
|
summary: Kontena command line tool
|
|
@@ -672,6 +674,7 @@ test_files:
|
|
|
672
674
|
- spec/kontena/cli/common_spec.rb
|
|
673
675
|
- spec/kontena/cli/containers/list_command_spec.rb
|
|
674
676
|
- spec/kontena/cli/containers/logs_command_spec.rb
|
|
677
|
+
- spec/kontena/cli/etcd/health_command_spec.rb
|
|
675
678
|
- spec/kontena/cli/grids/health_command_spec.rb
|
|
676
679
|
- spec/kontena/cli/grids/trusted_subnets/add_command_spec.rb
|
|
677
680
|
- spec/kontena/cli/grids/trusted_subnets/list_command_spec.rb
|
|
@@ -690,6 +693,7 @@ test_files:
|
|
|
690
693
|
- spec/kontena/cli/nodes/health_command_spec.rb
|
|
691
694
|
- spec/kontena/cli/nodes/list_command_spec.rb
|
|
692
695
|
- spec/kontena/cli/services/containers_command_spec.rb
|
|
696
|
+
- spec/kontena/cli/services/exec_command_spec.rb
|
|
693
697
|
- spec/kontena/cli/services/link_command_spec.rb
|
|
694
698
|
- spec/kontena/cli/services/restart_command_spec.rb
|
|
695
699
|
- spec/kontena/cli/services/secrets/link_command_spec.rb
|