kontena-cli 0.14.0 → 0.14.1
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/lib/kontena/cli/apps/build_command.rb +2 -3
- data/lib/kontena/cli/apps/config_command.rb +1 -5
- data/lib/kontena/cli/master/aws/create_command.rb +6 -1
- data/lib/kontena/cli/nodes/aws/create_command.rb +5 -1
- data/lib/kontena/cli/services/update_command.rb +6 -6
- data/lib/kontena/machine/aws/common.rb +20 -0
- data/lib/kontena/machine/aws/master_provisioner.rb +33 -18
- data/lib/kontena/machine/aws/node_provisioner.rb +24 -14
- data/lib/kontena/machine/azure/node_provisioner.rb +2 -1
- data/lib/kontena/machine/digital_ocean/node_provisioner.rb +8 -1
- data/lib/kontena/machine/upcloud/master_provisioner.rb +2 -0
- data/lib/kontena/machine/upcloud/node_destroyer.rb +3 -0
- data/lib/kontena/machine/upcloud/node_provisioner.rb +2 -0
- data/lib/kontena/machine/upcloud/node_restarter.rb +2 -0
- data/lib/kontena/machine/upcloud/upcloud_common.rb +13 -9
- data/spec/kontena/cli/app/build_command_spec.rb +56 -0
- data/spec/kontena/cli/app/config_command_spec.rb +78 -0
- data/spec/kontena/cli/services/update_command_spec.rb +56 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 271ff6357fc144663ce26127000670ee955591f9
|
4
|
+
data.tar.gz: 3c649adbd8e51c377d91f2ccff9e1cddaf83d198
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a324873b2090e75da968425299e6d15581d5d0632be85e53f1664501b212c8c0aca79f11a7f42c0e1a10cb90f4cf2c325452d0a32047f849d9d87ef0ed50b867
|
7
|
+
data.tar.gz: 3b60be978cfbb2a686f02e9e1353a62627ea11fd4bc71854018b65d1d542da2ac0a303197b10b0712dfc05531564f041899ea657d96976f213125e3d3b44f41b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.14.
|
1
|
+
0.14.1
|
@@ -12,12 +12,11 @@ module Kontena::Cli::Apps
|
|
12
12
|
option ['--no-cache'], :flag, 'Do not use cache when building the image', default: false
|
13
13
|
parameter "[SERVICE] ...", "Services to build"
|
14
14
|
|
15
|
-
attr_reader :services
|
15
|
+
attr_reader :services
|
16
16
|
|
17
17
|
def execute
|
18
18
|
require_config_file(filename)
|
19
|
-
@
|
20
|
-
@services = load_services(filename, service_list, service_prefix)
|
19
|
+
@services = services_from_yaml(filename, service_list, service_prefix)
|
21
20
|
process_docker_images(services, true, no_cache?)
|
22
21
|
end
|
23
22
|
end
|
@@ -3,8 +3,7 @@ require 'pp'
|
|
3
3
|
|
4
4
|
module Kontena::Cli::Apps
|
5
5
|
class ConfigCommand < Clamp::Command
|
6
|
-
include Kontena::Cli::Common
|
7
|
-
include Kontena::Cli::GridOptions
|
6
|
+
include Kontena::Cli::Common
|
8
7
|
include Common
|
9
8
|
|
10
9
|
option ['-f', '--file'], 'FILE', 'Specify an alternate Kontena compose file', attribute_name: :filename, default: 'kontena.yml'
|
@@ -12,11 +11,8 @@ module Kontena::Cli::Apps
|
|
12
11
|
|
13
12
|
parameter "[SERVICE] ...", "Services to view"
|
14
13
|
|
15
|
-
attr_reader :service_prefix
|
16
|
-
|
17
14
|
def execute
|
18
15
|
require_config_file(filename)
|
19
|
-
@service_prefix = project_name || current_dir
|
20
16
|
services = services_from_yaml(filename, service_list, service_prefix)
|
21
17
|
services.each do |name, config|
|
22
18
|
config['cmd'] = config['cmd'].join(" ") if config['cmd']
|
@@ -19,6 +19,9 @@ module Kontena::Cli::Master::Aws
|
|
19
19
|
option "--mongodb-uri", "URI", "External MongoDB uri (optional)"
|
20
20
|
option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
|
21
21
|
option "--auth-provider-url", "AUTH_PROVIDER_URL", "Define authentication provider url (optional)"
|
22
|
+
option "--associate-public-ip-address", :flag, "Whether to associated public IP in case the VPC defaults to not doing it", default: false, attribute_name: :associate_public_ip
|
23
|
+
option "--security-groups", "SECURITY GROUPS", "Comma separated list of security groups (names) where the new instance will be attached (default: create 'kontena_master' group if not already existing)"
|
24
|
+
|
22
25
|
|
23
26
|
def execute
|
24
27
|
require 'kontena/machine/aws'
|
@@ -36,7 +39,9 @@ module Kontena::Cli::Master::Aws
|
|
36
39
|
auth_server: auth_provider_url,
|
37
40
|
vault_secret: vault_secret || SecureRandom.hex(24),
|
38
41
|
vault_iv: vault_iv || SecureRandom.hex(24),
|
39
|
-
mongodb_uri: mongodb_uri
|
42
|
+
mongodb_uri: mongodb_uri,
|
43
|
+
associate_public_ip: associate_public_ip?,
|
44
|
+
security_groups: security_groups
|
40
45
|
)
|
41
46
|
end
|
42
47
|
end
|
@@ -14,6 +14,8 @@ module Kontena::Cli::Nodes::Aws
|
|
14
14
|
option "--type", "SIZE", "Instance type", default: 't2.small'
|
15
15
|
option "--storage", "STORAGE", "Storage size (GiB)", default: '30'
|
16
16
|
option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
|
17
|
+
option "--associate-public-ip-address", :flag, "Whether to associated public IP in case the VPC defaults to not doing it", default: false, attribute_name: :associate_public_ip
|
18
|
+
option "--security-groups", "SECURITY GROUPS", "Comma separated list of security groups (names) where the new instance will be attached (default: create grid specific group if not already existing)"
|
17
19
|
|
18
20
|
def execute
|
19
21
|
require_api_url
|
@@ -33,7 +35,9 @@ module Kontena::Cli::Nodes::Aws
|
|
33
35
|
subnet: subnet_id,
|
34
36
|
storage: storage,
|
35
37
|
version: version,
|
36
|
-
key_pair: key_pair
|
38
|
+
key_pair: key_pair,
|
39
|
+
associate_public_ip: associate_public_ip?,
|
40
|
+
security_groups: security_groups
|
37
41
|
)
|
38
42
|
end
|
39
43
|
end
|
@@ -20,11 +20,11 @@ module Kontena::Cli::Services
|
|
20
20
|
option "--instances", "INSTANCES", "How many instances should be deployed"
|
21
21
|
option ["-u", "--user"], "USER", "Username who executes first process inside container"
|
22
22
|
option "--privileged", :flag, "Give extended privileges to this service", default: false
|
23
|
-
option "--cap-add", "CAP_ADD", "Add capabitilies", multivalued: true
|
24
|
-
option "--cap-drop", "CAP_DROP", "Drop capabitilies", multivalued: true
|
23
|
+
option "--cap-add", "CAP_ADD", "Add capabitilies", multivalued: true, default: nil
|
24
|
+
option "--cap-drop", "CAP_DROP", "Drop capabitilies", multivalued: true, default: nil
|
25
25
|
option "--net", "NET", "Network mode"
|
26
26
|
option "--log-driver", "LOG_DRIVER", "Set logging driver"
|
27
|
-
option "--log-opt", "LOG_OPT", "Add logging options", multivalued: true
|
27
|
+
option "--log-opt", "LOG_OPT", "Add logging options", multivalued: true, default: nil
|
28
28
|
option "--deploy-strategy", "STRATEGY", "Deploy strategy to use (ha, daemon, random)"
|
29
29
|
option "--deploy-wait-for-port", "PORT", "Wait for port to respond when deploying"
|
30
30
|
option "--deploy-min-health", "FLOAT", "The minimum percentage (0.0 - 1.0) of healthy instances that do not sacrifice overall service availability while deploying"
|
@@ -59,11 +59,11 @@ module Kontena::Cli::Services
|
|
59
59
|
data[:user] = user if user
|
60
60
|
data[:image] = parse_image(image) if image
|
61
61
|
data[:privileged] = privileged?
|
62
|
-
data[:cap_add] = cap_add_list
|
63
|
-
data[:cap_drop] = cap_drop_list
|
62
|
+
data[:cap_add] = cap_add_list if cap_add_list
|
63
|
+
data[:cap_drop] = cap_drop_list if cap_drop_list
|
64
64
|
data[:net] = net if net
|
65
65
|
data[:log_driver] = log_driver if log_driver
|
66
|
-
data[:log_opts] = parse_log_opts(log_opt_list)
|
66
|
+
data[:log_opts] = parse_log_opts(log_opt_list) if log_opt_list
|
67
67
|
data[:deploy_opts] = {}
|
68
68
|
data[:deploy_opts][:min_health] = deploy_min_health.to_f if deploy_min_health
|
69
69
|
data[:deploy_opts][:wait_for_port] = deploy_wait_for_port.to_i if deploy_wait_for_port
|
@@ -32,6 +32,26 @@ module Kontena
|
|
32
32
|
def default_vpc
|
33
33
|
ec2.vpcs({filters: [{name: "is-default", values: ["true"]}]}).first
|
34
34
|
end
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
##
|
39
|
+
# Resolves givne list of group names into group ids
|
40
|
+
# @param [String] comma separated list of group names
|
41
|
+
# @return [Array]
|
42
|
+
def resolve_security_groups_to_ids(group_list, vpc_id)
|
43
|
+
ids = group_list.split(',').map { |group|
|
44
|
+
sg = ec2.security_groups({
|
45
|
+
filters: [
|
46
|
+
{name: 'group-name', values: [group]},
|
47
|
+
{name: 'vpc-id', values: [vpc_id]}
|
48
|
+
]
|
49
|
+
}).first
|
50
|
+
|
51
|
+
sg ? sg.group_id : nil
|
52
|
+
}
|
53
|
+
ids.compact
|
54
|
+
end
|
35
55
|
end
|
36
56
|
end
|
37
57
|
end
|
@@ -42,6 +42,7 @@ module Kontena
|
|
42
42
|
else
|
43
43
|
subnet = ec2.subnet(opts[:subnet])
|
44
44
|
end
|
45
|
+
abort('Failed to find subnet!') unless subnet
|
45
46
|
userdata_vars = {
|
46
47
|
ssl_cert: ssl_cert,
|
47
48
|
auth_server: opts[:auth_server],
|
@@ -51,16 +52,17 @@ module Kontena
|
|
51
52
|
mongodb_uri: opts[:mongodb_uri]
|
52
53
|
}
|
53
54
|
|
54
|
-
|
55
|
+
security_groups = opts[:security_groups] ?
|
56
|
+
resolve_security_groups_to_ids(opts[:security_groups], opts[:vpc]) :
|
57
|
+
ensure_security_group(opts[:vpc])
|
58
|
+
|
55
59
|
name = generate_name
|
56
60
|
ec2_instance = ec2.create_instances({
|
57
61
|
image_id: ami,
|
58
62
|
min_count: 1,
|
59
63
|
max_count: 1,
|
60
64
|
instance_type: opts[:type],
|
61
|
-
security_group_ids: [security_group.group_id],
|
62
65
|
key_name: opts[:key_pair],
|
63
|
-
subnet_id: subnet.subnet_id,
|
64
66
|
user_data: Base64.encode64(user_data(userdata_vars)),
|
65
67
|
block_device_mappings: [
|
66
68
|
{
|
@@ -71,6 +73,15 @@ module Kontena
|
|
71
73
|
volume_type: 'gp2'
|
72
74
|
}
|
73
75
|
}
|
76
|
+
],
|
77
|
+
network_interfaces: [
|
78
|
+
{
|
79
|
+
device_index: 0,
|
80
|
+
subnet_id: subnet.subnet_id,
|
81
|
+
groups: security_groups,
|
82
|
+
associate_public_ip_address: opts[:associate_public_ip],
|
83
|
+
delete_on_termination: true
|
84
|
+
}
|
74
85
|
]
|
75
86
|
}).first
|
76
87
|
ec2_instance.create_tags({
|
@@ -78,37 +89,41 @@ module Kontena
|
|
78
89
|
{key: 'Name', value: name}
|
79
90
|
]
|
80
91
|
})
|
92
|
+
|
81
93
|
ShellSpinner "Creating AWS instance #{name.colorize(:cyan)} " do
|
82
94
|
sleep 5 until ec2_instance.reload.state.name == 'running'
|
83
95
|
end
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
96
|
+
public_ip = ec2_instance.reload.public_ip_address
|
97
|
+
if public_ip.nil?
|
98
|
+
master_url = "https://#{ec2_instance.private_ip_address}"
|
99
|
+
puts "Could not get public IP for the created master, private connect url is: #{master_url}"
|
100
|
+
else
|
101
|
+
master_url = "https://#{ec2_instance.public_ip_address}"
|
102
|
+
Excon.defaults[:ssl_verify_peer] = false
|
103
|
+
http_client = Excon.new(master_url, :connect_timeout => 10)
|
104
|
+
ShellSpinner "Waiting for #{name.colorize(:cyan)} to start " do
|
105
|
+
sleep 5 until master_running?(http_client)
|
106
|
+
end
|
89
107
|
end
|
90
|
-
|
108
|
+
|
91
109
|
puts "Kontena Master is now running at #{master_url}"
|
92
110
|
puts "Use #{"kontena login --name=#{name.sub('kontena-master-', '')} #{master_url}".colorize(:light_black)} to complete Kontena Master setup"
|
93
111
|
end
|
94
112
|
|
95
113
|
##
|
96
114
|
# @param [String] vpc_id
|
97
|
-
# @return [
|
115
|
+
# @return [Array] Security group id in array
|
98
116
|
def ensure_security_group(vpc_id)
|
99
117
|
group_name = "kontena_master"
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
{name: 'vpc-id', values: [vpc_id]}
|
104
|
-
]
|
105
|
-
}).first
|
106
|
-
unless sg
|
118
|
+
group_id = resolve_security_groups_to_ids(group_name, vpc_id)
|
119
|
+
|
120
|
+
if group_id.empty?
|
107
121
|
ShellSpinner "Creating AWS security group" do
|
108
122
|
sg = create_security_group(group_name, vpc_id)
|
123
|
+
group_id = [sg.group_id]
|
109
124
|
end
|
110
125
|
end
|
111
|
-
|
126
|
+
group_id
|
112
127
|
end
|
113
128
|
|
114
129
|
##
|
@@ -31,10 +31,12 @@ module Kontena
|
|
31
31
|
|
32
32
|
opts[:vpc] = default_vpc.vpc_id unless opts[:vpc]
|
33
33
|
|
34
|
-
|
34
|
+
security_groups = opts[:security_groups] ?
|
35
|
+
resolve_security_groups_to_ids(opts[:security_groups], opts[:vpc]) :
|
36
|
+
ensure_security_group(opts[:grid], opts[:vpc])
|
37
|
+
|
35
38
|
name = opts[:name ] || generate_name
|
36
39
|
|
37
|
-
|
38
40
|
if opts[:subnet].nil?
|
39
41
|
subnet = default_subnet(opts[:vpc], region+opts[:zone])
|
40
42
|
else
|
@@ -54,9 +56,7 @@ module Kontena
|
|
54
56
|
min_count: 1,
|
55
57
|
max_count: 1,
|
56
58
|
instance_type: opts[:type],
|
57
|
-
security_group_ids: [security_group.group_id],
|
58
59
|
key_name: opts[:key_pair],
|
59
|
-
subnet_id: subnet.subnet_id,
|
60
60
|
user_data: Base64.encode64(user_data(userdata_vars)),
|
61
61
|
block_device_mappings: [
|
62
62
|
{
|
@@ -67,6 +67,15 @@ module Kontena
|
|
67
67
|
volume_type: 'gp2'
|
68
68
|
}
|
69
69
|
}
|
70
|
+
],
|
71
|
+
network_interfaces: [
|
72
|
+
{
|
73
|
+
device_index: 0,
|
74
|
+
subnet_id: subnet.subnet_id,
|
75
|
+
groups: security_groups,
|
76
|
+
associate_public_ip_address: opts[:associate_public_ip],
|
77
|
+
delete_on_termination: true
|
78
|
+
}
|
70
79
|
]
|
71
80
|
}).first
|
72
81
|
ec2_instance.create_tags({
|
@@ -83,27 +92,28 @@ module Kontena
|
|
83
92
|
ShellSpinner "Waiting for node #{name.colorize(:cyan)} join to grid #{opts[:grid].colorize(:cyan)} " do
|
84
93
|
sleep 2 until node = instance_exists_in_grid?(opts[:grid], name)
|
85
94
|
end
|
86
|
-
labels = [
|
95
|
+
labels = [
|
96
|
+
"region=#{region}",
|
97
|
+
"az=#{opts[:zone]}",
|
98
|
+
"provider=aws"
|
99
|
+
]
|
87
100
|
set_labels(node, labels)
|
88
101
|
end
|
89
102
|
|
90
103
|
##
|
91
104
|
# @param [String] grid
|
92
|
-
# @return [
|
105
|
+
# @return [Array] Security group id in array
|
93
106
|
def ensure_security_group(grid, vpc_id)
|
94
107
|
group_name = "kontena_grid_#{grid}"
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
{name: 'vpc-id', values: [vpc_id]}
|
99
|
-
]
|
100
|
-
}).first
|
101
|
-
unless sg
|
108
|
+
group_id = resolve_security_groups_to_ids(group_name, vpc_id)
|
109
|
+
|
110
|
+
if group_id.empty?
|
102
111
|
ShellSpinner "Creating AWS security group" do
|
103
112
|
sg = create_security_group(group_name, vpc_id)
|
113
|
+
group_id = [sg.group_id]
|
104
114
|
end
|
105
115
|
end
|
106
|
-
|
116
|
+
group_id
|
107
117
|
end
|
108
118
|
|
109
119
|
##
|
@@ -74,7 +74,8 @@ module Kontena
|
|
74
74
|
if node
|
75
75
|
labels = [
|
76
76
|
"region=#{cloud_service(cloud_service_name).location}",
|
77
|
-
"az=#{cloud_service(cloud_service_name).location}"
|
77
|
+
"az=#{cloud_service(cloud_service_name).location}",
|
78
|
+
"provider=azure"
|
78
79
|
]
|
79
80
|
set_labels(node, labels)
|
80
81
|
end
|
@@ -47,7 +47,14 @@ module Kontena
|
|
47
47
|
ShellSpinner "Waiting for node #{droplet.name.colorize(:cyan)} join to grid #{opts[:grid].colorize(:cyan)} " do
|
48
48
|
sleep 2 until node = droplet_exists_in_grid?(opts[:grid], droplet)
|
49
49
|
end
|
50
|
-
set_labels(
|
50
|
+
set_labels(
|
51
|
+
node,
|
52
|
+
[
|
53
|
+
"region=#{opts[:region]}",
|
54
|
+
"az=#{opts[:region]}",
|
55
|
+
"provider=digitalocean"
|
56
|
+
]
|
57
|
+
)
|
51
58
|
end
|
52
59
|
|
53
60
|
def user_data(vars)
|
@@ -35,6 +35,8 @@ module Kontena
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
abort_unless_api_access
|
39
|
+
|
38
40
|
abort('CoreOS template not found on Upcloud') unless coreos_template = find_template('CoreOS Stable')
|
39
41
|
abort('Server plan not found on Upcloud') unless plan = find_plan(opts[:plan])
|
40
42
|
abort('Zone not found on Upcloud') unless zone_exist?(opts[:zone])
|
@@ -34,6 +34,8 @@ module Kontena
|
|
34
34
|
grid_token: opts[:grid_token],
|
35
35
|
}
|
36
36
|
|
37
|
+
abort_unless_api_access
|
38
|
+
|
37
39
|
abort('CoreOS template not found on Upcloud') unless coreos_template = find_template('CoreOS Stable')
|
38
40
|
abort('Server plan not found on Upcloud') unless plan = find_plan(opts[:plan])
|
39
41
|
abort('Zone not found on Upcloud') unless zone_exist?(opts[:zone])
|
@@ -35,6 +35,19 @@ module Kontena
|
|
35
35
|
get("server/#{id}").fetch(:server, nil)
|
36
36
|
end
|
37
37
|
|
38
|
+
def api_access?
|
39
|
+
response = get('account')
|
40
|
+
response.kind_of?(Hash) && response.has_key?(:account)
|
41
|
+
rescue
|
42
|
+
false
|
43
|
+
end
|
44
|
+
|
45
|
+
def abort_unless_api_access
|
46
|
+
unless api_access?
|
47
|
+
abort('Upcloud API authentication failed. Check that API access is enabled for the user.')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
38
51
|
[:get, :post, :delete].each do |http_method|
|
39
52
|
define_method http_method do |path, opts={}|
|
40
53
|
response = client.send(
|
@@ -59,12 +72,3 @@ module Kontena
|
|
59
72
|
end
|
60
73
|
end
|
61
74
|
end
|
62
|
-
|
63
|
-
class Testing
|
64
|
-
include Kontena::Machine::Upcloud::UpcloudCommon
|
65
|
-
def initialize(user, pass)
|
66
|
-
@username = user
|
67
|
-
@password = pass
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative "../../../spec_helper"
|
2
|
+
require "kontena/cli/apps/build_command"
|
3
|
+
|
4
|
+
describe Kontena::Cli::Apps::BuildCommand do
|
5
|
+
include FixturesHelpers
|
6
|
+
|
7
|
+
let(:subject) do
|
8
|
+
described_class.new(File.basename($0))
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:kontena_yml) do
|
12
|
+
fixture('kontena.yml')
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:docker_compose_yml) do
|
16
|
+
fixture('docker-compose.yml')
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:settings) do
|
20
|
+
{'current_server' => 'alias',
|
21
|
+
'servers' => [
|
22
|
+
{
|
23
|
+
'name' => 'some_master',
|
24
|
+
'url' => 'some_master'
|
25
|
+
}
|
26
|
+
]
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#execute' do
|
31
|
+
before(:each) do
|
32
|
+
allow(subject).to receive(:settings).and_return(settings)
|
33
|
+
allow(subject).to receive(:current_dir).and_return("kontena-test")
|
34
|
+
allow(File).to receive(:exists?).and_return(true)
|
35
|
+
allow(File).to receive(:read).with("#{Dir.getwd}/kontena.yml").and_return(kontena_yml)
|
36
|
+
allow(File).to receive(:read).with("#{Dir.getwd}/docker-compose.yml").and_return(docker_compose_yml)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'requests process_docker_images with services from yaml' do
|
40
|
+
expect(subject).to receive(:process_docker_images) do |services, force_build, no_cache|
|
41
|
+
expect(services.keys).to eq(['wordpress', 'mysql'])
|
42
|
+
end
|
43
|
+
subject.run([])
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'requests process_docker_images with force_build' do
|
47
|
+
expect(subject).to receive(:process_docker_images).with(anything, true, anything)
|
48
|
+
subject.run([])
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'requests process_docker_images with given no_cache option' do
|
52
|
+
expect(subject).to receive(:process_docker_images).with(anything, anything, true)
|
53
|
+
subject.run(['--no-cache', true])
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require_relative "../../../spec_helper"
|
2
|
+
require "kontena/cli/apps/config_command"
|
3
|
+
require 'ruby_dig'
|
4
|
+
|
5
|
+
describe Kontena::Cli::Apps::ConfigCommand do
|
6
|
+
include FixturesHelpers
|
7
|
+
|
8
|
+
let(:subject) do
|
9
|
+
described_class.new(File.basename($0))
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:kontena_yml) do
|
13
|
+
fixture('mysql.yml')
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:yaml_with_app_name) do
|
17
|
+
{
|
18
|
+
'version' => '2',
|
19
|
+
'name' => 'myapp',
|
20
|
+
'services' => {
|
21
|
+
'mysql' => {
|
22
|
+
'image' => '$project-mysql:5.6'
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:settings) do
|
29
|
+
{'current_server' => 'alias',
|
30
|
+
'servers' => [
|
31
|
+
{
|
32
|
+
'name' => 'some_master',
|
33
|
+
'url' => 'some_master'
|
34
|
+
}
|
35
|
+
]
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#execute' do
|
40
|
+
before(:each) do
|
41
|
+
allow(subject).to receive(:settings).and_return(settings)
|
42
|
+
allow(subject).to receive(:current_dir).and_return("kontena-test")
|
43
|
+
allow(File).to receive(:exists?).and_return(true)
|
44
|
+
allow(File).to receive(:read).with("#{Dir.getwd}/kontena.yml").and_return(kontena_yml)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'outputs service configs' do
|
48
|
+
valid_output = {
|
49
|
+
'services' => {
|
50
|
+
'mysql' => {
|
51
|
+
'image' => 'mysql:5.6',
|
52
|
+
'stateful' => false
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
expect {
|
57
|
+
subject.run([])
|
58
|
+
}.to output(valid_output.to_yaml).to_stdout
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'uses app name from yaml as project variable' do
|
62
|
+
|
63
|
+
allow(File).to receive(:read).with("#{Dir.getwd}/kontena.yml").and_return(yaml_with_app_name.to_yaml)
|
64
|
+
valid_output = {
|
65
|
+
'services' => {
|
66
|
+
'mysql' => {
|
67
|
+
'image' => 'myapp-mysql:5.6',
|
68
|
+
'stateful' => false
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
expect {
|
73
|
+
subject.run([])
|
74
|
+
}.to output(valid_output.to_yaml).to_stdout
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative "../../../spec_helper"
|
2
|
+
require "kontena/cli/grid_options"
|
3
|
+
require "kontena/cli/services/update_command"
|
4
|
+
|
5
|
+
describe Kontena::Cli::Services::UpdateCommand do
|
6
|
+
|
7
|
+
include ClientHelpers
|
8
|
+
|
9
|
+
describe '#execute' do
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
allow(subject).to receive(:update_service).and_return({})
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'requires api url' do
|
16
|
+
expect(subject).to receive(:require_api_url).once
|
17
|
+
subject.run(['service'])
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'requires token' do
|
21
|
+
expect(subject).to receive(:require_token).once
|
22
|
+
subject.run(['service'])
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'sends update command' do
|
26
|
+
expect(subject).to receive(:update_service).with(token, 'service', {privileged: false})
|
27
|
+
subject.run(['service'])
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'sends --cap-add' do
|
31
|
+
expect(subject).to receive(:update_service).with(token, 'service', hash_including(cap_add: ['NET_ADMIN']))
|
32
|
+
subject.run(['--cap-add', 'NET_ADMIN', 'service'])
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'sends --cap-drop' do
|
36
|
+
expect(subject).to receive(:update_service).with(token, 'service', hash_including(cap_drop: ['MKNOD']))
|
37
|
+
subject.run(['--cap-drop', 'MKNOD', 'service'])
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'sends --log-driver' do
|
41
|
+
expect(subject).to receive(:update_service).with(token, 'service', hash_including(log_driver: 'syslog'))
|
42
|
+
subject.run(['--log-driver', 'syslog', 'service'])
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'sends --log-opt' do
|
46
|
+
expect(subject).to receive(:update_service).with(
|
47
|
+
token, 'service', hash_including(log_opts: {
|
48
|
+
'gelf-address' => 'udp://log_forwarder-logstash_internal:12201'
|
49
|
+
})
|
50
|
+
)
|
51
|
+
subject.run([
|
52
|
+
'--log-opt', 'gelf-address=udp://log_forwarder-logstash_internal:12201', 'service'
|
53
|
+
])
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
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: 0.14.
|
4
|
+
version: 0.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kontena, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -411,7 +411,9 @@ files:
|
|
411
411
|
- spec/fixtures/mysql.yml
|
412
412
|
- spec/fixtures/wordpress-scaled.yml
|
413
413
|
- spec/fixtures/wordpress.yml
|
414
|
+
- spec/kontena/cli/app/build_command_spec.rb
|
414
415
|
- spec/kontena/cli/app/common_spec.rb
|
416
|
+
- spec/kontena/cli/app/config_command_spec.rb
|
415
417
|
- spec/kontena/cli/app/deploy_command_spec.rb
|
416
418
|
- spec/kontena/cli/app/docker_helper_spec.rb
|
417
419
|
- spec/kontena/cli/app/scale_spec.rb
|
@@ -440,6 +442,7 @@ files:
|
|
440
442
|
- spec/kontena/cli/services/secrets/unlink_command_spec.rb
|
441
443
|
- spec/kontena/cli/services/services_helper_spec.rb
|
442
444
|
- spec/kontena/cli/services/unlink_command_spec.rb
|
445
|
+
- spec/kontena/cli/services/update_command_spec.rb
|
443
446
|
- spec/kontena/cli/version_command_spec.rb
|
444
447
|
- spec/spec_helper.rb
|
445
448
|
- spec/support/client_helpers.rb
|
@@ -479,7 +482,9 @@ test_files:
|
|
479
482
|
- spec/fixtures/mysql.yml
|
480
483
|
- spec/fixtures/wordpress-scaled.yml
|
481
484
|
- spec/fixtures/wordpress.yml
|
485
|
+
- spec/kontena/cli/app/build_command_spec.rb
|
482
486
|
- spec/kontena/cli/app/common_spec.rb
|
487
|
+
- spec/kontena/cli/app/config_command_spec.rb
|
483
488
|
- spec/kontena/cli/app/deploy_command_spec.rb
|
484
489
|
- spec/kontena/cli/app/docker_helper_spec.rb
|
485
490
|
- spec/kontena/cli/app/scale_spec.rb
|
@@ -508,6 +513,7 @@ test_files:
|
|
508
513
|
- spec/kontena/cli/services/secrets/unlink_command_spec.rb
|
509
514
|
- spec/kontena/cli/services/services_helper_spec.rb
|
510
515
|
- spec/kontena/cli/services/unlink_command_spec.rb
|
516
|
+
- spec/kontena/cli/services/update_command_spec.rb
|
511
517
|
- spec/kontena/cli/version_command_spec.rb
|
512
518
|
- spec/spec_helper.rb
|
513
519
|
- spec/support/client_helpers.rb
|