kontena-cli 1.1.6 → 1.2.0.dev1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/VERSION +1 -1
  4. data/bin/kontena +8 -28
  5. data/kontena-cli.gemspec +2 -2
  6. data/lib/kontena/cli/app_command.rb +14 -27
  7. data/lib/kontena/cli/certificate_command.rb +4 -7
  8. data/lib/kontena/cli/cloud/master_command.rb +5 -12
  9. data/lib/kontena/cli/cloud_command.rb +4 -7
  10. data/lib/kontena/cli/container_command.rb +4 -9
  11. data/lib/kontena/cli/etcd/health_command.rb +1 -0
  12. data/lib/kontena/cli/etcd_command.rb +6 -13
  13. data/lib/kontena/cli/external_registry_command.rb +3 -7
  14. data/lib/kontena/cli/grid_command.rb +14 -29
  15. data/lib/kontena/cli/grids/cloud_config_command.rb +1 -0
  16. data/lib/kontena/cli/grids/common.rb +2 -0
  17. data/lib/kontena/cli/grids/create_command.rb +5 -0
  18. data/lib/kontena/cli/grids/trusted_subnet_command.rb +6 -8
  19. data/lib/kontena/cli/grids/user_command.rb +3 -6
  20. data/lib/kontena/cli/master/config_command.rb +6 -12
  21. data/lib/kontena/cli/master/token_command.rb +6 -11
  22. data/lib/kontena/cli/master/users/role_command.rb +2 -4
  23. data/lib/kontena/cli/master/users_command.rb +4 -8
  24. data/lib/kontena/cli/master_command.rb +14 -33
  25. data/lib/kontena/cli/node_command.rb +7 -15
  26. data/lib/kontena/cli/nodes/health_command.rb +1 -1
  27. data/lib/kontena/cli/nodes/label_command.rb +3 -9
  28. data/lib/kontena/cli/nodes/show_command.rb +1 -1
  29. data/lib/kontena/cli/nodes/ssh_command.rb +13 -4
  30. data/lib/kontena/cli/plugin_command.rb +5 -9
  31. data/lib/kontena/cli/registry_command.rb +2 -5
  32. data/lib/kontena/cli/service_command.rb +22 -45
  33. data/lib/kontena/cli/services/container_command.rb +2 -3
  34. data/lib/kontena/cli/services/env_command.rb +3 -6
  35. data/lib/kontena/cli/services/secret_command.rb +2 -4
  36. data/lib/kontena/cli/stack_command.rb +11 -24
  37. data/lib/kontena/cli/stacks/registry_command.rb +5 -12
  38. data/lib/kontena/cli/stacks/upgrade_command.rb +6 -0
  39. data/lib/kontena/cli/stacks/yaml/reader.rb +17 -2
  40. data/lib/kontena/cli/subcommand_loader.rb +82 -0
  41. data/lib/kontena/cli/vault_command.rb +7 -15
  42. data/lib/kontena/cli/version.rb +6 -1
  43. data/lib/kontena/cli/vpn_command.rb +3 -7
  44. data/lib/kontena/command.rb +28 -1
  45. data/lib/kontena/machine/cloud_config/cloudinit.yml +1 -1
  46. data/lib/kontena/main_command.rb +22 -38
  47. data/lib/kontena/scripts/completer +2 -233
  48. data/lib/kontena/scripts/completer.rb +230 -0
  49. data/lib/kontena/scripts/init +5 -8
  50. data/lib/kontena/scripts/kontena.bash +8 -0
  51. data/lib/kontena/scripts/kontena.zsh +11 -0
  52. data/lib/kontena_cli.rb +9 -1
  53. data/omnibus/wrappers/sh/kontena +1 -1
  54. data/spec/fixtures/stack-with-liquid-optional.yml +14 -0
  55. data/spec/fixtures/stack-with-liquid-undefined.yml +12 -0
  56. data/spec/kontena/cli/app/build_command_spec.rb +1 -2
  57. data/spec/kontena/cli/app/common_spec.rb +1 -2
  58. data/spec/kontena/cli/app/config_command_spec.rb +0 -1
  59. data/spec/kontena/cli/app/deploy_command_spec.rb +2 -3
  60. data/spec/kontena/cli/app/docker_helper_spec.rb +0 -1
  61. data/spec/kontena/cli/app/init_command_spec.rb +0 -1
  62. data/spec/kontena/cli/app/logs_command_spec.rb +0 -1
  63. data/spec/kontena/cli/app/scale_spec.rb +2 -3
  64. data/spec/kontena/cli/app/service_generator_spec.rb +1 -2
  65. data/spec/kontena/cli/app/service_generator_v2_spec.rb +0 -1
  66. data/spec/kontena/cli/app/yaml/reader_spec.rb +0 -1
  67. data/spec/kontena/cli/app/yaml/service_extender_spec.rb +0 -1
  68. data/spec/kontena/cli/app/yaml/validator_spec.rb +0 -1
  69. data/spec/kontena/cli/app/yaml/validator_v2_spec.rb +0 -1
  70. data/spec/kontena/cli/cloud/login_command_spec.rb +0 -1
  71. data/spec/kontena/cli/cloud/logout_command_spec.rb +0 -1
  72. data/spec/kontena/cli/cloud/master/add_command_spec.rb +0 -1
  73. data/spec/kontena/cli/common_spec.rb +0 -1
  74. data/spec/kontena/cli/containers/list_command_spec.rb +0 -1
  75. data/spec/kontena/cli/containers/logs_command_spec.rb +0 -1
  76. data/spec/kontena/cli/etcd/health_command_spec.rb +2 -0
  77. data/spec/kontena/cli/grids/trusted_subnets/add_command_spec.rb +0 -11
  78. data/spec/kontena/cli/grids/trusted_subnets/list_command_spec.rb +4 -13
  79. data/spec/kontena/cli/grids/trusted_subnets/remove_command_spec.rb +0 -11
  80. data/spec/kontena/cli/grids/use_command_spec.rb +0 -1
  81. data/spec/kontena/cli/helpers/log_helper_spec.rb +0 -1
  82. data/spec/kontena/cli/main_command_spec.rb +2 -3
  83. data/spec/kontena/cli/master/current_command_spec.rb +5 -15
  84. data/spec/kontena/cli/master/init_cloud_command_spec.rb +0 -1
  85. data/spec/kontena/cli/master/login_command_spec.rb +0 -1
  86. data/spec/kontena/cli/master/logout_command_spec.rb +0 -1
  87. data/spec/kontena/cli/master/use_command_spec.rb +0 -1
  88. data/spec/kontena/cli/master/users/invite_command_spec.rb +1 -5
  89. data/spec/kontena/cli/master/users/remove_command_spec.rb +2 -14
  90. data/spec/kontena/cli/master/users/roles/add_command_spec.rb +0 -1
  91. data/spec/kontena/cli/master/users/roles/remove_command_spec.rb +0 -1
  92. data/spec/kontena/cli/nodes/list_command_spec.rb +2 -0
  93. data/spec/kontena/cli/services/containers_command_spec.rb +0 -18
  94. data/spec/kontena/cli/services/exec_command_spec.rb +6 -4
  95. data/spec/kontena/cli/services/link_command_spec.rb +5 -19
  96. data/spec/kontena/cli/services/restart_command_spec.rb +0 -16
  97. data/spec/kontena/cli/services/secrets/link_command_spec.rb +0 -11
  98. data/spec/kontena/cli/services/secrets/unlink_command_spec.rb +1 -12
  99. data/spec/kontena/cli/services/services_helper_spec.rb +0 -1
  100. data/spec/kontena/cli/services/unlink_command_spec.rb +7 -21
  101. data/spec/kontena/cli/services/update_command_spec.rb +0 -15
  102. data/spec/kontena/cli/stacks/build_command_spec.rb +0 -1
  103. data/spec/kontena/cli/stacks/deploy_command_spec.rb +10 -13
  104. data/spec/kontena/cli/stacks/install_command_spec.rb +0 -15
  105. data/spec/kontena/cli/stacks/list_command_spec.rb +4 -10
  106. data/spec/kontena/cli/stacks/remove_command_spec.rb +1 -16
  107. data/spec/kontena/cli/stacks/service_generator_spec.rb +0 -1
  108. data/spec/kontena/cli/stacks/service_generator_v2_spec.rb +0 -1
  109. data/spec/kontena/cli/stacks/show_command_spec.rb +1 -14
  110. data/spec/kontena/cli/stacks/upgrade_command_spec.rb +19 -1
  111. data/spec/kontena/cli/stacks/yaml/reader_spec.rb +163 -130
  112. data/spec/kontena/cli/stacks/yaml/service_extender_spec.rb +0 -1
  113. data/spec/kontena/cli/stacks/yaml/validator_v3_spec.rb +0 -1
  114. data/spec/kontena/cli/vault/export_spec.rb +0 -1
  115. data/spec/kontena/cli/vault/import_spec.rb +4 -5
  116. data/spec/kontena/cli/version_command_spec.rb +8 -6
  117. data/spec/kontena/cli/vpn/create_command_spec.rb +3 -4
  118. data/spec/kontena/client_spec.rb +0 -1
  119. data/spec/kontena/config_spec.rb +0 -1
  120. data/spec/kontena/kontena_cli_spec.rb +1 -1
  121. data/spec/kontena/main_command_spec.rb +0 -1
  122. data/spec/kontena/plugin_manager_spec.rb +0 -1
  123. data/spec/spec_helper.rb +1 -0
  124. data/spec/support/client_helpers.rb +1 -1
  125. data/spec/support/exit_with_error_helper.rb +36 -0
  126. data/spec/support/fixtures_helpers.rb +5 -2
  127. metadata +18 -7
@@ -1,4 +1,3 @@
1
- require_relative '../../../../spec_helper'
2
1
  require 'kontena/cli/stacks/yaml/service_extender'
3
2
 
4
3
  describe Kontena::Cli::Stacks::YAML::ServiceExtender do
@@ -1,4 +1,3 @@
1
- require_relative '../../../../spec_helper'
2
1
  require 'kontena/cli/stacks/yaml/validator_v3'
3
2
 
4
3
  describe Kontena::Cli::Stacks::YAML::ValidatorV3 do
@@ -1,4 +1,3 @@
1
- require_relative "../../../spec_helper"
2
1
  require 'kontena/cli/vault/export_command'
3
2
 
4
3
  describe Kontena::Cli::Vault::ExportCommand do
@@ -1,4 +1,3 @@
1
- require_relative "../../../spec_helper"
2
1
  require 'kontena/cli/vault/import_command'
3
2
 
4
3
 
@@ -18,15 +17,15 @@ describe Kontena::Cli::Vault::ImportCommand do
18
17
  expect_to_require_current_master
19
18
 
20
19
  it 'asks for confirmation' do
21
- expect(subject).to receive(:confirm).and_raise(RuntimeError, 'confirm')
20
+ expect(subject).to receive(:confirm).and_return(false)
22
21
  expect(File).to receive(:read).with('foo.yml').and_return("foo: bar\n")
23
- expect{subject.run(['foo.yml'])}.to raise_error(RuntimeError, 'confirm')
22
+ subject.run(['foo.yml'])
24
23
  end
25
24
 
26
25
  it 'dies if the yml contains something odd' do
27
26
  expect(File).to receive(:read).with('foo.yml').and_return({foo: 'bar', bar: { foo: ["bar"] }}.to_yaml)
28
- expect(subject).to receive(:exit_with_error).with(/Invalid value/).and_raise(RuntimeError, 'invalid')
29
- expect{subject.run(['foo.yml'])}.to raise_error(RuntimeError, 'invalid')
27
+ expect(subject).to receive(:exit_with_error).with(/Invalid value/).and_call_original
28
+ expect{subject.run(['--force', 'foo.yml'])}.to exit_with_error
30
29
  end
31
30
 
32
31
  it 'runs vault write for kv-pairs in yaml' do
@@ -1,17 +1,19 @@
1
- require_relative "../../spec_helper"
2
1
  require "kontena/cli/version_command"
3
2
 
4
3
  describe Kontena::Cli::VersionCommand do
5
4
 
6
5
  include ClientHelpers
6
+
7
+ let :http_client do
8
+ double(:http_client)
9
+ end
7
10
 
8
11
  describe '#execute' do
9
- before(:each) do
10
- allow(subject).to receive(:client).and_return(client)
11
- end
12
-
13
12
  it 'runs without errors' do
14
- expect { subject.run([]) }.not_to raise_error
13
+ expect(client).to receive(:http_client).and_return(http_client)
14
+ expect(http_client).to receive(:get).with(path: '/').and_return(double(body: '{"version": "0.1"}'))
15
+
16
+ expect { subject.run([]) }.to output("cli: #{Kontena::Cli::VERSION}\nmaster: 0.1 (someurl)\n").to_stdout
15
17
  end
16
18
  end
17
19
  end
@@ -1,4 +1,3 @@
1
- require_relative "../../../spec_helper"
2
1
  require "kontena/cli/vpn/create_command"
3
2
 
4
3
  describe Kontena::Cli::Vpn::CreateCommand do
@@ -13,7 +12,7 @@ describe Kontena::Cli::Vpn::CreateCommand do
13
12
 
14
13
  expect {
15
14
  subject.execute
16
- }.to raise_error SystemExit
15
+ }.to exit_with_error
17
16
  end
18
17
  end
19
18
 
@@ -29,7 +28,7 @@ describe Kontena::Cli::Vpn::CreateCommand do
29
28
 
30
29
  expect {
31
30
  subject.find_node(token, nil)
32
- }.to raise_error SystemExit
31
+ }.to exit_with_error
33
32
  end
34
33
 
35
34
  it 'should return first online node with public ip' do
@@ -69,7 +68,7 @@ describe Kontena::Cli::Vpn::CreateCommand do
69
68
 
70
69
  expect {
71
70
  subject.find_node(token, 'foobar')
72
- }.to raise_error SystemExit
71
+ }.to exit_with_error
73
72
  end
74
73
 
75
74
  end
@@ -1,4 +1,3 @@
1
- require_relative '../spec_helper'
2
1
  require 'kontena_cli'
3
2
  require 'ostruct'
4
3
 
@@ -1,4 +1,3 @@
1
- require_relative '../spec_helper'
2
1
 
3
2
  # Lots of coverage already in Common spec
4
3
  describe Kontena::Cli::Config do
@@ -1,6 +1,6 @@
1
- require_relative '../spec_helper'
2
1
  require 'kontena_cli'
3
2
  require 'kontena/light_prompt'
3
+ require 'kontena/cli/whoami_command'
4
4
 
5
5
  describe Kontena do
6
6
  context 'prompt' do
@@ -1,4 +1,3 @@
1
- require_relative '../spec_helper'
2
1
  require 'kontena/main_command'
3
2
 
4
3
  describe Kontena::MainCommand do
@@ -1,4 +1,3 @@
1
- require_relative '../spec_helper'
2
1
  require 'kontena_cli'
3
2
 
4
3
  describe Kontena::PluginManager do
data/spec/spec_helper.rb CHANGED
@@ -62,3 +62,4 @@ require_relative 'support/client_helpers'
62
62
  require_relative 'support/requirements_helper'
63
63
  require_relative 'support/fixtures_helpers'
64
64
  require_relative 'support/output_helpers'
65
+ require_relative 'support/exit_with_error_helper'
@@ -6,7 +6,7 @@ module ClientHelpers
6
6
  end
7
7
 
8
8
  base.let(:client) do
9
- spy(:client)
9
+ instance_double(Kontena::Client, :client)
10
10
  end
11
11
 
12
12
  base.let(:token) do
@@ -0,0 +1,36 @@
1
+ RSpec::Matchers.define :exit_with_error do
2
+
3
+ def supports_block_expectations?
4
+ true
5
+ end
6
+
7
+ match do |block|
8
+ begin
9
+ block.call
10
+ rescue SystemExit => e
11
+ @exit_status = e.status
12
+ end
13
+ !@exit_status.nil? && @exit_status == expected_status
14
+ end
15
+
16
+ chain :status do |status|
17
+ @expected_status = status
18
+ end
19
+
20
+ failure_message do |block|
21
+ "expected block to exit with status #{expected_status} but exit " +
22
+ (@exit_status.nil? ? "was not called" : "status was #{@exit_status}")
23
+ end
24
+
25
+ failure_message_when_negated do |block|
26
+ "expected block not to raise SystemExit, got exit with status #{@exit_status}"
27
+ end
28
+
29
+ description do
30
+ "expect block to exit #{expected_status.zero? ? "without error" : "with error (status #{expected_status})"}"
31
+ end
32
+
33
+ def expected_status
34
+ @expected_status ||= 1
35
+ end
36
+ end
@@ -1,7 +1,10 @@
1
1
  module FixturesHelpers
2
2
  FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/'
3
3
 
4
+ def fixture_path(file)
5
+ File.expand_path(FIXTURES_PATH + file)
6
+ end
4
7
  def fixture(file)
5
- IO.read(FIXTURES_PATH+file)
8
+ IO.read(fixture_path(file))
6
9
  end
7
- end
10
+ 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.1.6
4
+ version: 1.2.0.dev1
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-03-31 00:00:00.000000000 Z
11
+ date: 2017-03-09 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.10'
61
+ version: 0.11.0
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.10'
68
+ version: 0.11.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: clamp
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -192,7 +192,7 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: 4.0.0
195
- description: Kontena command line tool
195
+ description: Command-line client for the Kontena container and microservices platform
196
196
  email:
197
197
  - info@kontena.io
198
198
  executables:
@@ -202,6 +202,7 @@ extra_rdoc_files: []
202
202
  files:
203
203
  - ".dockerignore"
204
204
  - ".gitignore"
205
+ - ".rspec"
205
206
  - Dockerfile
206
207
  - Gemfile
207
208
  - LICENSE.txt
@@ -444,6 +445,7 @@ files:
444
445
  - lib/kontena/cli/stacks/yaml/service_extender.rb
445
446
  - lib/kontena/cli/stacks/yaml/validations.rb
446
447
  - lib/kontena/cli/stacks/yaml/validator_v3.rb
448
+ - lib/kontena/cli/subcommand_loader.rb
447
449
  - lib/kontena/cli/vault/export_command.rb
448
450
  - lib/kontena/cli/vault/import_command.rb
449
451
  - lib/kontena/cli/vault/list_command.rb
@@ -474,7 +476,10 @@ files:
474
476
  - lib/kontena/presets/github_auth_provider.yml
475
477
  - lib/kontena/presets/kontena_auth_provider.yml
476
478
  - lib/kontena/scripts/completer
479
+ - lib/kontena/scripts/completer.rb
477
480
  - lib/kontena/scripts/init
481
+ - lib/kontena/scripts/kontena.bash
482
+ - lib/kontena/scripts/kontena.zsh
478
483
  - lib/kontena/stacks_cache.rb
479
484
  - lib/kontena/stacks_client.rb
480
485
  - lib/kontena/util.rb
@@ -522,6 +527,8 @@ files:
522
527
  - spec/fixtures/stack-with-env-file.yml
523
528
  - spec/fixtures/stack-with-ifs.yml
524
529
  - spec/fixtures/stack-with-invalid-liquid.yml
530
+ - spec/fixtures/stack-with-liquid-optional.yml
531
+ - spec/fixtures/stack-with-liquid-undefined.yml
525
532
  - spec/fixtures/stack-with-liquid.yml
526
533
  - spec/fixtures/stack-with-prompted-variables.yml
527
534
  - spec/fixtures/stack-with-variables.yml
@@ -601,6 +608,7 @@ files:
601
608
  - spec/kontena/plugin_manager_spec.rb
602
609
  - spec/spec_helper.rb
603
610
  - spec/support/client_helpers.rb
611
+ - spec/support/exit_with_error_helper.rb
604
612
  - spec/support/fixtures_helpers.rb
605
613
  - spec/support/output_helpers.rb
606
614
  - spec/support/requirements_helper.rb
@@ -621,9 +629,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
621
629
  version: 2.1.0
622
630
  required_rubygems_version: !ruby/object:Gem::Requirement
623
631
  requirements:
624
- - - ">="
632
+ - - ">"
625
633
  - !ruby/object:Gem::Version
626
- version: '0'
634
+ version: 1.3.1
627
635
  requirements: []
628
636
  rubyforge_project:
629
637
  rubygems_version: 2.6.8
@@ -655,6 +663,8 @@ test_files:
655
663
  - spec/fixtures/stack-with-env-file.yml
656
664
  - spec/fixtures/stack-with-ifs.yml
657
665
  - spec/fixtures/stack-with-invalid-liquid.yml
666
+ - spec/fixtures/stack-with-liquid-optional.yml
667
+ - spec/fixtures/stack-with-liquid-undefined.yml
658
668
  - spec/fixtures/stack-with-liquid.yml
659
669
  - spec/fixtures/stack-with-prompted-variables.yml
660
670
  - spec/fixtures/stack-with-variables.yml
@@ -734,6 +744,7 @@ test_files:
734
744
  - spec/kontena/plugin_manager_spec.rb
735
745
  - spec/spec_helper.rb
736
746
  - spec/support/client_helpers.rb
747
+ - spec/support/exit_with_error_helper.rb
737
748
  - spec/support/fixtures_helpers.rb
738
749
  - spec/support/output_helpers.rb
739
750
  - spec/support/requirements_helper.rb