brightbox-cli 2.8.2 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/lib/brightbox-cli/commands/token.rb +19 -0
- data/lib/brightbox-cli/token.rb +73 -0
- data/lib/brightbox-cli/version.rb +1 -1
- data/lib/brightbox_cli.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cedc167a85a17d8b2ff76e61a27f890649d9a2f94200ee45328caef421f23fb
|
4
|
+
data.tar.gz: c0c77936c9a1bd5d26fea97168bc12766a15acd3aebf2fdab0978ce6e165bda4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b20329ede04fa6a141f0a3a08569b56f5d70d97f4cd996d0e55184df2731efdcfbeba7bdb23b5d5e2955dda7c7ab84f4818d7ce0b3fe67924ff5ba57f8676acd
|
7
|
+
data.tar.gz: 31ea3f97b528dc93a188faf5c6160d978f8e95fdadfa4c6cfdc1c362f4db4dc75c3e7c5a75b94d29493b09fa26bfedecae41c810008286e49f98637a2481b8fb
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
### v2.9.0 /2018-08-24
|
2
|
+
|
3
|
+
[Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v2.8.2...v2.9.0)
|
4
|
+
|
5
|
+
Enhancements:
|
6
|
+
|
7
|
+
* Adds `brightbox token` command to read currently cached OAuth2 bearer tokens
|
8
|
+
|
1
9
|
### v2.8.2 /2018-08-21
|
2
10
|
|
3
11
|
[Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v2.8.1...v2.8.2)
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Brightbox
|
2
|
+
desc "Authentication token management"
|
3
|
+
command [:token] do |cmd|
|
4
|
+
cmd.default_command :show
|
5
|
+
|
6
|
+
cmd.desc "Show currently cached OAuth2 Bearer token"
|
7
|
+
cmd.command [:show] do |c|
|
8
|
+
c.desc "Either 'text', 'token', 'json' or 'curl'"
|
9
|
+
c.arg_name "format"
|
10
|
+
c.default_value "text"
|
11
|
+
c.flag [:format]
|
12
|
+
|
13
|
+
c.action do |global_options, options, args|
|
14
|
+
token = Token.show(Brightbox.config, options)
|
15
|
+
$stdout.puts token.format(options[:format])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require "json"
|
2
|
+
|
3
|
+
module Brightbox
|
4
|
+
class Token
|
5
|
+
def self.show(config, options)
|
6
|
+
new(config, options)
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_accessor :config, :options
|
10
|
+
|
11
|
+
def initialize(config, options = {})
|
12
|
+
@config = config
|
13
|
+
@options = options
|
14
|
+
end
|
15
|
+
|
16
|
+
def access_token
|
17
|
+
config.access_token
|
18
|
+
end
|
19
|
+
|
20
|
+
def format(output = :text)
|
21
|
+
output = output.to_sym
|
22
|
+
|
23
|
+
case output
|
24
|
+
when :curl
|
25
|
+
curl_output
|
26
|
+
when :json
|
27
|
+
json_output
|
28
|
+
when :token
|
29
|
+
token_output
|
30
|
+
else
|
31
|
+
text_output
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def refresh_token
|
36
|
+
config.refresh_token
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def api_url
|
42
|
+
base_url = URI(config.to_fog[:brightbox_api_url]).to_s
|
43
|
+
URI.join(base_url, "/1.0/").to_s
|
44
|
+
end
|
45
|
+
|
46
|
+
def curl_output
|
47
|
+
"curl - H 'Authorization: Bearer #{access_token}' #{api_url} "
|
48
|
+
end
|
49
|
+
|
50
|
+
def json_output
|
51
|
+
JSON.dump(token_data)
|
52
|
+
end
|
53
|
+
|
54
|
+
def text_output
|
55
|
+
token_data.map do |key, value|
|
56
|
+
"#{key.to_s.rjust(16)}: #{value}"
|
57
|
+
end.join("\n")
|
58
|
+
end
|
59
|
+
|
60
|
+
def token_data
|
61
|
+
data = {
|
62
|
+
access_token: access_token,
|
63
|
+
token_type: "Bearer"
|
64
|
+
}
|
65
|
+
data[:refresh_token] = refresh_token if refresh_token
|
66
|
+
data.sort.to_h
|
67
|
+
end
|
68
|
+
|
69
|
+
def token_output
|
70
|
+
access_token
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/lib/brightbox_cli.rb
CHANGED
@@ -56,6 +56,7 @@ module Brightbox
|
|
56
56
|
autoload :DatabaseType, File.expand_path("../brightbox-cli/database_type", __FILE__)
|
57
57
|
autoload :DatabaseServer, File.expand_path("../brightbox-cli/database_server", __FILE__)
|
58
58
|
autoload :DatabaseSnapshot, File.expand_path("../brightbox-cli/database_snapshot", __FILE__)
|
59
|
+
autoload :Token, File.expand_path("../brightbox-cli/token", __FILE__)
|
59
60
|
|
60
61
|
module Config
|
61
62
|
autoload :SectionNameDeduplicator, File.expand_path("../brightbox-cli/config/section_name_deduplicator", __FILE__)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brightbox-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Leach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-brightbox
|
@@ -330,6 +330,7 @@ files:
|
|
330
330
|
- lib/brightbox-cli/commands/sql/snapshots_show.rb
|
331
331
|
- lib/brightbox-cli/commands/sql/snapshots_update.rb
|
332
332
|
- lib/brightbox-cli/commands/sql/types.rb
|
333
|
+
- lib/brightbox-cli/commands/token.rb
|
333
334
|
- lib/brightbox-cli/commands/types.rb
|
334
335
|
- lib/brightbox-cli/commands/user-collaborations.rb
|
335
336
|
- lib/brightbox-cli/commands/users/list.rb
|
@@ -368,6 +369,7 @@ files:
|
|
368
369
|
- lib/brightbox-cli/server_groups.rb
|
369
370
|
- lib/brightbox-cli/servers.rb
|
370
371
|
- lib/brightbox-cli/tables.rb
|
372
|
+
- lib/brightbox-cli/token.rb
|
371
373
|
- lib/brightbox-cli/types.rb
|
372
374
|
- lib/brightbox-cli/user_collaboration.rb
|
373
375
|
- lib/brightbox-cli/users.rb
|