kontena-cli 0.11.3 → 0.11.4
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/app_command.rb +2 -0
- data/lib/kontena/cli/apps/deploy_command.rb +16 -1
- data/lib/kontena/cli/apps/restart_command.rb +39 -0
- data/lib/kontena/cli/services/deploy_command.rb +4 -1
- data/lib/kontena/cli/services/restart_command.rb +1 -1
- data/lib/kontena/cli/services/services_helper.rb +7 -0
- data/lib/kontena/cli/services/start_command.rb +1 -1
- data/lib/kontena/cli/services/stop_command.rb +1 -1
- data/lib/kontena/cli/vault/update_command.rb +20 -0
- data/lib/kontena/cli/vault_command.rb +3 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a146f1bd72f47a1f7805aaeb88ef87dda561a6d3
|
4
|
+
data.tar.gz: be7453435a084c1aedf71e571afabad1bf26b358
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8ef20d0fa01a285f9aba9868fd0ba46da56208e3e6965e3a59a3c583d69c7f3925188947a0a70494e24b32b7015cc6f1a42f62c6967a7042d0873c7c52da37c
|
7
|
+
data.tar.gz: 55a70a37241fbf825c0fe41b2d7198f74104884d6a8517c06dcc94789debdc0135bfb4db6a80ef836f6c9e0077a7ceacebcb1bba26c949674dd93956cc803eb2
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.11.
|
1
|
+
0.11.4
|
@@ -3,6 +3,7 @@ require_relative 'apps/build_command'
|
|
3
3
|
require_relative 'apps/deploy_command'
|
4
4
|
require_relative 'apps/start_command'
|
5
5
|
require_relative 'apps/stop_command'
|
6
|
+
require_relative 'apps/restart_command'
|
6
7
|
require_relative 'apps/remove_command'
|
7
8
|
require_relative 'apps/list_command'
|
8
9
|
require_relative 'apps/logs_command'
|
@@ -18,6 +19,7 @@ class Kontena::Cli::AppCommand < Clamp::Command
|
|
18
19
|
subcommand "scale", "Scale services", Kontena::Cli::Apps::ScaleCommand
|
19
20
|
subcommand "start", "Start services", Kontena::Cli::Apps::StartCommand
|
20
21
|
subcommand "stop", "Stop services", Kontena::Cli::Apps::StopCommand
|
22
|
+
subcommand "restart", "Restart services", Kontena::Cli::Apps::RestartCommand
|
21
23
|
subcommand "show", "Show service details", Kontena::Cli::Apps::ShowCommand
|
22
24
|
subcommand ["ps", "list"], "List services", Kontena::Cli::Apps::ListCommand
|
23
25
|
subcommand ["logs"], "Show service logs", Kontena::Cli::Apps::LogsCommand
|
@@ -12,6 +12,7 @@ module Kontena::Cli::Apps
|
|
12
12
|
option ['--no-build'], :flag, 'Don\'t build an image, even if it\'s missing', default: false
|
13
13
|
option ['-p', '--project-name'], 'NAME', 'Specify an alternate project name (default: directory name)'
|
14
14
|
option '--async', :flag, 'Run deploys async/parallel'
|
15
|
+
option '--force-deploy', :flag, 'Force deploy even if service does not have any changes'
|
15
16
|
|
16
17
|
parameter "[SERVICE] ...", "Services to start"
|
17
18
|
|
@@ -31,12 +32,14 @@ module Kontena::Cli::Apps
|
|
31
32
|
|
32
33
|
private
|
33
34
|
|
35
|
+
# @param [Hash] services
|
34
36
|
def create_or_update_services(services)
|
35
37
|
services.each do |name, config|
|
36
38
|
create_or_update_service(name, config)
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
42
|
+
# @param [Array] queue
|
40
43
|
def deploy_services(queue)
|
41
44
|
queue.each do |service|
|
42
45
|
name = service['id'].split('/').last
|
@@ -50,6 +53,8 @@ module Kontena::Cli::Apps
|
|
50
53
|
end
|
51
54
|
end
|
52
55
|
|
56
|
+
# @param [String] name
|
57
|
+
# @param [Hash] options
|
53
58
|
def create_or_update_service(name, options)
|
54
59
|
# skip if service is already processed or it's not present
|
55
60
|
return nil if in_deploy_queue?(name) || !services.keys.include?(name)
|
@@ -75,10 +80,13 @@ module Kontena::Cli::Apps
|
|
75
80
|
deploy_queue.push service
|
76
81
|
end
|
77
82
|
|
83
|
+
# @param [String] name
|
78
84
|
def find_service_by_name(name)
|
79
85
|
get_service(token, prefixed_name(name)) rescue nil
|
80
86
|
end
|
81
87
|
|
88
|
+
# @param [String] name
|
89
|
+
# @param [Hash] options
|
82
90
|
def create(name, options)
|
83
91
|
puts "creating #{name.colorize(:cyan)}"
|
84
92
|
name = prefixed_name(name)
|
@@ -87,17 +95,22 @@ module Kontena::Cli::Apps
|
|
87
95
|
create_service(token, current_grid, data)
|
88
96
|
end
|
89
97
|
|
98
|
+
# @param [String] id
|
99
|
+
# @param [Hash] options
|
90
100
|
def update(id, options)
|
91
101
|
puts "updating #{id.colorize(:cyan)}"
|
92
102
|
id = prefixed_name(id)
|
93
103
|
data = parse_data(options)
|
94
104
|
update_service(token, id, data)
|
105
|
+
deploy_service(token, id, {force: true}) if force_deploy?
|
95
106
|
end
|
96
107
|
|
108
|
+
# @param [String] name
|
97
109
|
def in_deploy_queue?(name)
|
98
110
|
deploy_queue.find {|service| service['name'] == prefixed_name(name)} != nil
|
99
111
|
end
|
100
112
|
|
113
|
+
# @param [Hash] options
|
101
114
|
def merge_env_vars(options)
|
102
115
|
return unless options['env_file']
|
103
116
|
|
@@ -111,6 +124,7 @@ module Kontena::Cli::Apps
|
|
111
124
|
options['environment'].uniq! {|s| s.split('=').first}
|
112
125
|
end
|
113
126
|
|
127
|
+
# @param [Hash] options
|
114
128
|
def merge_external_links(options)
|
115
129
|
if options['external_links']
|
116
130
|
options['links'] ||= []
|
@@ -119,6 +133,7 @@ module Kontena::Cli::Apps
|
|
119
133
|
end
|
120
134
|
end
|
121
135
|
|
136
|
+
# @param [String] path
|
122
137
|
def read_env_file(path)
|
123
138
|
File.readlines(path).delete_if { |line| line.start_with?('#') || line.empty? }
|
124
139
|
end
|
@@ -145,6 +160,7 @@ module Kontena::Cli::Apps
|
|
145
160
|
data[:cap_add] = options['cap_add'] if options['cap_add']
|
146
161
|
data[:cap_drop] = options['cap_drop'] if options['cap_drop']
|
147
162
|
data[:net] = options['net'] if options['net']
|
163
|
+
data[:pid] = options['pid'] if options['pid']
|
148
164
|
data[:log_driver] = options['log_driver'] if options['log_driver']
|
149
165
|
data[:log_opts] = options['log_opt'] if options['log_opt'] && !options['log_opt'].empty?
|
150
166
|
|
@@ -162,6 +178,5 @@ module Kontena::Cli::Apps
|
|
162
178
|
|
163
179
|
data
|
164
180
|
end
|
165
|
-
|
166
181
|
end
|
167
182
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative 'common'
|
2
|
+
|
3
|
+
module Kontena::Cli::Apps
|
4
|
+
class RestartCommand < Clamp::Command
|
5
|
+
include Kontena::Cli::Common
|
6
|
+
include Common
|
7
|
+
|
8
|
+
option ['-f', '--file'], 'FILE', 'Specify an alternate Kontena compose file', attribute_name: :filename, default: 'kontena.yml'
|
9
|
+
option ['-p', '--project-name'], 'NAME', 'Specify an alternate project name (default: directory name)'
|
10
|
+
|
11
|
+
parameter "[SERVICE] ...", "Services to start"
|
12
|
+
|
13
|
+
attr_reader :services, :service_prefix
|
14
|
+
|
15
|
+
def execute
|
16
|
+
require_config_file(filename)
|
17
|
+
|
18
|
+
@service_prefix = project_name || current_dir
|
19
|
+
@services = load_services(filename, service_list, service_prefix)
|
20
|
+
if services.size > 0
|
21
|
+
restart_services(services)
|
22
|
+
elsif !service_list.empty?
|
23
|
+
puts "No such service: #{service_list.join(', ')}".colorize(:red)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
def restart_services(services)
|
29
|
+
services.each do |service_name, opts|
|
30
|
+
if service_exists?(service_name)
|
31
|
+
puts "restarting #{prefixed_name(service_name)}"
|
32
|
+
restart_service(token, prefixed_name(service_name))
|
33
|
+
else
|
34
|
+
puts "No such service: #{service_name}".colorize(:red)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -6,12 +6,15 @@ module Kontena::Cli::Services
|
|
6
6
|
include ServicesHelper
|
7
7
|
|
8
8
|
parameter "NAME", "Service name"
|
9
|
+
option '--force-deploy', :flag, 'Force deploy even if service does not have any changes'
|
9
10
|
|
10
11
|
def execute
|
11
12
|
require_api_url
|
12
13
|
token = require_token
|
13
14
|
service_id = name
|
14
|
-
|
15
|
+
data = {}
|
16
|
+
data[:force] = true if force_deploy?
|
17
|
+
deploy_service(token, service_id, data)
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
@@ -209,6 +209,13 @@ module Kontena
|
|
209
209
|
client(token).post("services/#{param}/stop", {})
|
210
210
|
end
|
211
211
|
|
212
|
+
# @param [String] token
|
213
|
+
# @param [String] service_id
|
214
|
+
def restart_service(token, service_id)
|
215
|
+
param = parse_service_id(service_id)
|
216
|
+
client(token).post("services/#{param}/restart", {})
|
217
|
+
end
|
218
|
+
|
212
219
|
# @param [String] token
|
213
220
|
# @param [String] service_id
|
214
221
|
def delete_service(token, service_id)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Kontena::Cli::Vault
|
2
|
+
class UpdateCommand < Clamp::Command
|
3
|
+
include Kontena::Cli::Common
|
4
|
+
|
5
|
+
parameter 'NAME', 'Secret name'
|
6
|
+
parameter '[VALUE]', 'Secret value'
|
7
|
+
|
8
|
+
def execute
|
9
|
+
require_api_url
|
10
|
+
token = require_token
|
11
|
+
secret = value
|
12
|
+
if secret.to_s == ''
|
13
|
+
secret = STDIN.read
|
14
|
+
end
|
15
|
+
abort('No value provided') if secret.to_s == ''
|
16
|
+
data = {value: secret}
|
17
|
+
client(token).put("grids/#{current_grid}/secrets/#{name}", data)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -2,12 +2,14 @@ require_relative 'vault/write_command'
|
|
2
2
|
require_relative 'vault/list_command'
|
3
3
|
require_relative 'vault/read_command'
|
4
4
|
require_relative 'vault/remove_command'
|
5
|
+
require_relative 'vault/update_command'
|
5
6
|
|
6
7
|
class Kontena::Cli::VaultCommand < Clamp::Command
|
7
8
|
|
8
|
-
subcommand "write", "Write a secret", Kontena::Cli::Vault::WriteCommand
|
9
9
|
subcommand ["list", "ls"], "List secrets", Kontena::Cli::Vault::ListCommand
|
10
|
+
subcommand "write", "Write a secret", Kontena::Cli::Vault::WriteCommand
|
10
11
|
subcommand "read", "Read secret", Kontena::Cli::Vault::ReadCommand
|
12
|
+
subcommand "update", "Update secret", Kontena::Cli::Vault::UpdateCommand
|
11
13
|
subcommand ["remove", "rm"], "Remove secret", Kontena::Cli::Vault::RemoveCommand
|
12
14
|
|
13
15
|
def execute
|
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.11.
|
4
|
+
version: 0.11.4
|
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-02-
|
11
|
+
date: 2016-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- lib/kontena/cli/apps/logs_command.rb
|
140
140
|
- lib/kontena/cli/apps/monitor_command.rb
|
141
141
|
- lib/kontena/cli/apps/remove_command.rb
|
142
|
+
- lib/kontena/cli/apps/restart_command.rb
|
142
143
|
- lib/kontena/cli/apps/scale_command.rb
|
143
144
|
- lib/kontena/cli/apps/show_command.rb
|
144
145
|
- lib/kontena/cli/apps/start_command.rb
|
@@ -246,6 +247,7 @@ files:
|
|
246
247
|
- lib/kontena/cli/vault/list_command.rb
|
247
248
|
- lib/kontena/cli/vault/read_command.rb
|
248
249
|
- lib/kontena/cli/vault/remove_command.rb
|
250
|
+
- lib/kontena/cli/vault/update_command.rb
|
249
251
|
- lib/kontena/cli/vault/write_command.rb
|
250
252
|
- lib/kontena/cli/vault_command.rb
|
251
253
|
- lib/kontena/cli/verify_account_command.rb
|