kontena-cli 1.0.1 → 1.0.2.pre1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 08dbe21db191ffa55abcfd05ba71a938324e64fc
4
- data.tar.gz: 86de5ca2a7921f23e5289daa547123ca675232ce
3
+ metadata.gz: 10d95d577cd62d1ef303de2391e5cc943a258492
4
+ data.tar.gz: e38f1964bae2e547b28b281f38a49cb661106e5d
5
5
  SHA512:
6
- metadata.gz: 64dd1d95be76e2ed7198f46648a84b68a10aeac29b5dc5b6d8a618eff1c360a966f71be38cc48d8eb6dc7cffcc4e5b8aad49de9e0d3e5847044b8ebd8cda725d
7
- data.tar.gz: 972083ee70376698af16655bf0d31adbad026f73c8ddb9c05f6f29f0e64e11a3bca200c7bfbf70a7a714d6f09c74d92c760f8cfaad7d7f3588b78916603e819b
6
+ metadata.gz: 79ee080091fef65600adb307d308599bd7399c151b48f5322cfd39baf0f5d61101234d146bf64cfe6a72636ecdda68820ac5deb08bdbb4c82c96272e373b2fcd
7
+ data.tar.gz: 39a0fe44eadac6a14c92ee7b9437b2d9965232d2439d2030163383c6130a2f0b987307d5b79b7eae93b7ed47472f3c010d79839d85d17433efefc119e9900ad0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2.pre1
@@ -1,8 +1,10 @@
1
+ require_relative '../stacks/stacks_helper'
2
+
1
3
  module Kontena::Cli::Registry
2
4
  class CreateCommand < Kontena::Command
3
5
  include Kontena::Cli::Common
4
6
  include Kontena::Cli::GridOptions
5
- include Kontena::Cli::Services::ServicesHelper
7
+ include Kontena::Cli::Stacks::StacksHelper
6
8
 
7
9
  REGISTRY_VERSION = '2.2'
8
10
 
@@ -109,9 +111,7 @@ module Kontena::Cli::Registry
109
111
  client(token).post("grids/#{current_grid}/stacks", data)
110
112
  deployment = client(token).post("stacks/#{current_grid}/registry/deploy", {})
111
113
  spinner "Deploying #{data[:name].colorize(:cyan)} stack " do
112
- deployment['service_deploys'].each do |service_deploy|
113
- wait_for_deploy_to_finish(token, service_deploy)
114
- end
114
+ wait_for_deploy_to_finish(deployment)
115
115
  end
116
116
  puts "\n"
117
117
  puts "Docker Registry #{REGISTRY_VERSION} is now running at registry.#{current_grid}.kontena.local."
@@ -1,10 +1,10 @@
1
- require_relative 'common'
1
+ require_relative 'stacks_helper'
2
2
 
3
3
  module Kontena::Cli::Stacks
4
4
  class DeployCommand < Kontena::Command
5
5
  include Kontena::Cli::Common
6
6
  include Kontena::Cli::GridOptions
7
- include Common
7
+ include StacksHelper
8
8
 
9
9
  banner "Deploys all services of a stack that has been installed in a grid on Kontena Master"
10
10
 
@@ -24,33 +24,5 @@ module Kontena::Cli::Stacks
24
24
  def deploy_stack(name)
25
25
  client.post("stacks/#{current_grid}/#{name}/deploy", {})
26
26
  end
27
-
28
- # @param [Hash] deployment
29
- # @return [Boolean]
30
- def wait_for_deploy_to_finish(deployment, timeout = 600)
31
- deployed = false
32
- progress = []
33
- states = %w(success error)
34
- Timeout::timeout(timeout) do
35
- until deployed
36
- deployment = client.get("stacks/#{deployment['stack_id']}/deploys/#{deployment['id']}")
37
- deployed = true if states.include?(deployment['state'])
38
- sleep 1
39
- end
40
- if deployment['state'] == 'error'
41
- deployment['service_deploys'].each do |service_deploy|
42
- if service_deploy['state'] == 'error'
43
- puts " #{service_deploy['reason']}"
44
- end
45
- end
46
-
47
- raise 'deploy failed'
48
- end
49
- end
50
-
51
- deployed
52
- rescue Timeout::Error
53
- raise 'deploy timed out'
54
- end
55
27
  end
56
28
  end
@@ -0,0 +1,32 @@
1
+
2
+ module Kontena::Cli::Stacks
3
+ module StacksHelper
4
+
5
+ # @param [Hash] deployment
6
+ # @return [Boolean]
7
+ def wait_for_deploy_to_finish(deployment, timeout = 600)
8
+ deployed = false
9
+ states = %w(success error)
10
+ Timeout::timeout(timeout) do
11
+ until deployed
12
+ deployment = client.get("stacks/#{deployment['stack_id']}/deploys/#{deployment['id']}")
13
+ deployed = true if states.include?(deployment['state'])
14
+ sleep 1
15
+ end
16
+ if deployment['state'] == 'error'
17
+ deployment['service_deploys'].each do |service_deploy|
18
+ if service_deploy['state'] == 'error'
19
+ puts " #{service_deploy['reason']}"
20
+ end
21
+ end
22
+
23
+ raise 'deploy failed'
24
+ end
25
+ end
26
+
27
+ deployed
28
+ rescue Timeout::Error
29
+ raise 'deploy timed out'
30
+ end
31
+ end
32
+ end
@@ -1,8 +1,10 @@
1
+ require_relative '../stacks/stacks_helper'
2
+
1
3
  module Kontena::Cli::Vpn
2
4
  class CreateCommand < Kontena::Command
3
5
  include Kontena::Cli::Common
4
6
  include Kontena::Cli::GridOptions
5
- include Kontena::Cli::Services::ServicesHelper
7
+ include Kontena::Cli::Stacks::StacksHelper
6
8
 
7
9
  option '--node', 'NODE', 'Node name where VPN is deployed'
8
10
  option '--ip', 'IP', 'Node ip-address to use in VPN service configuration'
@@ -46,9 +48,7 @@ module Kontena::Cli::Vpn
46
48
  client(token).post("grids/#{current_grid}/stacks", data)
47
49
  deployment = client(token).post("stacks/#{current_grid}/#{name}/deploy", {})
48
50
  spinner "Deploying #{pastel.cyan(name)} service " do
49
- deployment['service_deploys'].each do |service_deploy|
50
- wait_for_deploy_to_finish(token, service_deploy)
51
- end
51
+ wait_for_deploy_to_finish(deployment)
52
52
  end
53
53
  spinner "Generating #{pastel.cyan(name)} keys (this will take a while) " do
54
54
  wait_for_configuration_to_finish(token)
@@ -32,11 +32,27 @@ class Helper
32
32
  []
33
33
  end
34
34
 
35
+ def stacks
36
+ stacks = client.get("grids/#{current_grid}/stacks")['stacks']
37
+ results = []
38
+ results.push stacks.map{|s| s['name']}
39
+ results.delete('null')
40
+ results
41
+ rescue
42
+ []
43
+ end
44
+
35
45
  def services
36
46
  services = client.get("grids/#{current_grid}/services")['services']
37
47
  results = []
38
- results.push services.map{|s| s['name']}
39
-
48
+ results.push services.map{ |s|
49
+ stack = s['stack']['id'].split('/').last
50
+ if stack != 'null'
51
+ "#{stack}/#{s['name']}"
52
+ else
53
+ s['name']
54
+ end
55
+ }
40
56
  results
41
57
  rescue
42
58
  []
@@ -57,17 +73,19 @@ class Helper
57
73
  def yml_services
58
74
  if File.exist?('kontena.yml')
59
75
  yaml = YAML.load(File.read('kontena.yml'))
60
- if yaml['version'] == '2'
61
- services = yaml['services']
62
- else
63
- services = yaml
64
- end
76
+ services = yaml['services']
65
77
  services.keys
66
78
  end
67
79
  rescue
68
80
  []
69
81
  end
70
82
 
83
+ def yml_files
84
+ Dir["./*.yml"].map{|file| file.sub('./', '')}
85
+ rescue
86
+ []
87
+ end
88
+
71
89
  def master_names
72
90
  config_file = File.expand_path('~/.kontena_client.json')
73
91
  if(File.exist?(config_file))
@@ -86,7 +104,7 @@ words = ARGV
86
104
  words.delete_at(0)
87
105
 
88
106
  completion = []
89
- completion.push %w(cloud logout grid app service vault certificate node master vpn registry container etcd external-registry whoami plugin version) if words.size < 2
107
+ completion.push %w(cloud logout grid app service stack vault certificate node master vpn registry container etcd external-registry whoami plugin version) if words.size < 2
90
108
  if words.size > 0
91
109
  case words[0]
92
110
  when 'plugin'
@@ -197,6 +215,25 @@ if words.size > 0
197
215
  else
198
216
  completion.push sub_commands
199
217
  end
218
+ when 'stack'
219
+ completion.clear
220
+ sub_commands = %w(build install upgrade deploy start stop remove rm ls list
221
+ logs monitor show registry)
222
+ if words[1]
223
+ if words[1] == 'registry'
224
+ registry_sub_commands = %(push pull search show rm)
225
+ completion.push registry_sub_commands
226
+ elsif %w(install).include?(words[1])
227
+ completion.push helper.yml_files
228
+ elsif words[1] == 'upgrade' && words[3]
229
+ completion.push helper.yml_files
230
+ else
231
+ completion.push(sub_commands) unless sub_commands.include?(words[1])
232
+ completion.push helper.stacks
233
+ end
234
+ else
235
+ completion.push sub_commands
236
+ end
200
237
  end
201
238
  end
202
239
 
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.1
4
+ version: 1.0.2.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: 2016-12-09 00:00:00.000000000 Z
11
+ date: 2016-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -394,6 +394,7 @@ files:
394
394
  - lib/kontena/cli/stacks/service_generator.rb
395
395
  - lib/kontena/cli/stacks/service_generator_v2.rb
396
396
  - lib/kontena/cli/stacks/show_command.rb
397
+ - lib/kontena/cli/stacks/stacks_helper.rb
397
398
  - lib/kontena/cli/stacks/upgrade_command.rb
398
399
  - lib/kontena/cli/stacks/yaml/custom_validators/affinities_validator.rb
399
400
  - lib/kontena/cli/stacks/yaml/custom_validators/build_validator.rb
@@ -543,9 +544,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
543
544
  version: 2.0.0
544
545
  required_rubygems_version: !ruby/object:Gem::Requirement
545
546
  requirements:
546
- - - ">="
547
+ - - ">"
547
548
  - !ruby/object:Gem::Version
548
- version: '0'
549
+ version: 1.3.1
549
550
  requirements: []
550
551
  rubyforge_project:
551
552
  rubygems_version: 2.5.1