kontena-cli 0.11.7 → 0.12.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 +2 -4
- data/kontena-cli.gemspec +1 -0
- data/lib/kontena/cli/app_command.rb +1 -1
- data/lib/kontena/cli/apps/common.rb +30 -3
- data/lib/kontena/cli/apps/deploy_command.rb +1 -0
- data/lib/kontena/cli/apps/list_command.rb +1 -0
- data/lib/kontena/cli/apps/logs_command.rb +9 -3
- data/lib/kontena/cli/apps/monitor_command.rb +1 -0
- data/lib/kontena/cli/apps/remove_command.rb +2 -0
- data/lib/kontena/cli/apps/scale_command.rb +2 -1
- data/lib/kontena/cli/apps/show_command.rb +1 -0
- data/lib/kontena/cli/apps/start_command.rb +1 -0
- data/lib/kontena/cli/apps/stop_command.rb +1 -0
- data/lib/kontena/cli/common.rb +5 -1
- data/lib/kontena/cli/containers/exec_command.rb +1 -0
- data/lib/kontena/cli/containers/inspect_command.rb +1 -0
- data/lib/kontena/cli/etcd/get_command.rb +2 -1
- data/lib/kontena/cli/etcd/list_command.rb +1 -0
- data/lib/kontena/cli/etcd/mkdir_command.rb +2 -1
- data/lib/kontena/cli/etcd/remove_command.rb +2 -1
- data/lib/kontena/cli/etcd/set_command.rb +2 -1
- data/lib/kontena/cli/etcd_command.rb +2 -2
- data/lib/kontena/cli/external_registries/add_command.rb +1 -0
- data/lib/kontena/cli/external_registries/delete_command.rb +2 -0
- data/lib/kontena/cli/external_registries/list_command.rb +1 -0
- data/lib/kontena/cli/external_registries/remove_command.rb +13 -0
- data/lib/kontena/cli/external_registry_command.rb +4 -3
- data/lib/kontena/cli/grid_command.rb +5 -1
- data/lib/kontena/cli/grid_options.rb +12 -0
- data/lib/kontena/cli/grids/add_user_command.rb +1 -0
- data/lib/kontena/cli/grids/cloud_config_command.rb +41 -0
- data/lib/kontena/cli/grids/common.rb +65 -4
- data/lib/kontena/cli/grids/logs_command.rb +9 -4
- data/lib/kontena/cli/grids/remove_user_command.rb +1 -0
- data/lib/kontena/cli/grids/update_command.rb +27 -0
- data/lib/kontena/cli/master/use_command.rb +12 -2
- data/lib/kontena/cli/master/users/add_role_command.rb +26 -0
- data/lib/kontena/cli/master/users/invite_command.rb +24 -0
- data/lib/kontena/cli/master/users/list_command.rb +18 -0
- data/lib/kontena/cli/master/users/remove_role_command.rb +26 -0
- data/lib/kontena/cli/master/users_command.rb +14 -0
- data/lib/kontena/cli/master_command.rb +2 -1
- data/lib/kontena/cli/node_command.rb +7 -1
- data/lib/kontena/cli/nodes/add_label_command.rb +19 -0
- data/lib/kontena/cli/nodes/aws/create_command.rb +2 -1
- data/lib/kontena/cli/nodes/aws/restart_command.rb +1 -0
- data/lib/kontena/cli/nodes/aws/terminate_command.rb +1 -0
- data/lib/kontena/cli/nodes/azure/create_command.rb +1 -0
- data/lib/kontena/cli/nodes/azure/restart_command.rb +1 -0
- data/lib/kontena/cli/nodes/azure/terminate_command.rb +1 -0
- data/lib/kontena/cli/nodes/digital_ocean/create_command.rb +1 -0
- data/lib/kontena/cli/nodes/digital_ocean/restart_command.rb +1 -0
- data/lib/kontena/cli/nodes/digital_ocean/terminate_command.rb +1 -0
- data/lib/kontena/cli/nodes/list_command.rb +10 -14
- data/lib/kontena/cli/nodes/remove_command.rb +1 -0
- data/lib/kontena/cli/nodes/remove_label_command.rb +23 -0
- data/lib/kontena/cli/nodes/show_command.rb +1 -0
- data/lib/kontena/cli/nodes/ssh_command.rb +1 -0
- data/lib/kontena/cli/nodes/update_command.rb +1 -0
- data/lib/kontena/cli/nodes/vagrant/create_command.rb +1 -0
- data/lib/kontena/cli/nodes/vagrant/restart_command.rb +1 -0
- data/lib/kontena/cli/nodes/vagrant/ssh_command.rb +1 -0
- data/lib/kontena/cli/nodes/vagrant/start_command.rb +1 -0
- data/lib/kontena/cli/nodes/vagrant/stop_command.rb +1 -0
- data/lib/kontena/cli/nodes/vagrant/terminate_command.rb +1 -0
- data/lib/kontena/cli/registry/create_command.rb +80 -30
- data/lib/kontena/cli/registry/delete_command.rb +3 -0
- data/lib/kontena/cli/registry/remove_command.rb +15 -0
- data/lib/kontena/cli/registry_command.rb +3 -1
- data/lib/kontena/cli/service_command.rb +20 -4
- data/lib/kontena/cli/services/add_env_command.rb +1 -0
- data/lib/kontena/cli/services/add_secret_command.rb +24 -0
- data/lib/kontena/cli/services/containers_command.rb +1 -0
- data/lib/kontena/cli/services/create_command.rb +3 -2
- data/lib/kontena/cli/services/delete_command.rb +2 -0
- data/lib/kontena/cli/services/deploy_command.rb +1 -0
- data/lib/kontena/cli/services/envs_command.rb +1 -0
- data/lib/kontena/cli/services/link_command.rb +26 -0
- data/lib/kontena/cli/services/list_command.rb +13 -10
- data/lib/kontena/cli/services/logs_command.rb +13 -5
- data/lib/kontena/cli/services/monitor_command.rb +1 -0
- data/lib/kontena/cli/services/remove_command.rb +17 -0
- data/lib/kontena/cli/services/remove_env_command.rb +1 -0
- data/lib/kontena/cli/services/remove_secret_command.rb +28 -0
- data/lib/kontena/cli/services/restart_command.rb +1 -0
- data/lib/kontena/cli/services/scale_command.rb +2 -1
- data/lib/kontena/cli/services/show_command.rb +1 -0
- data/lib/kontena/cli/services/start_command.rb +1 -0
- data/lib/kontena/cli/services/stats_command.rb +5 -4
- data/lib/kontena/cli/services/stop_command.rb +1 -0
- data/lib/kontena/cli/services/unlink_command.rb +25 -0
- data/lib/kontena/cli/services/update_command.rb +4 -3
- data/lib/kontena/cli/users_command.rb +15 -0
- data/lib/kontena/cli/vault/list_command.rb +1 -0
- data/lib/kontena/cli/vault/read_command.rb +1 -0
- data/lib/kontena/cli/vault/remove_command.rb +1 -0
- data/lib/kontena/cli/vault/write_command.rb +1 -0
- data/lib/kontena/cli/version_command.rb +9 -1
- data/lib/kontena/cli/vpn/config_command.rb +1 -0
- data/lib/kontena/cli/vpn/create_command.rb +1 -0
- data/lib/kontena/cli/vpn/delete_command.rb +2 -0
- data/lib/kontena/cli/vpn/remove_command.rb +15 -0
- data/lib/kontena/cli/vpn_command.rb +3 -1
- data/lib/kontena/machine/aws/node_destroyer.rb +1 -1
- data/lib/kontena/machine/cloud_config/cloudinit.yml +70 -0
- data/lib/kontena/machine/cloud_config/node_generator.rb +28 -0
- data/lib/kontena/machine/digital_ocean/cloudinit.yml +22 -0
- data/lib/kontena/machine/digital_ocean/node_destroyer.rb +4 -2
- data/lib/kontena/machine/random_name.rb +3 -3
- data/lib/kontena/scripts/completer +7 -3
- data/spec/fixtures/docker-compose.yml +8 -0
- data/spec/fixtures/kontena.yml +17 -0
- data/spec/fixtures/mysql.yml +3 -0
- data/spec/fixtures/wordpress-scaled.yml +3 -0
- data/spec/fixtures/wordpress.yml +2 -0
- data/spec/kontena/cli/app/common_spec.rb +42 -0
- data/spec/kontena/cli/app/deploy_command_spec.rb +4 -31
- data/spec/kontena/cli/app/scale_spec.rb +4 -23
- data/spec/kontena/cli/master/use_command_spec.rb +12 -3
- data/spec/kontena/cli/master/users/add_role_command_spec.rb +35 -0
- data/spec/kontena/cli/master/users/invite_command_spec.rb +35 -0
- data/spec/kontena/cli/master/users/remove_role_command_spec.rb +35 -0
- data/spec/kontena/cli/services/add_secret_command_spec.rb +61 -0
- data/spec/kontena/cli/services/link_command_spec.rb +43 -0
- data/spec/kontena/cli/services/remove_secret_command_spec.rb +48 -0
- data/spec/kontena/cli/services/restart_command_spec.rb +1 -23
- data/spec/kontena/cli/services/unlink_command_spec.rb +43 -0
- data/spec/kontena/cli/version_command_spec.rb +17 -0
- data/spec/spec_helper.rb +6 -1
- data/spec/support/client_helpers.rb +31 -0
- data/spec/support/fixtures_helpers.rb +7 -0
- metadata +67 -6
- data/lib/kontena/cli/deploy_command.rb +0 -164
- data/lib/kontena/cli/invite_command.rb +0 -13
- data/spec/kontena/cli/deploy_command_spec.rb +0 -239
@@ -2,11 +2,53 @@ require_relative "../../../spec_helper"
|
|
2
2
|
require "kontena/cli/apps/common"
|
3
3
|
|
4
4
|
describe Kontena::Cli::Apps::Common do
|
5
|
+
include ClientHelpers
|
6
|
+
include FixturesHelpers
|
5
7
|
|
6
8
|
let(:subject) do
|
7
9
|
Class.new { include Kontena::Cli::Apps::Common}.new
|
8
10
|
end
|
9
11
|
|
12
|
+
let(:kontena_yml) do
|
13
|
+
fixture('kontena.yml')
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:docker_compose_yml) do
|
17
|
+
fixture('docker-compose.yml')
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:mysql_yml) do
|
21
|
+
fixture('mysql.yml')
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:services) do
|
25
|
+
{
|
26
|
+
'wordpress' => {
|
27
|
+
'image' => 'wordpress:4.1',
|
28
|
+
'ports' => ['80:80']
|
29
|
+
}
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#parse_services' do
|
34
|
+
|
35
|
+
it 'returns services from given YAML file' do
|
36
|
+
allow(File).to receive(:read).with("#{Dir.getwd}/kontena.yml").and_return(kontena_yml)
|
37
|
+
allow(File).to receive(:read).with("#{Dir.getwd}/docker-compose.yml").and_return(docker_compose_yml)
|
38
|
+
services = subject.parse_services('kontena.yml')
|
39
|
+
expect(services['wordpress']).not_to be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'raises error if extended service is not found from base file' do
|
43
|
+
allow(File).to receive(:read).with("#{Dir.getwd}/kontena.yml").and_return(kontena_yml)
|
44
|
+
allow(File).to receive(:read).with("#{Dir.getwd}/docker-compose.yml").and_return(mysql_yml)
|
45
|
+
|
46
|
+
expect {
|
47
|
+
subject.parse_services('kontena.yml')
|
48
|
+
}.to raise_error(SystemExit)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
10
52
|
describe '#normalize_env_vars' do
|
11
53
|
it 'converts env hash to array' do
|
12
54
|
opts = {
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require_relative "../../../spec_helper"
|
2
|
+
require 'kontena/cli/grid_options'
|
2
3
|
require "kontena/cli/apps/deploy_command"
|
3
4
|
|
4
5
|
describe Kontena::Cli::Apps::DeployCommand do
|
6
|
+
include FixturesHelpers
|
5
7
|
|
6
8
|
let(:subject) do
|
7
9
|
described_class.new(File.basename($0))
|
@@ -37,40 +39,11 @@ describe Kontena::Cli::Apps::DeployCommand do
|
|
37
39
|
end
|
38
40
|
|
39
41
|
let(:docker_compose_yml) do
|
40
|
-
|
41
|
-
wordpress:
|
42
|
-
image: wordpress:4.1
|
43
|
-
ports:
|
44
|
-
- 80:80
|
45
|
-
links:
|
46
|
-
- mysql:mysql
|
47
|
-
mysql:
|
48
|
-
image: mysql:5.6
|
49
|
-
yml
|
50
|
-
yml_content
|
42
|
+
fixture('docker-compose.yml')
|
51
43
|
end
|
52
44
|
|
53
45
|
let(:kontena_yml) do
|
54
|
-
|
55
|
-
wordpress:
|
56
|
-
extends:
|
57
|
-
file: docker-compose.yml
|
58
|
-
service: wordpress
|
59
|
-
stateful: true
|
60
|
-
environment:
|
61
|
-
- WORDPRESS_DB_PASSWORD=%{project}_secret
|
62
|
-
instances: 2
|
63
|
-
deploy:
|
64
|
-
strategy: ha
|
65
|
-
mysql:
|
66
|
-
extends:
|
67
|
-
file: docker-compose.yml
|
68
|
-
service: mysql
|
69
|
-
stateful: true
|
70
|
-
environment:
|
71
|
-
- MYSQL_ROOT_PASSWORD=%{project}_secret
|
72
|
-
yml
|
73
|
-
yml_content
|
46
|
+
fixture('kontena.yml')
|
74
47
|
end
|
75
48
|
|
76
49
|
let(:services) do
|
@@ -2,42 +2,23 @@ require_relative "../../../spec_helper"
|
|
2
2
|
require "kontena/cli/apps/scale_command"
|
3
3
|
|
4
4
|
describe Kontena::Cli::Apps::ScaleCommand do
|
5
|
+
include FixturesHelpers
|
6
|
+
include ClientHelpers
|
5
7
|
|
6
8
|
let(:subject) do
|
7
9
|
described_class.new(File.basename($0))
|
8
10
|
end
|
9
11
|
|
10
|
-
let(:settings) do
|
11
|
-
{'current_server' => 'alias',
|
12
|
-
'servers' => [
|
13
|
-
{'name' => 'some_master', 'url' => 'some_master'},
|
14
|
-
{'name' => 'alias', 'url' => 'someurl', 'token' => token}
|
15
|
-
]
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
let(:token) do
|
20
|
-
'1234567'
|
21
|
-
end
|
22
|
-
|
23
12
|
let(:kontena_yml) do
|
24
|
-
|
25
|
-
wordpress:
|
26
|
-
image: wordpress:latest
|
27
|
-
instances: 2
|
28
|
-
yml
|
13
|
+
fixture('wordpress-scaled.yml')
|
29
14
|
end
|
30
15
|
|
31
16
|
let(:kontena_yml_no_instances) do
|
32
|
-
|
33
|
-
wordpress:
|
34
|
-
image: wordpress:latest
|
35
|
-
yml
|
17
|
+
fixture('wordpress.yml')
|
36
18
|
end
|
37
19
|
|
38
20
|
describe '#execute' do
|
39
21
|
before(:each) do
|
40
|
-
allow(subject).to receive(:settings).and_return(settings)
|
41
22
|
allow(subject).to receive(:current_dir).and_return("kontena-test")
|
42
23
|
allow(File).to receive(:exists?).and_return(true)
|
43
24
|
allow(File).to receive(:read).with("#{Dir.getwd}/kontena.yml").and_return(kontena_yml)
|
@@ -7,6 +7,8 @@ describe Kontena::Cli::Master::UseCommand do
|
|
7
7
|
described_class.new(File.basename($0))
|
8
8
|
end
|
9
9
|
|
10
|
+
let(:client) { spy(:client) }
|
11
|
+
|
10
12
|
let(:valid_settings) do
|
11
13
|
{'current_server' => 'alias',
|
12
14
|
'servers' => [
|
@@ -17,13 +19,20 @@ describe Kontena::Cli::Master::UseCommand do
|
|
17
19
|
end
|
18
20
|
|
19
21
|
describe '#use' do
|
20
|
-
|
21
22
|
it 'should update current master' do
|
23
|
+
allow(subject).to receive(:client).and_return(client)
|
22
24
|
allow(subject).to receive(:settings).and_return(valid_settings)
|
23
25
|
expect(subject).to receive(:current_master=).with('some_master')
|
24
26
|
subject.run(['some_master'])
|
25
27
|
end
|
26
28
|
|
29
|
+
it 'should fetch grid list from master' do
|
30
|
+
allow(subject).to receive(:require_token).and_return('token')
|
31
|
+
allow(subject).to receive(:client).and_return(client)
|
32
|
+
allow(subject).to receive(:settings).and_return(valid_settings)
|
33
|
+
expect(subject).to receive(:current_master=).with('some_master')
|
34
|
+
expect(client).to receive(:get).with('grids')
|
35
|
+
subject.run(['some_master'])
|
36
|
+
end
|
27
37
|
end
|
28
|
-
|
29
|
-
end
|
38
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative "../../../../spec_helper"
|
2
|
+
require 'kontena/cli/master/users_command'
|
3
|
+
require 'kontena/cli/master/users/add_role_command'
|
4
|
+
|
5
|
+
describe Kontena::Cli::Master::Users::AddRoleCommand do
|
6
|
+
|
7
|
+
let(:subject) do
|
8
|
+
described_class.new(File.basename($0))
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:client) { spy(:client) }
|
12
|
+
|
13
|
+
let(:valid_settings) do
|
14
|
+
{'current_server' => 'alias',
|
15
|
+
'servers' => [
|
16
|
+
{'name' => 'some_master', 'url' => 'some_master'},
|
17
|
+
{'name' => 'alias', 'url' => 'someurl', 'token' => '123456'}
|
18
|
+
]
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#add-role" do
|
23
|
+
before(:each) do
|
24
|
+
allow(subject).to receive(:client).and_return(client)
|
25
|
+
allow(subject).to receive(:settings).and_return(valid_settings)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'makes add role request for all given users' do
|
29
|
+
expect(client).to receive(:post).with("users/john@example.org/roles", {role: 'role'}).once
|
30
|
+
expect(client).to receive(:post).with("users/jane@example.org/roles", {role: 'role'}).once
|
31
|
+
|
32
|
+
subject.run(['role', 'john@example.org', 'jane@example.org'])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative "../../../../spec_helper"
|
2
|
+
require 'kontena/cli/master/users_command'
|
3
|
+
require 'kontena/cli/master/users/invite_command'
|
4
|
+
|
5
|
+
describe Kontena::Cli::Master::Users::InviteCommand do
|
6
|
+
|
7
|
+
let(:subject) do
|
8
|
+
described_class.new(File.basename($0))
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:valid_settings) do
|
12
|
+
{'current_server' => 'alias',
|
13
|
+
'servers' => [
|
14
|
+
{'name' => 'some_master', 'url' => 'some_master'},
|
15
|
+
{'name' => 'alias', 'url' => 'someurl', 'token' => '123456'}
|
16
|
+
]
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:client) { spy(:client) }
|
21
|
+
|
22
|
+
describe "#invite" do
|
23
|
+
before(:each) do
|
24
|
+
allow(subject).to receive(:client).and_return(client)
|
25
|
+
allow(subject).to receive(:settings).and_return(valid_settings)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'makes invitation request for all given users' do
|
29
|
+
expect(client).to receive(:post).with("users", {email: 'john@example.org'}).once
|
30
|
+
expect(client).to receive(:post).with("users", {email: 'jane@example.org'}).once
|
31
|
+
|
32
|
+
subject.run(['john@example.org', 'jane@example.org'])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative "../../../../spec_helper"
|
2
|
+
require 'kontena/cli/master/users_command'
|
3
|
+
require 'kontena/cli/master/users/remove_role_command'
|
4
|
+
|
5
|
+
describe Kontena::Cli::Master::Users::RemoveRoleCommand do
|
6
|
+
|
7
|
+
let(:subject) do
|
8
|
+
described_class.new(File.basename($0))
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:valid_settings) do
|
12
|
+
{'current_server' => 'alias',
|
13
|
+
'servers' => [
|
14
|
+
{'name' => 'some_master', 'url' => 'some_master'},
|
15
|
+
{'name' => 'alias', 'url' => 'someurl', 'token' => '123456'}
|
16
|
+
]
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:client) { spy(:client) }
|
21
|
+
|
22
|
+
describe "#remove-role" do
|
23
|
+
before(:each) do
|
24
|
+
allow(subject).to receive(:client).and_return(client)
|
25
|
+
allow(subject).to receive(:settings).and_return(valid_settings)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'makes remove role request for all given users' do
|
29
|
+
expect(client).to receive(:delete).with("users/john@example.org/roles/role").once
|
30
|
+
expect(client).to receive(:delete).with("users/jane@example.org/roles/role").once
|
31
|
+
|
32
|
+
subject.run(['role', 'john@example.org', 'jane@example.org'])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require_relative "../../../spec_helper"
|
2
|
+
require "kontena/cli/services/add_secret_command"
|
3
|
+
|
4
|
+
describe Kontena::Cli::Services::AddSecretCommand do
|
5
|
+
|
6
|
+
include ClientHelpers
|
7
|
+
|
8
|
+
describe '#execute' do
|
9
|
+
it 'requires api url' do
|
10
|
+
expect(subject).to receive(:require_api_url).once
|
11
|
+
subject.run(['service', 'secret:name:env'])
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'requires token' do
|
15
|
+
expect(subject).to receive(:require_token).and_return(token)
|
16
|
+
subject.run(['service', 'secret:name:env'])
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'requires service as param' do
|
20
|
+
expect {
|
21
|
+
subject.run([])
|
22
|
+
}.to raise_error(Clamp::UsageError)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'requires secret as param' do
|
26
|
+
expect {
|
27
|
+
subject.run(['service'])
|
28
|
+
}.to raise_error(Clamp::UsageError)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'sends secrets to master' do
|
32
|
+
data = {
|
33
|
+
secrets: [
|
34
|
+
{secret: 'MY_PASSWORD', name: 'PASSWORD', type: 'env'}
|
35
|
+
]
|
36
|
+
}
|
37
|
+
allow(client).to receive(:get).with("services/test-grid/foo").and_return({
|
38
|
+
'secrets' => []
|
39
|
+
})
|
40
|
+
expect(client).to receive(:put).with("services/test-grid/foo", data)
|
41
|
+
subject.run(['foo', 'MY_PASSWORD:PASSWORD:env'])
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'appends secret to existing list' do
|
45
|
+
original = {
|
46
|
+
'secrets' => [
|
47
|
+
{'secret' => 'FOO', 'name' => 'BAR', 'type' => 'env'}
|
48
|
+
]
|
49
|
+
}
|
50
|
+
data = {
|
51
|
+
secrets: [
|
52
|
+
{'secret' => 'FOO', 'name' => 'BAR', 'type' => 'env'},
|
53
|
+
{secret: 'MY_PASSWORD', name: 'PASSWORD', type: 'env'}
|
54
|
+
]
|
55
|
+
}
|
56
|
+
allow(client).to receive(:get).with("services/test-grid/foo").and_return(original)
|
57
|
+
expect(client).to receive(:put).with("services/test-grid/foo", data)
|
58
|
+
subject.run(['foo', 'MY_PASSWORD:PASSWORD:env'])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative "../../../spec_helper"
|
2
|
+
require "kontena/cli/services/link_command"
|
3
|
+
|
4
|
+
describe Kontena::Cli::Services::LinkCommand do
|
5
|
+
|
6
|
+
include ClientHelpers
|
7
|
+
|
8
|
+
describe '#execute' do
|
9
|
+
before(:each) do
|
10
|
+
allow(client).to receive(:get).and_return({
|
11
|
+
'links' => []
|
12
|
+
})
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'requires api url' do
|
16
|
+
expect(subject).to receive(:require_api_url).once
|
17
|
+
subject.run(['service-a', 'service-b'])
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'requires token' do
|
21
|
+
expect(subject).to receive(:require_token).and_return(token)
|
22
|
+
subject.run(['service-a', 'service-b'])
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'aborts if service is already linked' do
|
26
|
+
allow(client).to receive(:get).and_return({
|
27
|
+
'links' => [
|
28
|
+
{'alias' => 'service-b', 'grid_service_id' => "grid/service-b"}
|
29
|
+
]
|
30
|
+
})
|
31
|
+
expect {
|
32
|
+
subject.run(['service-a', 'service-b'])
|
33
|
+
}.to raise_error(SystemExit)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'sends link to master' do
|
37
|
+
expect(client).to receive(:put).with(
|
38
|
+
'services/test-grid/service-a', {links: [{name: 'service-b', alias: 'service-b'}]}
|
39
|
+
)
|
40
|
+
subject.run(['service-a', 'service-b'])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative "../../../spec_helper"
|
2
|
+
require "kontena/cli/services/remove_secret_command"
|
3
|
+
|
4
|
+
describe Kontena::Cli::Services::RemoveSecretCommand do
|
5
|
+
|
6
|
+
include ClientHelpers
|
7
|
+
|
8
|
+
describe '#execute' do
|
9
|
+
it 'requires api url' do
|
10
|
+
expect(subject).to receive(:require_api_url).once
|
11
|
+
subject.run(['service', 'secret:name:env'])
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'requires token' do
|
15
|
+
expect(subject).to receive(:require_token).and_return(token)
|
16
|
+
subject.run(['service', 'secret:name:env'])
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'requires service as param' do
|
20
|
+
expect {
|
21
|
+
subject.run([])
|
22
|
+
}.to raise_error(Clamp::UsageError)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'requires secret as param' do
|
26
|
+
expect {
|
27
|
+
subject.run(['service'])
|
28
|
+
}.to raise_error(Clamp::UsageError)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'removes secret to existing list' do
|
32
|
+
original = {
|
33
|
+
'secrets' => [
|
34
|
+
{'secret' => 'FOO', 'name' => 'BAR', 'type' => 'env'},
|
35
|
+
{'secret' => 'BAR', 'name' => 'BAZ', 'type' => 'env'}
|
36
|
+
]
|
37
|
+
}
|
38
|
+
data = {
|
39
|
+
secrets: [
|
40
|
+
{'secret' => 'BAR', 'name' => 'BAZ', 'type' => 'env'}
|
41
|
+
]
|
42
|
+
}
|
43
|
+
allow(client).to receive(:get).with("services/test-grid/mymy").and_return(original)
|
44
|
+
expect(client).to receive(:put).with("services/test-grid/mymy", data)
|
45
|
+
subject.run(['mymy', 'FOO:BAR:env'])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|