kontena-cli 1.3.0 → 1.3.1.rc1
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 +0 -1
- data/lib/kontena/autoload_core.rb +1 -1
- data/lib/kontena/cli/apps/common.rb +1 -0
- data/lib/kontena/cli/apps/config_command.rb +1 -1
- data/lib/kontena/cli/apps/init_command.rb +0 -3
- data/lib/kontena/cli/apps/kontena_yml_generator.rb +0 -2
- data/lib/kontena/cli/apps/yaml/reader.rb +0 -2
- data/lib/kontena/cli/master/config/import_command.rb +0 -2
- data/lib/kontena/cli/nodes/list_command.rb +1 -1
- data/lib/kontena/cli/plugins/install_command.rb +5 -17
- data/lib/kontena/cli/plugins/uninstall_command.rb +2 -0
- data/lib/kontena/cli/stacks/common.rb +1 -3
- data/lib/kontena/cli/stacks/registry/show_command.rb +0 -2
- data/lib/kontena/cli/stacks/yaml/reader.rb +0 -2
- data/lib/kontena/cli/vault/export_command.rb +1 -2
- data/lib/kontena/cli/vault/import_command.rb +0 -2
- data/lib/kontena/main_command.rb +22 -12
- data/lib/kontena/plugin_manager.rb +2 -10
- data/lib/kontena/scripts/completer.rb +1 -1
- data/lib/kontena/stacks_cache.rb +0 -2
- data/spec/kontena/cli/app/config_command_spec.rb +1 -0
- data/spec/kontena/cli/nodes/list_command_spec.rb +40 -0
- data/spec/kontena/cli/plugins/install_command_spec.rb +10 -0
- data/spec/kontena/cli/vault/{export_spec.rb → export_command_spec.rb} +0 -0
- data/spec/kontena/cli/vault/{import_spec.rb → import_command_spec.rb} +1 -1
- metadata +10 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6045b4c6dceb33697e5f728679d1021cfba62519
|
4
|
+
data.tar.gz: d13307a8b2ecffa1b2bd5b4f02ad965a97db23fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 269cce5ddd6f2c6b47ce1df51c9d1d7b5abd1787d0eea28e9f10f5fcf9c85ecaafc6d655a281734dd33ed437a31d4f32d54fdfa575985be52f38535a5c735e6f
|
7
|
+
data.tar.gz: ee09b9b9522f59438db81170a0d9c6e7c79cec94c29e70d271f7b3cdafaec1cc83374d0d9664a4546b91f82288e63960c2b031920eabc985614fe8dc273995a1
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.1.rc1
|
data/kontena-cli.gemspec
CHANGED
@@ -31,7 +31,6 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_runtime_dependency "retriable", "~> 2.1.0"
|
32
32
|
spec.add_runtime_dependency "opto", "1.8.5"
|
33
33
|
spec.add_runtime_dependency "semantic", "~> 1.5"
|
34
|
-
spec.add_runtime_dependency "safe_yaml", "~> 1.0"
|
35
34
|
spec.add_runtime_dependency "liquid", "~> 4.0.0"
|
36
35
|
spec.add_runtime_dependency "tty-table", "~> 0.8.0"
|
37
36
|
spec.add_runtime_dependency "websocket-driver-kontena", "0.6.5"
|
@@ -4,9 +4,6 @@ require_relative 'dockerfile_generator'
|
|
4
4
|
require_relative 'docker_compose_generator'
|
5
5
|
require_relative 'kontena_yml_generator'
|
6
6
|
|
7
|
-
require "safe_yaml"
|
8
|
-
SafeYAML::OPTIONS[:default_mode] = :safe
|
9
|
-
|
10
7
|
module Kontena::Cli::Apps
|
11
8
|
class InitCommand < Kontena::Command
|
12
9
|
include Kontena::Cli::Common
|
@@ -66,7 +66,7 @@ module Kontena::Cli::Nodes
|
|
66
66
|
unless quiet?
|
67
67
|
grid_health = grid_health(grid, grid_nodes)
|
68
68
|
grid_nodes.each do |node|
|
69
|
-
node['name'] = health_icon(node_health(node, grid_health)) + " " + node['name']
|
69
|
+
node['name'] = health_icon(node_health(node, grid_health)) + " " + (node['name'] || '(initializing)')
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -14,28 +14,16 @@ module Kontena::Cli::Plugins
|
|
14
14
|
installed_version = Kontena::PluginManager.instance.installed(name)
|
15
15
|
|
16
16
|
if installed_version
|
17
|
-
installed = spinner "Upgrading plugin #{name.colorize(:cyan)}" do
|
18
|
-
|
19
|
-
Kontena::PluginManager.instance.upgrade_plugin(name, pre: pre?)
|
20
|
-
rescue => ex
|
21
|
-
$stderr.puts pastel.red("#{ex.class.name} : #{ex.message}")
|
22
|
-
logger.error(ex)
|
23
|
-
spin.fail!
|
24
|
-
end
|
17
|
+
installed = spinner "Upgrading plugin #{name.colorize(:cyan)}" do
|
18
|
+
Kontena::PluginManager.instance.upgrade_plugin(name, pre: pre?)
|
25
19
|
end
|
26
20
|
|
27
|
-
spinner "Running cleanup" do
|
21
|
+
spinner "Running cleanup" do
|
28
22
|
Kontena::PluginManager.instance.cleanup_plugin(name)
|
29
23
|
end
|
30
24
|
else
|
31
|
-
installed = spinner "Installing plugin #{name.colorize(:cyan)}" do
|
32
|
-
|
33
|
-
Kontena::PluginManager.instance.install_plugin(name, pre: pre?, version: version)
|
34
|
-
rescue => ex
|
35
|
-
$stderr.puts pastel.red("#{ex.class.name} : #{ex.message}")
|
36
|
-
logger.error(ex)
|
37
|
-
spin.fail!
|
38
|
-
end
|
25
|
+
installed = spinner "Installing plugin #{name.colorize(:cyan)}" do
|
26
|
+
Kontena::PluginManager.instance.install_plugin(name, pre: pre?, version: version)
|
39
27
|
end
|
40
28
|
end
|
41
29
|
|
@@ -6,9 +6,11 @@ module Kontena::Cli::Plugins
|
|
6
6
|
include Kontena::Cli::Common
|
7
7
|
|
8
8
|
parameter 'NAME', 'Plugin name'
|
9
|
+
|
9
10
|
option "--force", :flag, "Force remove", default: false, attribute_name: :forced
|
10
11
|
|
11
12
|
def execute
|
13
|
+
exit_with_error "Plugin #{pastel.cyan(name)} is not installed" unless Kontena::PluginManager.instance.installed(name) && !ENV['NO_PLUGINS']
|
12
14
|
confirm unless forced?
|
13
15
|
spinner "Uninstalling plugin #{pastel.cyan(name)}" do |spin|
|
14
16
|
begin
|
@@ -2,9 +2,7 @@ require_relative 'yaml/reader'
|
|
2
2
|
require_relative '../services/services_helper'
|
3
3
|
require_relative 'service_generator_v2'
|
4
4
|
require_relative '../../stacks_client'
|
5
|
-
|
6
|
-
require "safe_yaml"
|
7
|
-
SafeYAML::OPTIONS[:default_mode] = :safe
|
5
|
+
require 'yaml'
|
8
6
|
|
9
7
|
module Kontena::Cli::Stacks
|
10
8
|
module Common
|
@@ -14,8 +14,6 @@ module Kontena::Cli::Stacks::Registry
|
|
14
14
|
|
15
15
|
def execute
|
16
16
|
require 'semantic'
|
17
|
-
require "safe_yaml"
|
18
|
-
SafeYAML::OPTIONS[:default_mode] = :safe
|
19
17
|
unless versions?
|
20
18
|
stack = ::YAML.safe_load(stacks_client.show(stack_name, stack_version))
|
21
19
|
puts "#{stack['stack']}:"
|
@@ -25,8 +25,6 @@ module Kontena::Cli::Stacks
|
|
25
25
|
attr_reader :file, :raw_content, :errors, :notifications, :defaults, :values, :registry
|
26
26
|
|
27
27
|
def initialize(file, skip_validation: false, skip_variables: false, variables: nil, values: nil, defaults: nil)
|
28
|
-
require "safe_yaml"
|
29
|
-
SafeYAML::OPTIONS[:default_mode] = :safe
|
30
28
|
require_relative 'service_extender'
|
31
29
|
require_relative 'validator_v3'
|
32
30
|
require_relative 'opto'
|
@@ -12,8 +12,7 @@ module Kontena::Cli::Vault
|
|
12
12
|
def execute
|
13
13
|
require 'shellwords'
|
14
14
|
require 'json'
|
15
|
-
require
|
16
|
-
SafeYAML::OPTIONS[:default_mode] = :safe
|
15
|
+
require 'yaml'
|
17
16
|
meth = json? ? :to_json : :to_yaml
|
18
17
|
puts(
|
19
18
|
Kontena.run!(['vault', 'ls', '--return']).sort.map do |secret|
|
data/lib/kontena/main_command.rb
CHANGED
@@ -9,25 +9,30 @@ class Kontena::MainCommand < Kontena::Command
|
|
9
9
|
exit 0
|
10
10
|
end
|
11
11
|
|
12
|
+
banner Kontena.pastel.green("Getting started:"), false
|
13
|
+
banner ' - Create a Kontena Master (see "kontena plugin search" for a list of', false
|
14
|
+
banner ' provisioning plugins)', false
|
15
|
+
banner ' - Or log into an existing master, use: "kontena master login <master url>"', false
|
16
|
+
banner ' - Read more about Kontena at https://www.kontena.io/docs/', false
|
17
|
+
|
18
|
+
subcommand "master", "Kontena Master specific commands", load_subcommand('master_command')
|
12
19
|
subcommand "cloud", "Kontena Cloud specific commands", load_subcommand('cloud_command')
|
13
|
-
subcommand "
|
20
|
+
subcommand "node", "Node specific commands", load_subcommand('node_command')
|
14
21
|
subcommand "grid", "Grid specific commands", load_subcommand('grid_command')
|
15
|
-
subcommand "app", "App specific commands", load_subcommand('app_command')
|
16
22
|
subcommand "stack", "Stack specific commands", load_subcommand('stack_command')
|
17
23
|
subcommand "service", "Service specific commands", load_subcommand('service_command')
|
24
|
+
subcommand "container", "Container specific commands", load_subcommand('container_command')
|
18
25
|
subcommand "vault", "Vault specific commands", load_subcommand('vault_command')
|
19
|
-
subcommand "certificate", "LE Certificate specific commands", load_subcommand('certificate_command')
|
20
|
-
subcommand "node", "Node specific commands", load_subcommand('node_command')
|
21
|
-
subcommand "master", "Master specific commands", load_subcommand('master_command')
|
22
26
|
subcommand "vpn", "VPN specific commands", load_subcommand('vpn_command')
|
23
|
-
subcommand "registry", "Registry specific commands", load_subcommand('registry_command')
|
24
|
-
subcommand "container", "Container specific commands", load_subcommand('container_command')
|
25
27
|
subcommand "etcd", "Etcd specific commands", load_subcommand('etcd_command')
|
28
|
+
subcommand "certificate", "LE Certificate specific commands", load_subcommand('certificate_command')
|
29
|
+
subcommand "registry", "Registry specific commands", load_subcommand('registry_command')
|
26
30
|
subcommand "external-registry", "External registry specific commands", load_subcommand('external_registry_command')
|
31
|
+
subcommand "volume", "Volume specific commands [EXPERIMENTAL]", load_subcommand('volume_command')
|
32
|
+
subcommand "app", "App specific commands", load_subcommand('app_command')
|
33
|
+
subcommand "plugin", "Plugin specific commands", load_subcommand('plugin_command')
|
27
34
|
subcommand "whoami", "Shows current logged in user", load_subcommand('whoami_command')
|
28
|
-
subcommand "plugin", "Plugin related commands", load_subcommand('plugin_command')
|
29
35
|
subcommand "version", "Show CLI and current master version", load_subcommand('version_command')
|
30
|
-
subcommand "volume", "Volume specific commands [EXPERIMENTAL]", load_subcommand('volume_command')
|
31
36
|
|
32
37
|
def execute
|
33
38
|
end
|
@@ -40,12 +45,17 @@ class Kontena::MainCommand < Kontena::Command
|
|
40
45
|
end
|
41
46
|
|
42
47
|
def subcommand_missing(name)
|
48
|
+
extend Kontena::Cli::Common
|
43
49
|
if known_plugin_subcommand?(name)
|
44
|
-
extend Kontena::Cli::Common
|
45
50
|
exit_with_error "The '#{name}' plugin has not been installed. Use: kontena plugin install #{name}"
|
46
|
-
|
47
|
-
|
51
|
+
elsif name == 'login'
|
52
|
+
exit_with_error "Use 'kontena master login' to log into a Kontena Master\n"+
|
53
|
+
" or 'kontena cloud login' for logging into your Kontena Cloud account"
|
54
|
+
elsif name == 'logout'
|
55
|
+
exit_with_error "Use 'kontena master logout' to log out from a Kontena Master\n"+
|
56
|
+
" or 'kontena cloud logout' for logging out from your Kontena Cloud account"
|
48
57
|
end
|
58
|
+
super
|
49
59
|
end
|
50
60
|
|
51
61
|
def known_plugin_subcommand?(name)
|
@@ -37,7 +37,7 @@ module Kontena
|
|
37
37
|
minimal_deps: true
|
38
38
|
)
|
39
39
|
plugin_version = version.nil? ? Gem::Requirement.default : Gem::Requirement.new(version)
|
40
|
-
|
40
|
+
cmd.install(prefix(plugin_name), plugin_version)
|
41
41
|
cmd.installed_gems
|
42
42
|
end
|
43
43
|
|
@@ -110,7 +110,7 @@ module Kontena
|
|
110
110
|
options = []
|
111
111
|
options += ['-q', '--no-verbose'] unless ENV["DEBUG"]
|
112
112
|
cmd.handle_options options
|
113
|
-
|
113
|
+
cmd.execute
|
114
114
|
rescue Gem::SystemExitException => e
|
115
115
|
return true if e.exit_code == 0
|
116
116
|
raise
|
@@ -136,14 +136,6 @@ module Kontena
|
|
136
136
|
|
137
137
|
private
|
138
138
|
|
139
|
-
# Execute block without SafeYAML. Gem does security internally.
|
140
|
-
def without_safe(&block)
|
141
|
-
SafeYAML::OPTIONS[:default_mode] = :unsafe if Object.const_defined?(:SafeYAML)
|
142
|
-
yield
|
143
|
-
ensure
|
144
|
-
SafeYAML::OPTIONS[:default_mode] = :safe if Object.const_defined?(:SafeYAML)
|
145
|
-
end
|
146
|
-
|
147
139
|
def plugin_debug?
|
148
140
|
@plugin_debug ||= ENV['DEBUG'] == 'plugin'
|
149
141
|
end
|
@@ -139,7 +139,7 @@ helper.logger.debug { "Completing #{words.inspect}" }
|
|
139
139
|
|
140
140
|
begin
|
141
141
|
completion = []
|
142
|
-
completion.push %w(cloud
|
142
|
+
completion.push %w(cloud grid app service stack vault certificate node master vpn registry container etcd external-registry whoami plugin version) if words.size < 2
|
143
143
|
if words.size > 0
|
144
144
|
case words[0]
|
145
145
|
when 'plugin'
|
data/lib/kontena/stacks_cache.rb
CHANGED
@@ -111,6 +111,46 @@ describe Kontena::Cli::Nodes::ListCommand do
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
+
context "with two online nodes and one initializing node" do
|
115
|
+
before do
|
116
|
+
allow(client).to receive(:get).with('grids/test-grid/nodes').and_return(
|
117
|
+
{ "nodes" => [
|
118
|
+
{
|
119
|
+
"connected" => true,
|
120
|
+
"name" => "node-1",
|
121
|
+
"node_number" => 1,
|
122
|
+
"initial_member" => true,
|
123
|
+
'agent_version' => '1.1-dev',
|
124
|
+
},
|
125
|
+
{
|
126
|
+
"connected" => true,
|
127
|
+
"name" => "node-2",
|
128
|
+
"node_number" => 2,
|
129
|
+
"initial_member" => true,
|
130
|
+
'agent_version' => '1.1-dev',
|
131
|
+
},
|
132
|
+
# node has just connected, but not sent any node_info yet
|
133
|
+
{
|
134
|
+
"connected" => false,
|
135
|
+
"name" => nil,
|
136
|
+
"node_number" => nil,
|
137
|
+
"initial_member" => false,
|
138
|
+
'agent_version' => nil,
|
139
|
+
},
|
140
|
+
]
|
141
|
+
}
|
142
|
+
)
|
143
|
+
end
|
144
|
+
|
145
|
+
it "outputs two nodes with warning and one initializing" do
|
146
|
+
expect{subject.run([])}.to output_table [
|
147
|
+
[':warning node-1', '1.1-dev', 'online', '1 / 3', '-'],
|
148
|
+
[':warning node-2', '1.1-dev', 'online', '2 / 3', '-'],
|
149
|
+
[':offline (initializing)', '', 'offline', '-', '-'],
|
150
|
+
]
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
114
154
|
context "with two online nodes and one offline node" do
|
115
155
|
before do
|
116
156
|
allow(client).to receive(:get).with('grids/test-grid/nodes').and_return(
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'kontena/cli/plugins/install_command'
|
2
|
+
|
3
|
+
describe Kontena::Cli::Plugins::InstallCommand do
|
4
|
+
let(:subject) { described_class.new([]) }
|
5
|
+
|
6
|
+
it 'exits with error if plugin not found' do
|
7
|
+
expect(Kontena::PluginManager.instance).to receive(:install_plugin).and_raise(StandardError, 'bar')
|
8
|
+
expect{subject.run(['foofoo'])}.to exit_with_error.and output(/StandardError/).to_stderr
|
9
|
+
end
|
10
|
+
end
|
File without changes
|
@@ -23,7 +23,7 @@ describe Kontena::Cli::Vault::ImportCommand do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'dies if the yml contains something odd' do
|
26
|
-
expect(File).to receive(:read).with('foo.yml').and_return(
|
26
|
+
expect(File).to receive(:read).with('foo.yml').and_return("foo: bar\nbar:\n foo:\n - bar\n")
|
27
27
|
expect(subject).to receive(:exit_with_error).with(/Invalid value/).and_call_original
|
28
28
|
expect{subject.run(['--force', 'foo.yml'])}.to exit_with_error
|
29
29
|
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.3.
|
4
|
+
version: 1.3.1.rc1
|
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-06-
|
11
|
+
date: 2017-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -164,20 +164,6 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '1.5'
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: safe_yaml
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - "~>"
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '1.0'
|
174
|
-
type: :runtime
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - "~>"
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: '1.0'
|
181
167
|
- !ruby/object:Gem::Dependency
|
182
168
|
name: liquid
|
183
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -626,6 +612,7 @@ files:
|
|
626
612
|
- spec/kontena/cli/nodes/health_command_spec.rb
|
627
613
|
- spec/kontena/cli/nodes/list_command_spec.rb
|
628
614
|
- spec/kontena/cli/nodes/ssh_command_spec.rb
|
615
|
+
- spec/kontena/cli/plugins/install_command_spec.rb
|
629
616
|
- spec/kontena/cli/registry/create_spec.rb
|
630
617
|
- spec/kontena/cli/services/containers_command_spec.rb
|
631
618
|
- spec/kontena/cli/services/events_command_spec.rb
|
@@ -660,8 +647,8 @@ files:
|
|
660
647
|
- spec/kontena/cli/stacks/yaml/service_extender_spec.rb
|
661
648
|
- spec/kontena/cli/stacks/yaml/validator_v3_spec.rb
|
662
649
|
- spec/kontena/cli/table_generator_spec.rb
|
663
|
-
- spec/kontena/cli/vault/
|
664
|
-
- spec/kontena/cli/vault/
|
650
|
+
- spec/kontena/cli/vault/export_command_spec.rb
|
651
|
+
- spec/kontena/cli/vault/import_command_spec.rb
|
665
652
|
- spec/kontena/cli/vault/update_command_spec.rb
|
666
653
|
- spec/kontena/cli/vault/write_command_spec.rb
|
667
654
|
- spec/kontena/cli/version_command_spec.rb
|
@@ -695,9 +682,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
695
682
|
version: 2.1.0
|
696
683
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
697
684
|
requirements:
|
698
|
-
- - "
|
685
|
+
- - ">"
|
699
686
|
- !ruby/object:Gem::Version
|
700
|
-
version:
|
687
|
+
version: 1.3.1
|
701
688
|
requirements: []
|
702
689
|
rubyforge_project:
|
703
690
|
rubygems_version: 2.6.8
|
@@ -781,6 +768,7 @@ test_files:
|
|
781
768
|
- spec/kontena/cli/nodes/health_command_spec.rb
|
782
769
|
- spec/kontena/cli/nodes/list_command_spec.rb
|
783
770
|
- spec/kontena/cli/nodes/ssh_command_spec.rb
|
771
|
+
- spec/kontena/cli/plugins/install_command_spec.rb
|
784
772
|
- spec/kontena/cli/registry/create_spec.rb
|
785
773
|
- spec/kontena/cli/services/containers_command_spec.rb
|
786
774
|
- spec/kontena/cli/services/events_command_spec.rb
|
@@ -815,8 +803,8 @@ test_files:
|
|
815
803
|
- spec/kontena/cli/stacks/yaml/service_extender_spec.rb
|
816
804
|
- spec/kontena/cli/stacks/yaml/validator_v3_spec.rb
|
817
805
|
- spec/kontena/cli/table_generator_spec.rb
|
818
|
-
- spec/kontena/cli/vault/
|
819
|
-
- spec/kontena/cli/vault/
|
806
|
+
- spec/kontena/cli/vault/export_command_spec.rb
|
807
|
+
- spec/kontena/cli/vault/import_command_spec.rb
|
820
808
|
- spec/kontena/cli/vault/update_command_spec.rb
|
821
809
|
- spec/kontena/cli/vault/write_command_spec.rb
|
822
810
|
- spec/kontena/cli/version_command_spec.rb
|