kontena-cli 0.16.0.pre1 → 0.16.0.pre2
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/lib/kontena/callbacks/master/deploy/05_before_deploy_configuration_wizard.rb +21 -37
- data/lib/kontena/callbacks/master/deploy/60_configure_auth_provider_after_deploy.rb +1 -3
- data/lib/kontena/cli/cloud/login_command.rb +8 -6
- data/lib/kontena/cli/master/config/import_command.rb +2 -2
- data/lib/kontena/cli/master/login_command.rb +4 -2
- data/lib/kontena/cli/master/use_command.rb +2 -1
- data/lib/kontena/presets/kontena_auth_provider.yml +1 -1
- data/lib/kontena_cli.rb +3 -0
- data/spec/kontena/cli/master/use_command_spec.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dc5728b1347004899b102ebd4866c211042e5a0
|
4
|
+
data.tar.gz: 9db1ef29e2fc497e4714601c853fa05e8a348b7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6e669442d78dd7bed60f5946f45827f974db78c57f27a8c5d7443d6af316b816f3fd4d1a64bf5f53231964cdd1b3e5390d2c196381195d2bf383d2d10eecfa2
|
7
|
+
data.tar.gz: f965ff386e19547fafec5949b224eaaf3c8231a679232f8969ad3629922853eec714d4d6c760328caa00e0472cf720484210bc4dcc6a56ef12dde06038596911
|
data/Dockerfile
CHANGED
@@ -5,7 +5,7 @@ ADD https://get.docker.com/builds/Linux/x86_64/docker-1.10.3 /usr/local/bin/dock
|
|
5
5
|
ARG CLI_VERSION
|
6
6
|
|
7
7
|
RUN apk update && \
|
8
|
-
apk --update add ruby ruby-json ruby-bigdecimal \
|
8
|
+
apk --update add ruby ruby-json ruby-bigdecimal ruby-io-console \
|
9
9
|
ca-certificates libssl1.0 openssl libstdc++ && \
|
10
10
|
gem install kontena-cli --no-rdoc --no-ri -v ${CLI_VERSION} && \
|
11
11
|
adduser kontena -D -h /home/kontena -s /bin/sh && \
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.16.0.
|
1
|
+
0.16.0.pre2
|
@@ -23,8 +23,8 @@ module Kontena
|
|
23
23
|
# Scans config server names and returns default-2 if default exists,
|
24
24
|
# default-3 if default-2 exists, etc.
|
25
25
|
def next_default_name
|
26
|
-
last_default = config.servers.map(&:name).select{ |n| n =~ /
|
27
|
-
return "
|
26
|
+
last_default = config.servers.map(&:name).select{ |n| n =~ /kontena\-master(?:\-\d+)?$/ }.sort.last
|
27
|
+
return "kontena-master" unless last_default
|
28
28
|
unless last_default =~ /\d$/
|
29
29
|
last_default << "-1"
|
30
30
|
end
|
@@ -42,33 +42,13 @@ module Kontena
|
|
42
42
|
cloud_client.authentication_ok?(kontena_account.userinfo_endpoint)
|
43
43
|
end
|
44
44
|
|
45
|
-
def select_cloud_master
|
46
|
-
masters = []
|
47
|
-
spinner "Retrieving a list of registered masters on your Kontena Cloud account" do
|
48
|
-
masters = cloud_client.get("user/masters")["data"]
|
49
|
-
end
|
50
|
-
if masters.empty?
|
51
|
-
puts
|
52
|
-
puts "You have no registered masters. Adding a new master."
|
53
|
-
puts
|
54
|
-
return create_cloud_master
|
55
|
-
else
|
56
|
-
puts
|
57
|
-
return prompt.select("Select master") do |menu|
|
58
|
-
masters.each do |master|
|
59
|
-
name = master['attributes']['name']
|
60
|
-
url = master['attributes']['url']
|
61
|
-
master_id = master['id']
|
62
|
-
menu.choice "#{master['attributes']['name']} (#{url.nil? ? "setup not done" : url})", master_id
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
45
|
def create_cloud_master
|
69
46
|
master_id = nil
|
70
|
-
|
71
|
-
|
47
|
+
begin
|
48
|
+
spinner "Registering a new master '#{command.name}' to Kontena Cloud" do
|
49
|
+
master_id = Kontena.run("cloud master add --return #{command.name}", returning: :result)
|
50
|
+
end
|
51
|
+
rescue SystemExit
|
72
52
|
end
|
73
53
|
if master_id.to_s =~ /^[0-9a-f]{16,32}$/
|
74
54
|
master_id
|
@@ -92,30 +72,34 @@ module Kontena
|
|
92
72
|
if command.no_prompt?
|
93
73
|
command.cloud_master_id ||= create_cloud_master
|
94
74
|
elsif command.cloud_master_id.nil?
|
95
|
-
answer = prompt.select("Select
|
96
|
-
menu.choice 'Kontena Cloud (
|
97
|
-
menu.choice 'Kontena Cloud (use an existing master)', :kontena_existing
|
75
|
+
answer = prompt.select("Select OAuth2 authentication provider: ") do |menu|
|
76
|
+
menu.choice 'Kontena Cloud (recommended)', :kontena_new
|
98
77
|
menu.choice 'Custom', :custom
|
99
78
|
menu.choice 'None (single user mode)', :none
|
100
79
|
end
|
101
80
|
case answer
|
102
|
-
when :kontena_new
|
81
|
+
when :kontena_new
|
103
82
|
login_to_kontena || abort('You must login to Kontena Cloud')
|
104
|
-
|
105
|
-
|
106
|
-
else
|
107
|
-
command.cloud_master_id = select_cloud_master
|
108
|
-
end
|
83
|
+
command.cloud_master_id = create_cloud_master
|
84
|
+
command.skip_auth_provider = false
|
109
85
|
when :custom
|
86
|
+
puts
|
110
87
|
puts 'Learn how to configure custom user authentication provider after installation at: www.kontena.io/docs/configuring-custom-auth-provider'
|
88
|
+
puts
|
89
|
+
command.cloud_master_id = nil
|
90
|
+
command.skip_auth_provider = true
|
111
91
|
when :none
|
92
|
+
puts
|
112
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"
|
94
|
+
puts
|
95
|
+
command.cloud_master_id = nil
|
96
|
+
command.skip_auth_provider = true
|
113
97
|
else
|
114
98
|
abort 'Should never be here'
|
115
99
|
end
|
116
100
|
end
|
117
|
-
command.skip_auth_provider = !command.cloud_master_id.nil?
|
118
101
|
end
|
102
|
+
true
|
119
103
|
end
|
120
104
|
end
|
121
105
|
end
|
@@ -18,10 +18,8 @@ module Kontena
|
|
18
18
|
|
19
19
|
def configure_auth_provider(oauth_config)
|
20
20
|
require 'shellwords'
|
21
|
-
spinner "Setting Kontena Cloud authentication provider
|
21
|
+
spinner "Setting Kontena Cloud authentication provider settings to Master config" do
|
22
22
|
Kontena.run("master config import --force --preset kontena_auth_provider")
|
23
|
-
end
|
24
|
-
spinner "Setting Kontena Cloud authentication provider consumer credentials to Master config" do
|
25
23
|
Kontena.run("master config set oauth2.client_id=#{oauth_config['client-id'].shellescape} oauth2.client_secret=#{oauth_config['client-secret'].shellescape} server.root_url=#{config.current_master.url.shellescape}")
|
26
24
|
end
|
27
25
|
end
|
@@ -67,11 +67,11 @@ module Kontena::Cli::Cloud
|
|
67
67
|
uri.query = URI.encode_www_form(params)
|
68
68
|
|
69
69
|
puts "Opening a browser to #{uri.scheme}://#{uri.host}"
|
70
|
-
puts
|
71
|
-
puts "If you are running this command over an ssh connection or it's"
|
72
|
-
puts "otherwise not possible to open a browser from this terminal"
|
73
|
-
puts "then you must use a pregenerated access token using the --token"
|
74
|
-
puts "option : kontena cloud login --token <access_token>"
|
70
|
+
#puts
|
71
|
+
#puts "If you are running this command over an ssh connection or it's"
|
72
|
+
#puts "otherwise not possible to open a browser from this terminal"
|
73
|
+
#puts "then you must use a pregenerated access token using the --token"
|
74
|
+
#puts "option : kontena cloud login --token <access_token>"
|
75
75
|
puts
|
76
76
|
puts "Once the authentication is complete you can close the browser"
|
77
77
|
puts "window or tab and return to this window to continue."
|
@@ -85,7 +85,9 @@ module Kontena::Cli::Cloud
|
|
85
85
|
server_thread = Thread.new { Thread.main['response'] = web_server.serve_one }
|
86
86
|
browser_thread = Thread.new { Launchy.open(uri.to_s) }
|
87
87
|
|
88
|
-
|
88
|
+
vspinner "Waiting for browser authorization response" do
|
89
|
+
server_thread.join
|
90
|
+
end
|
89
91
|
browser_thread.join
|
90
92
|
|
91
93
|
response = Thread.main['response']
|
@@ -10,9 +10,9 @@ module Kontena::Cli::Master::Config
|
|
10
10
|
|
11
11
|
parameter '[PATH]', "Input from file in PATH, default: STDIN", required: false
|
12
12
|
|
13
|
-
option ['--preset'], '[NAME]', 'Load preset'
|
13
|
+
option ['--preset'], '[NAME]', 'Load preset', hidden: true
|
14
14
|
|
15
|
-
option ['--format'], '[FORMAT]', "Specify
|
15
|
+
option ['--format'], '[FORMAT]', "Specify input format (json, yaml) (default: guess from PATH or json)"
|
16
16
|
option ['--full'], :flag, "Perform full update, keys that are not present in the input are cleared"
|
17
17
|
option ['-f', '--force'], :flag, "Don't ask for confirmation"
|
18
18
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
#TODO: Something wrong with picking up wrong server in config using the url,
|
2
|
+
#maybe remove that part altogether.
|
1
3
|
require 'uri'
|
2
4
|
|
3
5
|
module Kontena::Cli::Master
|
@@ -92,8 +94,8 @@ module Kontena::Cli::Master
|
|
92
94
|
end
|
93
95
|
|
94
96
|
def find_server_or_create_new(url)
|
95
|
-
existing_server = config.find_server_by(url: url)
|
96
|
-
if existing_server
|
97
|
+
existing_server = config.find_server_by(url: url, name: self.name)
|
98
|
+
if existing_server
|
97
99
|
config.current_server = existing_server.name
|
98
100
|
existing_server
|
99
101
|
else
|
@@ -10,7 +10,8 @@ module Kontena::Cli::Master
|
|
10
10
|
abort pastel.red("Could not resolve master by name '#{name}'.") +
|
11
11
|
"\nFor a list of known masters please run: kontena master list"
|
12
12
|
else
|
13
|
-
|
13
|
+
config.current_master = master['name']
|
14
|
+
config.write
|
14
15
|
puts "Using master: #{pastel.cyan(master['name'])} (#{master['url']})"
|
15
16
|
puts "Using grid: #{current_grid ? pastel.cyan(current_grid) : "<none>"}"
|
16
17
|
end
|
@@ -4,7 +4,7 @@ oauth2.code_requires_basic_auth: false
|
|
4
4
|
oauth2.token_endpoint: https://auth2.kontena.io/v1/oauth2/token
|
5
5
|
oauth2.token_method: post
|
6
6
|
oauth2.token_post_content_type: application/x-www-form-urlencoded
|
7
|
-
oauth2.userinfo_endpoint: https://
|
7
|
+
oauth2.userinfo_endpoint: https://cloud-api.kontena.io/user
|
8
8
|
oauth2.userinfo_username_jsonpath: "$..username"
|
9
9
|
oauth2.userinfo_email_jsonpath: "$..email"
|
10
10
|
oauth2.userinfo_user_id_jsonpath: "$..id"
|
data/lib/kontena_cli.rb
CHANGED
@@ -8,10 +8,13 @@ module Kontena
|
|
8
8
|
# @return [Fixnum] exit_code
|
9
9
|
def self.run(cmdline = "", returning: :status)
|
10
10
|
require 'shellwords'
|
11
|
+
ENV["DEBUG"] && puts("Running Kontena.run(#{cmdline.inspect}, returning: #{returning}")
|
11
12
|
result = Kontena::MainCommand.new(File.basename(__FILE__)).run(cmdline.shellsplit)
|
13
|
+
ENV["DEBUG"] && puts("Command completed, result: #{result.inspect} status: 0")
|
12
14
|
return 0 if returning == :status
|
13
15
|
return result if returning == :result
|
14
16
|
rescue SystemExit
|
17
|
+
ENV["DEBUG"] && puts("Command completed with failure, result: #{result.inspect} status: #{$!.status}")
|
15
18
|
returning == :status ? $!.status : nil
|
16
19
|
end
|
17
20
|
|
@@ -11,8 +11,9 @@ describe Kontena::Cli::Master::UseCommand do
|
|
11
11
|
|
12
12
|
describe '#use' do
|
13
13
|
it 'should update current master' do
|
14
|
-
expect(subject).to receive(:
|
14
|
+
expect(subject.config).to receive(:write).and_return(true)
|
15
15
|
subject.run(['some_master'])
|
16
|
+
expect(subject.config.current_server).to eq 'some_master'
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|