kontena-cli 1.0.6 → 1.1.0.pre1
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/Dockerfile +1 -1
- data/VERSION +1 -1
- data/bin/kontena +4 -1
- data/kontena-cli.gemspec +1 -1
- data/lib/kontena/callback.rb +1 -1
- data/lib/kontena/callbacks/master/01_clear_current_master_after_terminate.rb +1 -1
- data/lib/kontena/callbacks/master/deploy/50_authenticate_after_deploy.rb +5 -5
- data/lib/kontena/callbacks/master/deploy/55_create_initial_grid_after_deploy.rb +1 -1
- data/lib/kontena/callbacks/master/deploy/56_set_server_provider_after_deploy.rb +25 -0
- data/lib/kontena/callbacks/master/deploy/70_invite_self_after_deploy.rb +1 -1
- data/lib/kontena/cli/common.rb +3 -3
- data/lib/kontena/cli/config.rb +1 -1
- data/lib/kontena/cli/grid_command.rb +2 -0
- data/lib/kontena/cli/grids/common.rb +12 -0
- data/lib/kontena/cli/grids/health_command.rb +69 -0
- data/lib/kontena/cli/helpers/health_helper.rb +53 -0
- data/lib/kontena/cli/localhost_web_server.rb +3 -3
- data/lib/kontena/cli/master/users/invite_command.rb +1 -1
- data/lib/kontena/cli/node_command.rb +2 -0
- data/lib/kontena/cli/nodes/health_command.rb +32 -0
- data/lib/kontena/cli/nodes/list_command.rb +40 -26
- data/lib/kontena/cli/nodes/show_command.rb +0 -1
- data/lib/kontena/cli/plugins/install_command.rb +28 -30
- data/lib/kontena/cli/plugins/search_command.rb +6 -14
- data/lib/kontena/cli/plugins/uninstall_command.rb +7 -11
- data/lib/kontena/cli/services/stats_command.rb +4 -2
- data/lib/kontena/cli/spinner.rb +20 -4
- data/lib/kontena/cli/stacks/show_command.rb +5 -1
- data/lib/kontena/cli/stacks/yaml/opto/service_instances_resolver.rb +22 -0
- data/lib/kontena/cli/stacks/yaml/opto/vault_setter.rb +1 -1
- data/lib/kontena/cli/stacks/yaml/reader.rb +1 -0
- data/lib/kontena/cli/vault/export_command.rb +22 -0
- data/lib/kontena/cli/vault/import_command.rb +80 -0
- data/lib/kontena/cli/vault/list_command.rb +4 -0
- data/lib/kontena/cli/vault/read_command.rb +8 -3
- data/lib/kontena/cli/vault/remove_command.rb +2 -1
- data/lib/kontena/cli/vault/update_command.rb +5 -7
- data/lib/kontena/cli/vault_command.rb +5 -1
- data/lib/kontena/client.rb +25 -2
- data/lib/kontena/command.rb +1 -1
- data/lib/kontena/debug_instrumentor.rb +70 -0
- data/lib/kontena/light_prompt.rb +103 -0
- data/lib/kontena/plugin_manager.rb +167 -6
- data/lib/kontena/stacks_cache.rb +1 -1
- data/lib/kontena_cli.rb +23 -6
- data/spec/kontena/cli/grids/health_command_spec.rb +390 -0
- data/spec/kontena/cli/nodes/health_command_spec.rb +206 -0
- data/spec/kontena/cli/nodes/list_command_spec.rb +205 -0
- data/spec/kontena/cli/vault/export_spec.rb +32 -0
- data/spec/kontena/cli/vault/import_spec.rb +69 -0
- data/spec/kontena/client_spec.rb +39 -0
- data/spec/kontena/plugin_manager_spec.rb +7 -7
- data/spec/spec_helper.rb +1 -0
- data/spec/support/output_helpers.rb +51 -0
- metadata +27 -6
data/spec/kontena/client_spec.rb
CHANGED
@@ -294,5 +294,44 @@ describe Kontena::Client do
|
|
294
294
|
expect{subject.get('test')}.to raise_error(Kontena::Errors::StandardError, "You are wrong")
|
295
295
|
end
|
296
296
|
end
|
297
|
+
|
298
|
+
context 'version warning' do
|
299
|
+
let(:client) { double(:client) }
|
300
|
+
let(:response) { double(:response) }
|
301
|
+
let(:cli_version) { Kontena::Cli::VERSION }
|
302
|
+
|
303
|
+
before(:each) do
|
304
|
+
allow(subject).to receive(:http_client).and_return(client)
|
305
|
+
allow(client).to receive(:request).and_return(response)
|
306
|
+
allow(response).to receive(:body).and_return("hello")
|
307
|
+
allow(response).to receive(:headers).and_return({})
|
308
|
+
end
|
309
|
+
|
310
|
+
it 'warns the user once if server version differs enough from master version' do
|
311
|
+
bumped_version = cli_version.split('.')[0] + '.' + (cli_version.split('.')[1].to_i + 1).to_s + '.0' # 1.5.4 --> 1.6.0
|
312
|
+
expect(response).to receive(:headers).at_least(:once).and_return({'X-Kontena-Version' => bumped_version})
|
313
|
+
expect(subject).to receive(:check_version_and_warn).at_least(:once).and_call_original
|
314
|
+
expect(subject).to receive(:add_version_warning).with(bumped_version).once.and_return(true)
|
315
|
+
expect(subject.get("test")).to eq 'hello'
|
316
|
+
expect(subject.get("test")).to eq 'hello'
|
317
|
+
end
|
318
|
+
|
319
|
+
it 'does not warn the user if server version does not differ too much' do
|
320
|
+
bumped_version = cli_version.split('.')[0] + '.' + cli_version.split('.')[1] + '.' + (cli_version.split('.')[2].to_i + 1).to_s # 1.5.4 --> 1.5.5
|
321
|
+
expect(response).to receive(:headers).at_least(:once).and_return({'X-Kontena-Version' => bumped_version})
|
322
|
+
expect(subject).to receive(:check_version_and_warn).at_least(:once).and_call_original
|
323
|
+
expect(subject).not_to receive(:at_exit)
|
324
|
+
expect(subject).not_to receive(:add_version_warning)
|
325
|
+
expect(subject.get("test")).to eq 'hello'
|
326
|
+
end
|
327
|
+
|
328
|
+
it 'does not warn the user if server version is not there at all' do
|
329
|
+
expect(response).to receive(:headers).at_least(:once).and_return({})
|
330
|
+
allow(subject).to receive(:check_version_and_warn).at_least(:once).and_call_original
|
331
|
+
expect(subject).not_to receive(:at_exit)
|
332
|
+
expect(subject).not_to receive(:add_version_warning)
|
333
|
+
expect(subject.get("test")).to eq 'hello'
|
334
|
+
end
|
335
|
+
end
|
297
336
|
end
|
298
337
|
end
|
@@ -5,14 +5,14 @@ describe Kontena::PluginManager do
|
|
5
5
|
|
6
6
|
let(:subject) { described_class.instance }
|
7
7
|
|
8
|
+
before(:each) { subject.init }
|
8
9
|
describe '#load_plugins' do
|
9
10
|
it 'includes hello plugin' do
|
10
|
-
plugins
|
11
|
-
expect(plugins.any?{ |p| p.name == 'kontena-plugin-hello' }).to be_truthy
|
11
|
+
expect(subject.plugins.any?{ |p| p.name == 'kontena-plugin-hello' }).to be_truthy
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'allows plugin to register as a sub-command' do
|
15
|
-
plugins = subject.
|
15
|
+
plugins = subject.init
|
16
16
|
main = Kontena::MainCommand.new(File.basename($0))
|
17
17
|
expect {
|
18
18
|
main.run(['hello'])
|
@@ -31,7 +31,7 @@ describe Kontena::PluginManager do
|
|
31
31
|
s.version = '0.1.0'
|
32
32
|
s.add_runtime_dependency 'kontena-cli', '>= 0.16.0'
|
33
33
|
end
|
34
|
-
expect(subject.spec_has_valid_dependency
|
34
|
+
expect(subject.send(:spec_has_valid_dependency?, spec)).to be_truthy
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'returns true if spec dependency > than MIN_CLI_VERSION and is prerelease' do
|
@@ -40,7 +40,7 @@ describe Kontena::PluginManager do
|
|
40
40
|
s.version = '0.1.0'
|
41
41
|
s.add_runtime_dependency 'kontena-cli', '>= 0.16.0.pre2'
|
42
42
|
end
|
43
|
-
expect(subject.spec_has_valid_dependency
|
43
|
+
expect(subject.send(:spec_has_valid_dependency?, spec)).to be_truthy
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'returns false if spec dependency < than MIN_CLI_VERSION' do
|
@@ -49,7 +49,7 @@ describe Kontena::PluginManager do
|
|
49
49
|
s.version = '0.1.0'
|
50
50
|
s.add_runtime_dependency 'kontena-cli', '>= 0.15.0'
|
51
51
|
end
|
52
|
-
expect(subject.spec_has_valid_dependency
|
52
|
+
expect(subject.send(:spec_has_valid_dependency?, spec)).to be_falsey
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'returns false if spec dependency < than MIN_CLI_VERSION and is prerelease' do
|
@@ -58,7 +58,7 @@ describe Kontena::PluginManager do
|
|
58
58
|
s.version = '0.1.0'
|
59
59
|
s.add_runtime_dependency 'kontena-cli', '>= 0.15.0.beta1'
|
60
60
|
end
|
61
|
-
expect(subject.spec_has_valid_dependency
|
61
|
+
expect(subject.send(:spec_has_valid_dependency?, spec)).to be_falsey
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
module OutputHelpers
|
2
|
+
extend RSpec::Matchers::DSL
|
3
|
+
|
4
|
+
matcher :return_and_output do |expected, *lines|
|
5
|
+
supports_block_expectations
|
6
|
+
|
7
|
+
match do |block|
|
8
|
+
stdout = lines.flatten.join("\n") + "\n"
|
9
|
+
|
10
|
+
begin
|
11
|
+
expect{@return = block.call}.to output(stdout).to_stdout
|
12
|
+
rescue Exception => error
|
13
|
+
@error = error
|
14
|
+
|
15
|
+
return false
|
16
|
+
else
|
17
|
+
return values_match? expected, @return
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
failure_message do |block|
|
22
|
+
if @error
|
23
|
+
return @error
|
24
|
+
else
|
25
|
+
return "expected #{block} to return #{expected}, but returned #{@return}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
matcher :output_table do |lines|
|
31
|
+
supports_block_expectations
|
32
|
+
|
33
|
+
match do |block|
|
34
|
+
stdout = Regexp.new('^' + lines.map{|fields| fields.join('\s+')}.join('\n') + '\n$', Regexp::MULTILINE)
|
35
|
+
|
36
|
+
begin
|
37
|
+
expect{@return = block.call}.to output(stdout).to_stdout
|
38
|
+
rescue Exception => error
|
39
|
+
@error = error
|
40
|
+
|
41
|
+
return false
|
42
|
+
else
|
43
|
+
return true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
failure_message do |block|
|
48
|
+
return @error
|
49
|
+
end
|
50
|
+
end
|
51
|
+
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: 1.0.
|
4
|
+
version: 1.1.0.pre1
|
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-01-
|
11
|
+
date: 2017-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: '0.10'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: '0.10'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: clamp
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -218,6 +218,7 @@ files:
|
|
218
218
|
- lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
|
219
219
|
- lib/kontena/callbacks/master/deploy/50_authenticate_after_deploy.rb
|
220
220
|
- lib/kontena/callbacks/master/deploy/55_create_initial_grid_after_deploy.rb
|
221
|
+
- lib/kontena/callbacks/master/deploy/56_set_server_provider_after_deploy.rb
|
221
222
|
- lib/kontena/callbacks/master/deploy/60_configure_auth_provider_after_deploy.rb
|
222
223
|
- lib/kontena/callbacks/master/deploy/70_invite_self_after_deploy.rb
|
223
224
|
- lib/kontena/callbacks/master/deploy/90_proptip_after_deploy.rb
|
@@ -293,6 +294,7 @@ files:
|
|
293
294
|
- lib/kontena/cli/grids/create_command.rb
|
294
295
|
- lib/kontena/cli/grids/current_command.rb
|
295
296
|
- lib/kontena/cli/grids/env_command.rb
|
297
|
+
- lib/kontena/cli/grids/health_command.rb
|
296
298
|
- lib/kontena/cli/grids/list_command.rb
|
297
299
|
- lib/kontena/cli/grids/logs_command.rb
|
298
300
|
- lib/kontena/cli/grids/remove_command.rb
|
@@ -307,6 +309,7 @@ files:
|
|
307
309
|
- lib/kontena/cli/grids/users/add_command.rb
|
308
310
|
- lib/kontena/cli/grids/users/list_command.rb
|
309
311
|
- lib/kontena/cli/grids/users/remove_command.rb
|
312
|
+
- lib/kontena/cli/helpers/health_helper.rb
|
310
313
|
- lib/kontena/cli/helpers/log_helper.rb
|
311
314
|
- lib/kontena/cli/localhost_web_server.rb
|
312
315
|
- lib/kontena/cli/login_command.rb
|
@@ -343,6 +346,7 @@ files:
|
|
343
346
|
- lib/kontena/cli/master/users_command.rb
|
344
347
|
- lib/kontena/cli/master_command.rb
|
345
348
|
- lib/kontena/cli/node_command.rb
|
349
|
+
- lib/kontena/cli/nodes/health_command.rb
|
346
350
|
- lib/kontena/cli/nodes/label_command.rb
|
347
351
|
- lib/kontena/cli/nodes/labels/add_command.rb
|
348
352
|
- lib/kontena/cli/nodes/labels/list_command.rb
|
@@ -416,12 +420,15 @@ files:
|
|
416
420
|
- lib/kontena/cli/stacks/yaml/custom_validators/hooks_validator.rb
|
417
421
|
- lib/kontena/cli/stacks/yaml/custom_validators/secrets_validator.rb
|
418
422
|
- lib/kontena/cli/stacks/yaml/opto/prompt_resolver.rb
|
423
|
+
- lib/kontena/cli/stacks/yaml/opto/service_instances_resolver.rb
|
419
424
|
- lib/kontena/cli/stacks/yaml/opto/vault_resolver.rb
|
420
425
|
- lib/kontena/cli/stacks/yaml/opto/vault_setter.rb
|
421
426
|
- lib/kontena/cli/stacks/yaml/reader.rb
|
422
427
|
- lib/kontena/cli/stacks/yaml/service_extender.rb
|
423
428
|
- lib/kontena/cli/stacks/yaml/validations.rb
|
424
429
|
- lib/kontena/cli/stacks/yaml/validator_v3.rb
|
430
|
+
- lib/kontena/cli/vault/export_command.rb
|
431
|
+
- lib/kontena/cli/vault/import_command.rb
|
425
432
|
- lib/kontena/cli/vault/list_command.rb
|
426
433
|
- lib/kontena/cli/vault/read_command.rb
|
427
434
|
- lib/kontena/cli/vault/remove_command.rb
|
@@ -437,7 +444,9 @@ files:
|
|
437
444
|
- lib/kontena/cli/whoami_command.rb
|
438
445
|
- lib/kontena/client.rb
|
439
446
|
- lib/kontena/command.rb
|
447
|
+
- lib/kontena/debug_instrumentor.rb
|
440
448
|
- lib/kontena/errors.rb
|
449
|
+
- lib/kontena/light_prompt.rb
|
441
450
|
- lib/kontena/machine/cert_helper.rb
|
442
451
|
- lib/kontena/machine/cloud_config/cloudinit.yml
|
443
452
|
- lib/kontena/machine/cloud_config/node_generator.rb
|
@@ -500,6 +509,7 @@ files:
|
|
500
509
|
- spec/kontena/cli/common_spec.rb
|
501
510
|
- spec/kontena/cli/containers/list_command_spec.rb
|
502
511
|
- spec/kontena/cli/containers/logs_command_spec.rb
|
512
|
+
- spec/kontena/cli/grids/health_command_spec.rb
|
503
513
|
- spec/kontena/cli/grids/trusted_subnets/add_command_spec.rb
|
504
514
|
- spec/kontena/cli/grids/trusted_subnets/list_command_spec.rb
|
505
515
|
- spec/kontena/cli/grids/trusted_subnets/remove_command_spec.rb
|
@@ -514,6 +524,8 @@ files:
|
|
514
524
|
- spec/kontena/cli/master/users/remove_command_spec.rb
|
515
525
|
- spec/kontena/cli/master/users/roles/add_command_spec.rb
|
516
526
|
- spec/kontena/cli/master/users/roles/remove_command_spec.rb
|
527
|
+
- spec/kontena/cli/nodes/health_command_spec.rb
|
528
|
+
- spec/kontena/cli/nodes/list_command_spec.rb
|
517
529
|
- spec/kontena/cli/services/containers_command_spec.rb
|
518
530
|
- spec/kontena/cli/services/link_command_spec.rb
|
519
531
|
- spec/kontena/cli/services/restart_command_spec.rb
|
@@ -534,6 +546,8 @@ files:
|
|
534
546
|
- spec/kontena/cli/stacks/yaml/reader_spec.rb
|
535
547
|
- spec/kontena/cli/stacks/yaml/service_extender_spec.rb
|
536
548
|
- spec/kontena/cli/stacks/yaml/validator_v3_spec.rb
|
549
|
+
- spec/kontena/cli/vault/export_spec.rb
|
550
|
+
- spec/kontena/cli/vault/import_spec.rb
|
537
551
|
- spec/kontena/cli/version_command_spec.rb
|
538
552
|
- spec/kontena/cli/vpn/create_command_spec.rb
|
539
553
|
- spec/kontena/client_spec.rb
|
@@ -542,6 +556,7 @@ files:
|
|
542
556
|
- spec/spec_helper.rb
|
543
557
|
- spec/support/client_helpers.rb
|
544
558
|
- spec/support/fixtures_helpers.rb
|
559
|
+
- spec/support/output_helpers.rb
|
545
560
|
- spec/support/requirements_helper.rb
|
546
561
|
- tasks/release.rake
|
547
562
|
- tasks/rspec.rake
|
@@ -560,9 +575,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
560
575
|
version: 2.0.0
|
561
576
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
562
577
|
requirements:
|
563
|
-
- - "
|
578
|
+
- - ">"
|
564
579
|
- !ruby/object:Gem::Version
|
565
|
-
version:
|
580
|
+
version: 1.3.1
|
566
581
|
requirements: []
|
567
582
|
rubyforge_project:
|
568
583
|
rubygems_version: 2.5.1
|
@@ -617,6 +632,7 @@ test_files:
|
|
617
632
|
- spec/kontena/cli/common_spec.rb
|
618
633
|
- spec/kontena/cli/containers/list_command_spec.rb
|
619
634
|
- spec/kontena/cli/containers/logs_command_spec.rb
|
635
|
+
- spec/kontena/cli/grids/health_command_spec.rb
|
620
636
|
- spec/kontena/cli/grids/trusted_subnets/add_command_spec.rb
|
621
637
|
- spec/kontena/cli/grids/trusted_subnets/list_command_spec.rb
|
622
638
|
- spec/kontena/cli/grids/trusted_subnets/remove_command_spec.rb
|
@@ -631,6 +647,8 @@ test_files:
|
|
631
647
|
- spec/kontena/cli/master/users/remove_command_spec.rb
|
632
648
|
- spec/kontena/cli/master/users/roles/add_command_spec.rb
|
633
649
|
- spec/kontena/cli/master/users/roles/remove_command_spec.rb
|
650
|
+
- spec/kontena/cli/nodes/health_command_spec.rb
|
651
|
+
- spec/kontena/cli/nodes/list_command_spec.rb
|
634
652
|
- spec/kontena/cli/services/containers_command_spec.rb
|
635
653
|
- spec/kontena/cli/services/link_command_spec.rb
|
636
654
|
- spec/kontena/cli/services/restart_command_spec.rb
|
@@ -651,6 +669,8 @@ test_files:
|
|
651
669
|
- spec/kontena/cli/stacks/yaml/reader_spec.rb
|
652
670
|
- spec/kontena/cli/stacks/yaml/service_extender_spec.rb
|
653
671
|
- spec/kontena/cli/stacks/yaml/validator_v3_spec.rb
|
672
|
+
- spec/kontena/cli/vault/export_spec.rb
|
673
|
+
- spec/kontena/cli/vault/import_spec.rb
|
654
674
|
- spec/kontena/cli/version_command_spec.rb
|
655
675
|
- spec/kontena/cli/vpn/create_command_spec.rb
|
656
676
|
- spec/kontena/client_spec.rb
|
@@ -659,4 +679,5 @@ test_files:
|
|
659
679
|
- spec/spec_helper.rb
|
660
680
|
- spec/support/client_helpers.rb
|
661
681
|
- spec/support/fixtures_helpers.rb
|
682
|
+
- spec/support/output_helpers.rb
|
662
683
|
- spec/support/requirements_helper.rb
|