kontena-cli 0.16.0.pre3 → 0.16.0.pre4

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: fa0396ae545ef65b7d8f8011ff078e644d593a94
4
- data.tar.gz: b146002d263311acb234c18fc39c9bd187dc360c
3
+ metadata.gz: 36e047ed9eeab9703d96bf167ae05ae212a8d696
4
+ data.tar.gz: 4c947a57f0d149044c1aa255e317db8115d2e305
5
5
  SHA512:
6
- metadata.gz: 050323b6a272b3ba7ee93bd21dc7b717b6254297c0e53a55035ed42cc4d0c0e98a021eea80fb5037b725e504c59116ac5b56435ca21defce0752567ac8082a73
7
- data.tar.gz: fff1427644f1620501fb95660e609090dfd2e2d8b8dfaaf4b29005bfedfb8e705204f238810960f9b64816b0c1605664289be0e77aed6f333aa6f485ab7dad6a
6
+ metadata.gz: dd2d2120ea3c23cfb2d3be1d867ec2b05475a9c6f9abfa689efe9ff6682ea6740ff10079163c104a7f3fcc65a818ce2fb688a48fea6f8703cc4a8bb4248bebd0
7
+ data.tar.gz: 86e61055eb8c0c34e0569c5bc26ae0f96055cca0dc90c3c6f8eaacae09752c7409ae666ca038a1a6a0ef8ce03b44327eec08d72e5ef383fd0215fd7d88937f9e
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.16.0.pre3
1
+ 0.16.0.pre4
@@ -0,0 +1,18 @@
1
+ module Kontena
2
+ module Callbacks
3
+ class DefaultMasterVersion < Kontena::Callback
4
+
5
+ matches_commands 'master create'
6
+
7
+ def after_load
8
+ # Only run this for prerelease cli
9
+ return unless Kontena::Cli::VERSION =~ /\d\.(?:pre|rc|beta|edge)/
10
+ version_switch = command.recognised_options.find {|opt| opt.switches.include?('--version')}
11
+ if version_switch
12
+ version_switch.instance_variable_set(:@default_value, 'edge')
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -84,13 +84,13 @@ module Kontena
84
84
  command.skip_auth_provider = false
85
85
  when :custom
86
86
  puts
87
- puts 'Learn how to configure custom user authentication provider after installation at: www.kontena.io/docs/configuring-custom-auth-provider'
87
+ puts 'Learn how to configure custom user authentication provider after installation at: www.kontena.io/docs/using-kontena/authentication'
88
88
  puts
89
89
  command.cloud_master_id = nil
90
90
  command.skip_auth_provider = true
91
91
  when :none
92
92
  puts
93
- puts "You have selected to use Kontena Master in single user mode. You can configure an authentication provider later. For more information, see here: www.kontena.io/docs/configuring-custom-auth-provider"
93
+ puts "You have selected to use Kontena Master in single user mode. You can configure an authentication provider later. For more information, see here: www.kontena.io/docs/using-kontena/authentication"
94
94
  puts
95
95
  command.cloud_master_id = nil
96
96
  command.skip_auth_provider = true
@@ -44,7 +44,7 @@ module Kontena
44
44
  end
45
45
 
46
46
  require 'shellwords'
47
- cmd = "master login --verbose --name #{command.result[:name].shellescape} --code #{command.result[:code].shellescape} #{new_master.url.shellescape}"
47
+ cmd = "master login --skip-grid-auto-select --verbose --name #{command.result[:name].shellescape} --code #{command.result[:code].shellescape} #{new_master.url.shellescape}"
48
48
  ENV["DEBUG"] && puts("Running: #{cmd}")
49
49
  Kontena.run(cmd)
50
50
  end
@@ -6,38 +6,51 @@ class Kontena::Command < Clamp::Command
6
6
  attr_reader :result
7
7
  attr_reader :exit_code
8
8
 
9
-
10
- def self.inherited(where)
11
- return if where.has_subcommands?
12
- return if where.callback_matcher
13
-
14
- name_parts = where.name.split('::')[-2, 2]
15
-
16
- unless name_parts.compact.empty?
17
- # 1: Remove trailing 'Command' from for example AuthCommand
18
- # 2: Convert the string from CamelCase to under_score
19
- # 3: Convert the string into a symbol
20
- #
21
- # In comes: ['ExternalRegistry', 'UseCommand']
22
- # Out goes: [:external_registry, :use]
23
- name_parts = name_parts.map { |np|
24
- np.gsub(/Command$/, '').
25
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
26
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
27
- tr("-", "_").
28
- downcase.
29
- to_sym
30
- }
31
- where.callback_matcher(*name_parts)
9
+ module Finalizer
10
+ def self.extended(obj)
11
+ # Tracepoint is used to trigger finalize once the command is completely
12
+ # loaded. If done through def self.inherited the finalizer and
13
+ # after_load callbacks would run before the options are defined.
14
+ TracePoint.trace(:end) do |t|
15
+ if obj == t.self
16
+ obj.finalize
17
+ t.disable
18
+ end
19
+ end
32
20
  end
33
21
 
34
- # Run all #after_load callbacks for this command.
35
- [name_parts.last, :all].compact.uniq.each do |cmd_type|
36
- [name_parts.first, :all].compact.uniq.each do |cmd_class|
37
- if Kontena::Callback.callbacks.fetch(cmd_class, {}).fetch(cmd_type, nil)
38
- Kontena::Callback.callbacks[cmd_class][cmd_type].each do |cb|
39
- if cb.instance_methods.include?(:after_load)
40
- cb.new(where).after_load
22
+ def finalize
23
+ return if self.has_subcommands?
24
+ return if self.callback_matcher
25
+
26
+ name_parts = self.name.split('::')[-2, 2]
27
+
28
+ unless name_parts.compact.empty?
29
+ # 1: Remove trailing 'Command' from for example AuthCommand
30
+ # 2: Convert the string from CamelCase to under_score
31
+ # 3: Convert the string into a symbol
32
+ #
33
+ # In comes: ['ExternalRegistry', 'UseCommand']
34
+ # Out goes: [:external_registry, :use]
35
+ name_parts = name_parts.map { |np|
36
+ np.gsub(/Command$/, '').
37
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
38
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
39
+ tr("-", "_").
40
+ downcase.
41
+ to_sym
42
+ }
43
+ self.callback_matcher(*name_parts)
44
+ end
45
+
46
+ # Run all #after_load callbacks for this command.
47
+ [name_parts.last, :all].compact.uniq.each do |cmd_type|
48
+ [name_parts.first, :all].compact.uniq.each do |cmd_class|
49
+ if Kontena::Callback.callbacks.fetch(cmd_class, {}).fetch(cmd_type, nil)
50
+ Kontena::Callback.callbacks[cmd_class][cmd_type].each do |cb|
51
+ if cb.instance_methods.include?(:after_load)
52
+ cb.new(self).after_load
53
+ end
41
54
  end
42
55
  end
43
56
  end
@@ -45,6 +58,10 @@ class Kontena::Command < Clamp::Command
45
58
  end
46
59
  end
47
60
 
61
+ def self.inherited(where)
62
+ where.extend Finalizer
63
+ end
64
+
48
65
  def self.callback_matcher(cmd_class = nil, cmd_type = nil)
49
66
  unless cmd_class
50
67
  if @command_class.nil?
@@ -59,7 +76,7 @@ class Kontena::Command < Clamp::Command
59
76
  end
60
77
 
61
78
  def run_callbacks(state)
62
- if self.class.respond_to?(:callback_matcher) && !self.class.callback_matcher.compact.empty?
79
+ if self.class.respond_to?(:callback_matcher) && !self.class.callback_matcher.nil? && !self.class.callback_matcher.compact.empty?
63
80
  Kontena::Callback.run_callbacks(self.class.callback_matcher, state, self)
64
81
  end
65
82
  end
@@ -146,7 +163,7 @@ class Kontena::Command < Clamp::Command
146
163
  end
147
164
 
148
165
  def run(arguments)
149
- ENV["DEBUG"] && puts("Running #{self} -- callback matcher = '#{self.class.callback_matcher.map(&:to_s).join(' ')}'")
166
+ ENV["DEBUG"] && puts("Running #{self} -- callback matcher = '#{self.class.callback_matcher.nil? ? "nil" : self.class.callback_matcher.map(&:to_s).join(' ')}'")
150
167
  @arguments = arguments
151
168
 
152
169
  run_callbacks :before_parse unless help_requested?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kontena-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0.pre3
4
+ version: 0.16.0.pre4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kontena, Inc
@@ -212,6 +212,7 @@ files:
212
212
  - lib/kontena/callbacks/auth/01_list_and_select_grid_after_master_auth.rb
213
213
  - lib/kontena/callbacks/master/01_clear_current_master_after_terminate.rb
214
214
  - lib/kontena/callbacks/master/deploy/01_show_logo_before_deploy.rb
215
+ - lib/kontena/callbacks/master/deploy/04_default_master_version.rb
215
216
  - lib/kontena/callbacks/master/deploy/05_before_deploy_configuration_wizard.rb
216
217
  - lib/kontena/callbacks/master/deploy/50_authenticate_after_deploy.rb
217
218
  - lib/kontena/callbacks/master/deploy/55_create_initial_grid_after_deploy.rb