kontena-cli 0.15.0 → 0.15.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/kontena-cli.gemspec +1 -0
- data/lib/kontena/cli/apps/yaml/reader.rb +8 -8
- data/lib/kontena/cli/apps/yaml/service_extender.rb +3 -13
- data/lib/kontena/cli/certificate/get_command.rb +1 -0
- data/lib/kontena/util.rb +15 -3
- data/spec/kontena/cli/app/yaml/reader_spec.rb +62 -0
- data/spec/kontena/client_spec.rb +1 -13
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d82df3e1f060653421ebc2ba56833b28881e6d6e
|
4
|
+
data.tar.gz: 867c7924eb2a780599392f21fdbc5e6d8e30961d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 788d94e130ecad93547fb194564039d70a8b4686f2c8029649beea8f5e0d52c8ce42eba53aab463de49e5f11647c92f0b9d33659cd0339f7338c9892043d6cba
|
7
|
+
data.tar.gz: 2ce7bd1b2bc78591a7405ba7d09d6c4f192a290a15ed6c2f79e4cfdecc12ae69f1b224cca96ae842a2265c7626b68f66842d9c4d908ff85080409a81db386e82
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.15.
|
1
|
+
0.15.1
|
data/kontena-cli.gemspec
CHANGED
@@ -2,10 +2,12 @@ require 'yaml'
|
|
2
2
|
require_relative 'service_extender'
|
3
3
|
require_relative 'validator'
|
4
4
|
require_relative 'validator_v2'
|
5
|
+
require_relative '../../../util'
|
5
6
|
|
6
7
|
module Kontena::Cli::Apps
|
7
8
|
module YAML
|
8
9
|
class Reader
|
10
|
+
include Kontena::Util
|
9
11
|
attr_reader :yaml, :file, :errors, :notifications
|
10
12
|
|
11
13
|
def initialize(file, skip_validation = false)
|
@@ -177,14 +179,12 @@ module Kontena::Cli::Apps
|
|
177
179
|
|
178
180
|
# @param [Hash] options - service config
|
179
181
|
def normalize_build_args(options)
|
180
|
-
if v2? && options
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
options['build']['args'][k] = v
|
187
|
-
end
|
182
|
+
if v2? && safe_dig(options, 'build', 'args').is_a?(Array)
|
183
|
+
args = options['build']['args'].dup
|
184
|
+
options['build']['args'] = {}
|
185
|
+
args.each do |arg|
|
186
|
+
k,v = arg.split('=')
|
187
|
+
options['build']['args'][k] = v
|
188
188
|
end
|
189
189
|
end
|
190
190
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require_relative '../../../util'
|
2
3
|
|
3
4
|
module Kontena::Cli::Apps
|
4
5
|
module YAML
|
5
6
|
class ServiceExtender
|
7
|
+
include Kontena::Util
|
6
8
|
attr_reader :service_config
|
7
9
|
|
8
10
|
# @param [Hash] service_config
|
@@ -26,24 +28,12 @@ module Kontena::Cli::Apps
|
|
26
28
|
service_config['build'] = {} unless service_config['build']
|
27
29
|
service_config['build']['args'] = build_args
|
28
30
|
end
|
29
|
-
|
31
|
+
|
30
32
|
from.merge(service_config)
|
31
33
|
end
|
32
34
|
|
33
35
|
private
|
34
36
|
|
35
|
-
# Compatibility between ruby_dig and Ruby 2.3. Ruby_dig returns
|
36
|
-
# nil when trying to dig into a string, Ruby 2.3 dig raises
|
37
|
-
# TypeError.
|
38
|
-
#
|
39
|
-
# @param [Hash] source_hash
|
40
|
-
# @param [*keys] list_of_keys
|
41
|
-
def safe_dig(hash, *keys)
|
42
|
-
hash.dig(*keys)
|
43
|
-
rescue TypeError
|
44
|
-
nil
|
45
|
-
end
|
46
|
-
|
47
37
|
# @param [Array] from
|
48
38
|
# @param [Array] to
|
49
39
|
# @return [Array]
|
@@ -6,6 +6,7 @@ module Kontena::Cli::Certificate
|
|
6
6
|
|
7
7
|
|
8
8
|
option '--secret-name', 'SECRET_NAME', 'The name for the secret to store the certificate in'
|
9
|
+
option '--cert-type', 'CERT_TYPE', 'The type of certificate to get: fullchain, chain or cert', default: 'fullchain'
|
9
10
|
parameter "DOMAIN ...", "Domain(s) to get certificate for"
|
10
11
|
|
11
12
|
|
data/lib/kontena/util.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Kontena
|
2
2
|
module Util
|
3
|
-
|
4
3
|
def self.included(base)
|
5
4
|
base.extend(ClassMethods)
|
6
5
|
end
|
@@ -16,13 +15,26 @@ module Kontena
|
|
16
15
|
end
|
17
16
|
return nil
|
18
17
|
end
|
18
|
+
|
19
|
+
# Compatibility between ruby_dig and Ruby 2.3. Ruby_dig returns
|
20
|
+
# nil when trying to dig into a string, Ruby 2.3 dig raises
|
21
|
+
# TypeError.
|
22
|
+
#
|
23
|
+
# @param [Hash] source_hash
|
24
|
+
# @param [*keys] list_of_keys
|
25
|
+
def safe_dig(hash, *keys)
|
26
|
+
hash.dig(*keys)
|
27
|
+
rescue TypeError
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
|
19
31
|
module_function(:which)
|
20
32
|
|
21
33
|
module ClassMethods
|
22
34
|
def experimental?
|
23
35
|
ENV.has_key?('KONTENA_EXPERIMENTAL')
|
24
|
-
end
|
36
|
+
end
|
25
37
|
end
|
26
|
-
|
38
|
+
|
27
39
|
end
|
28
40
|
end
|
@@ -330,4 +330,66 @@ describe Kontena::Cli::Apps::YAML::Reader do
|
|
330
330
|
expect(outcome[:services]['webapp']['build']['context']).to eq(File.expand_path('.'))
|
331
331
|
end
|
332
332
|
end
|
333
|
+
|
334
|
+
context 'normalize_build_args' do
|
335
|
+
context 'when build option is string' do
|
336
|
+
it 'skips normalizing' do
|
337
|
+
allow(File).to receive(:read)
|
338
|
+
.with(absolute_yaml_path('kontena.yml'))
|
339
|
+
.and_return(fixture('kontena_build_v2.yml'))
|
340
|
+
allow(subject).to receive(:v2?).and_return(true)
|
341
|
+
|
342
|
+
options = {
|
343
|
+
'build' => '.'
|
344
|
+
}
|
345
|
+
expect {
|
346
|
+
subject.send(:normalize_build_args, options)
|
347
|
+
}.not_to raise_error
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
context 'when build arguments option is Hash' do
|
352
|
+
it 'does not do anything' do
|
353
|
+
allow(File).to receive(:read)
|
354
|
+
.with(absolute_yaml_path('kontena.yml'))
|
355
|
+
.and_return(fixture('kontena_build_v2.yml'))
|
356
|
+
allow(subject).to receive(:v2?).and_return(true)
|
357
|
+
|
358
|
+
options = {
|
359
|
+
'build' => {
|
360
|
+
'context' => '.',
|
361
|
+
'args' => {
|
362
|
+
'foo' => 'bar'
|
363
|
+
}
|
364
|
+
}
|
365
|
+
}
|
366
|
+
|
367
|
+
subject.send(:normalize_build_args, options)
|
368
|
+
expect(options.dig('build', 'args')).to eq({
|
369
|
+
'foo' => 'bar'
|
370
|
+
})
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
context 'when build arguments option is Array' do
|
375
|
+
it 'converts it to array' do
|
376
|
+
allow(File).to receive(:read)
|
377
|
+
.with(absolute_yaml_path('kontena.yml'))
|
378
|
+
.and_return(fixture('kontena_build_v2.yml'))
|
379
|
+
allow(subject).to receive(:v2?).and_return(true)
|
380
|
+
|
381
|
+
options = {
|
382
|
+
'build' => {
|
383
|
+
'context' => '.',
|
384
|
+
'args' => ['foo=bar']
|
385
|
+
}
|
386
|
+
}
|
387
|
+
|
388
|
+
subject.send(:normalize_build_args, options)
|
389
|
+
expect(options.dig('build', 'args')).to eq({
|
390
|
+
'foo' => 'bar'
|
391
|
+
})
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
333
395
|
end
|
data/spec/kontena/client_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe Kontena::Client do
|
|
7
7
|
let(:http_client) { double(:http_client) }
|
8
8
|
|
9
9
|
before(:each) do
|
10
|
-
allow(subject).to receive(:http_client)
|
10
|
+
allow(subject).to receive(:http_client).and_return(http_client)
|
11
11
|
end
|
12
12
|
|
13
13
|
describe '#get' do
|
@@ -40,7 +40,6 @@ describe Kontena::Client do
|
|
40
40
|
let(:response_block) { Proc.new{ } }
|
41
41
|
|
42
42
|
it 'passes path & response_block to client' do
|
43
|
-
allow(subject).to receive(:http_client).and_return(http_client)
|
44
43
|
expect(http_client).to receive(:get).with(
|
45
44
|
hash_including(path: '/v1/foo', response_block: response_block)
|
46
45
|
).and_return(spy(:response, status: 200))
|
@@ -48,7 +47,6 @@ describe Kontena::Client do
|
|
48
47
|
end
|
49
48
|
|
50
49
|
it 'passes params to client' do
|
51
|
-
allow(subject).to receive(:http_client).and_return(http_client)
|
52
50
|
expect(http_client).to receive(:get).with(
|
53
51
|
hash_including(query: {bar: 'baz'})
|
54
52
|
).and_return(spy(:response, status: 200))
|
@@ -56,7 +54,6 @@ describe Kontena::Client do
|
|
56
54
|
end
|
57
55
|
|
58
56
|
it 'passes params to client' do
|
59
|
-
allow(subject).to receive(:http_client).and_return(http_client)
|
60
57
|
expect(http_client).to receive(:get).with(
|
61
58
|
hash_including(headers: hash_including(:'Some-Header' => 'value'))
|
62
59
|
).and_return(spy(:response, status: 200))
|
@@ -70,7 +67,6 @@ describe Kontena::Client do
|
|
70
67
|
end
|
71
68
|
|
72
69
|
it 'passes path and object to client' do
|
73
|
-
allow(subject).to receive(:http_client).and_return(http_client)
|
74
70
|
expect(http_client).to receive(:post).with(
|
75
71
|
hash_including(path: '/v1/foo', body: kind_of(String))
|
76
72
|
).and_return(spy(:response, status: 200))
|
@@ -78,7 +74,6 @@ describe Kontena::Client do
|
|
78
74
|
end
|
79
75
|
|
80
76
|
it 'passes params to client' do
|
81
|
-
allow(subject).to receive(:http_client).and_return(http_client)
|
82
77
|
expect(http_client).to receive(:post).with(
|
83
78
|
hash_including(query: {bar: 'baz'})
|
84
79
|
).and_return(spy(:response, status: 200))
|
@@ -86,7 +81,6 @@ describe Kontena::Client do
|
|
86
81
|
end
|
87
82
|
|
88
83
|
it 'passes params to client' do
|
89
|
-
allow(subject).to receive(:http_client).and_return(http_client)
|
90
84
|
expect(http_client).to receive(:post).with(
|
91
85
|
hash_including(headers: hash_including(:'Some-Header' => 'value'))
|
92
86
|
).and_return(spy(:response, status: 200))
|
@@ -100,7 +94,6 @@ describe Kontena::Client do
|
|
100
94
|
end
|
101
95
|
|
102
96
|
it 'passes path and object to client' do
|
103
|
-
allow(subject).to receive(:http_client).and_return(http_client)
|
104
97
|
expect(http_client).to receive(:put).with(
|
105
98
|
hash_including(path: '/v1/foo', body: kind_of(String))
|
106
99
|
).and_return(spy(:response, status: 200))
|
@@ -108,7 +101,6 @@ describe Kontena::Client do
|
|
108
101
|
end
|
109
102
|
|
110
103
|
it 'passes params to client' do
|
111
|
-
allow(subject).to receive(:http_client).and_return(http_client)
|
112
104
|
expect(http_client).to receive(:put).with(
|
113
105
|
hash_including(query: {bar: 'baz'})
|
114
106
|
).and_return(spy(:response, status: 200))
|
@@ -116,7 +108,6 @@ describe Kontena::Client do
|
|
116
108
|
end
|
117
109
|
|
118
110
|
it 'passes params to client' do
|
119
|
-
allow(subject).to receive(:http_client).and_return(http_client)
|
120
111
|
expect(http_client).to receive(:put).with(
|
121
112
|
hash_including(headers: hash_including(:'Some-Header' => 'value'))
|
122
113
|
).and_return(spy(:response, status: 200))
|
@@ -130,7 +121,6 @@ describe Kontena::Client do
|
|
130
121
|
end
|
131
122
|
|
132
123
|
it 'passes path to client' do
|
133
|
-
allow(subject).to receive(:http_client).and_return(http_client)
|
134
124
|
expect(http_client).to receive(:delete).with(
|
135
125
|
hash_including(path: '/v1/foo')
|
136
126
|
).and_return(spy(:response, status: 200))
|
@@ -138,7 +128,6 @@ describe Kontena::Client do
|
|
138
128
|
end
|
139
129
|
|
140
130
|
it 'passes params to client' do
|
141
|
-
allow(subject).to receive(:http_client).and_return(http_client)
|
142
131
|
expect(http_client).to receive(:delete).with(
|
143
132
|
hash_including(query: {bar: 'baz'})
|
144
133
|
).and_return(spy(:response, status: 200))
|
@@ -146,7 +135,6 @@ describe Kontena::Client do
|
|
146
135
|
end
|
147
136
|
|
148
137
|
it 'passes params to client' do
|
149
|
-
allow(subject).to receive(:http_client).and_return(http_client)
|
150
138
|
expect(http_client).to receive(:delete).with(
|
151
139
|
hash_including(headers: hash_including(:'Some-Header' => 'value'))
|
152
140
|
).and_return(spy(:response, status: 200))
|
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.15.
|
4
|
+
version: 0.15.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-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 0.8.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: dry-configurable
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.1.6
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.1.6
|
139
153
|
description: Kontena command line tool
|
140
154
|
email:
|
141
155
|
- info@kontena.io
|