brightbox-cli 4.1.0 → 4.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc36c35cb32073368b55abc445d0720ce2e635336e1c3b8af4ef9e1dcedc0000
4
- data.tar.gz: '0351935cba15d3c1503c1e8c44d7d4f5258d3d07f67700d363a5b043e58e287e'
3
+ metadata.gz: b24f4292c151b1a916960e8a251c3928468ac915ee5f1fe139e8ef3a4d1e0a82
4
+ data.tar.gz: f7da261677380fd05cf1e4c3f73021db46c0b24b7da36a8e3820928ca96cfbe4
5
5
  SHA512:
6
- metadata.gz: e230034d8c611139a5ed70b1508f1aef3ff3dd263e8f8f53acd58aad72c0616bdcfd5c44ae267e1fa27be66c7958e25e7de986f9169e29c484a47f4b5ceb1e0b
7
- data.tar.gz: c4672a3f3efcb30390a6fb536d2542c36988fbb1ba82b5fa59d6dfa1f58868d5518e36ac48f54d9987294b0de46531f0c9b8cb383d21817631a0436008d3e825
6
+ metadata.gz: e8eed506ef89c92c2f85d0567fb3e1c8910c3705a209330025d2443ead0fc237bc210d9a5867d9dc92b8331ba9d10d03992640307fcdf5e00575f815af1a8984
7
+ data.tar.gz: 49ae72e6347419f04bdb4c2190a0dc7ca2dc5066eda0c831adfe80cf4cec7483be83a3b6feabb1de837827dc97bbe5e0cd891874875e19115a30a523ed9ac3b9
data/CHANGELOG.md CHANGED
@@ -1,10 +1,33 @@
1
+ ### v4.2.1 / 2022-11-16
2
+
3
+ [Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v4.2.0...v4.2.1)
4
+
5
+ Bug fixes:
6
+
7
+ * Bumped version of `highline` gem to fix issue when prompting for password during `brightbox login` command on Ruby 3.0+.
8
+ * Fixed help output for `brightbox login` by correcting DSL declaration.
9
+
10
+ ### v4.2.0 / 2022-11-01
11
+
12
+ [Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v4.1.0...v4.2.0)
13
+
14
+ Changes:
15
+
16
+ * Adds three new, mutually exclusive options to `images create` to specify
17
+ different sources:
18
+ * `url` can specify source as a URL for a HTTP or HTTPS download rather than
19
+ an existing FTP upload.
20
+ * `server` can specify a server ID to create a snapshot image from.
21
+ * `volume` can specify a volume ID to create a snapshot image from.
22
+
1
23
  ### v4.1.0 / 2022-08-01
2
24
 
3
25
  [Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v4.0.0...v4.1.0)
4
26
 
5
27
  Changes:
6
28
 
7
- * Add `volume-size` to `servers create` to allow passing of arbitary sizes for network based storage types.
29
+ * Adds `volume-size` to `servers create` to allow passing of arbitrary sizes for
30
+ network based storage types.
8
31
 
9
32
  ### v4.0.0 / 2022-08-01
10
33
 
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brightbox-cli (4.1.0)
4
+ brightbox-cli (4.2.1)
5
5
  dry-inflector (= 0.2.0)
6
6
  fog-brightbox (>= 1.8.0)
7
7
  fog-core (< 2.0)
8
8
  gli (~> 2.21)
9
- highline (~> 1.6)
9
+ highline (~> 2.0)
10
10
  hirb (~> 0.6)
11
11
  i18n (>= 0.6, < 1.11)
12
12
  mime-types (~> 3.0)
@@ -25,7 +25,7 @@ GEM
25
25
  rexml
26
26
  diff-lcs (1.5.0)
27
27
  dry-inflector (0.2.0)
28
- excon (0.92.4)
28
+ excon (0.94.0)
29
29
  fog-brightbox (1.8.0)
30
30
  dry-inflector
31
31
  fog-core (>= 1.45, < 3.0)
@@ -40,7 +40,7 @@ GEM
40
40
  formatador (0.3.0)
41
41
  gli (2.21.0)
42
42
  hashdiff (1.0.1)
43
- highline (1.7.10)
43
+ highline (2.0.3)
44
44
  hirb (0.7.3)
45
45
  i18n (1.10.0)
46
46
  concurrent-ruby (~> 1.0)
@@ -117,4 +117,4 @@ DEPENDENCIES
117
117
  webmock
118
118
 
119
119
  BUNDLED WITH
120
- 2.1.4
120
+ 2.2.33
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency "fog-brightbox", ">= 1.8.0"
25
25
  s.add_dependency "fog-core", "< 2.0"
26
26
  s.add_dependency "gli", "~> 2.21"
27
- s.add_dependency "highline", "~> 1.6"
27
+ s.add_dependency "highline", "~> 2.0"
28
28
  s.add_dependency "hirb", "~> 0.6"
29
29
  s.add_dependency "i18n", ">= 0.6", "< 1.11"
30
30
  s.add_dependency "mime-types", "~> 3.0"
@@ -11,17 +11,26 @@ module Brightbox
11
11
  c.desc "Image Username"
12
12
  c.flag [:u, "username"]
13
13
 
14
- c.desc "Archtecture of the image (i686 or x86_64)"
14
+ c.desc "Architecture of the image (i686 or x86_64)"
15
15
  c.flag [:a, "arch"]
16
16
 
17
17
  c.desc "Source filename of the image you uploaded to the image library"
18
18
  c.flag [:s, "source"]
19
19
 
20
+ c.desc "Source server ID to create image from"
21
+ c.flag ["server"]
22
+
23
+ c.desc "Source URL of the image to download via HTTP"
24
+ c.flag ["url"]
25
+
26
+ c.desc "Source volume ID to create image from"
27
+ c.flag ["volume"]
28
+
20
29
  c.desc "Set image mode to be either 'virtio' or 'compatibility'"
21
30
  c.default_value "virtio"
22
31
  c.flag [:m, "mode"]
23
32
 
24
- c.desc "Set image to be publically visible (true or false)"
33
+ c.desc "Set image to be publicly visible (true or false)"
25
34
  c.default_value "false"
26
35
  c.flag [:p, "public"]
27
36
 
@@ -30,22 +39,38 @@ module Brightbox
30
39
 
31
40
  c.action do |global_options, options, _args|
32
41
  raise "You must specify the architecture" unless options[:a]
33
- raise "You must specify the source filename" unless options[:s]
34
42
  raise "Mode must be 'virtio' or 'compatibility'" unless options[:m] == "virtio" || options[:m] == "compatibility"
35
43
  raise "Public must be true or false" unless options[:p] == "true" || options[:p] == "false"
36
44
 
45
+ # Sources are mutually exclusive but at least one is required from this list
46
+ source_options = [:s, :server, :url, :volume].map { |k| options[k] }
47
+
48
+ if source_options.none?
49
+ raise "You must specify one of 'server', 'source', 'url', or 'volume'"
50
+ elsif !source_options.one?
51
+ raise "You cannot register from multiple sources. Use either 'source', 'server', 'url', or 'volume'"
52
+ end
53
+
37
54
  compatibility_flag = options[:m] == "compatibility"
38
55
 
39
56
  public_flag = options[:p] == "true"
40
57
 
41
58
  image_options = {
42
- :name => options[:n], :arch => options[:a],
43
- :username => options[:u], :source => options[:s],
59
+ :arch => options[:a],
44
60
  :compatibility_mode => compatibility_flag,
45
- :description => options[:d], :public => public_flag,
46
- :min_ram => options["min-ram"].to_i
61
+ :description => options[:d],
62
+ :min_ram => options["min-ram"].to_i,
63
+ :name => options[:n],
64
+ :public => public_flag,
65
+ :username => options[:u]
47
66
  }
48
67
 
68
+ # These should be limited to one by the mutually exclusive check earlier
69
+ image_options[:http_url] = options[:url] if options[:url]
70
+ image_options[:server] = options[:server] if options[:server]
71
+ image_options[:source] = options[:s] if options[:s]
72
+ image_options[:volume] = options[:volume] if options[:volume]
73
+
49
74
  image = Image.register(image_options)
50
75
 
51
76
  render_table([image], global_options)
@@ -1,13 +1,12 @@
1
1
  module Brightbox
2
+ desc I18n.t("login.desc")
3
+ arg :email
2
4
  command [:login] do |cmd|
3
- cmd.desc I18n.t("login.desc")
4
- cmd.arg_name "email"
5
-
6
5
  cmd.desc "password, if not specified you will be prompted"
7
- cmd.flag [:p, "password"]
6
+ cmd.flag [:p, "password"], arg_name: "password"
8
7
 
9
- cmd.desc "default account"
10
- cmd.flag [:"default-account"]
8
+ cmd.desc "Set a default account"
9
+ cmd.flag [:"default-account"], arg_name: "acc-12345"
11
10
 
12
11
  cmd.flag [:"application-id"]
13
12
  cmd.flag [:"application-secret"]
@@ -1,3 +1,3 @@
1
1
  module Brightbox
2
- VERSION = "4.1.0".freeze unless defined?(Brightbox::VERSION)
2
+ VERSION = "4.2.1".freeze unless defined?(Brightbox::VERSION)
3
3
  end
data/locales/en.yml CHANGED
@@ -136,6 +136,8 @@ en:
136
136
  update:
137
137
  desc: Update a load balancer
138
138
  long_desc: All intervals and timeouts are in milliseconds
139
+ login:
140
+ desc: Authenticate using an email address
139
141
  servers:
140
142
  desc: Manage an account's servers
141
143
  activate_console:
@@ -23,7 +23,67 @@ describe "brightbox images" do
23
23
  end
24
24
  end
25
25
 
26
- context "with minimal arguments" do
26
+ context "without any source" do
27
+ let(:argv) { %w[images register --arch x86_64] }
28
+
29
+ it "does not error" do
30
+ expect { output }.to_not raise_error
31
+
32
+ expect(stderr).to match("ERROR: You must specify one of 'server', 'source', 'url', or 'volume'")
33
+ expect(stdout).to match("")
34
+ end
35
+ end
36
+
37
+ context "with mutually exclusive arguments" do
38
+ let(:argv) { %w[images register --arch x86_64 --source test.img --url http://example.com/test.img] }
39
+
40
+ it "does not error" do
41
+ expect { output }.to_not raise_error
42
+
43
+ expect(stderr).to match("ERROR: You cannot register from multiple sources. Use either 'source', 'server', 'url', or 'volume'")
44
+ expect(stdout).to match("")
45
+ end
46
+ end
47
+
48
+ context "with 'server' argument" do
49
+ let(:argv) { %w[images register --arch x86_64 --server srv-12345] }
50
+
51
+ before do
52
+ expect(Brightbox::Image).to receive(:register)
53
+ .with(hash_including(
54
+ arch: "x86_64",
55
+ server: "srv-12345"
56
+ ))
57
+ .and_call_original
58
+
59
+ stub_request(:post, "#{api_url}/1.0/images?account_id=acc-12345")
60
+ .with(body: /"server":"srv-12345"/)
61
+ .to_return(
62
+ status: 201,
63
+ body: {
64
+ id: "img-12345"
65
+ }.to_json
66
+ )
67
+
68
+ stub_request(:get, "#{api_url}/1.0/images/img-12345?account_id=acc-12345")
69
+ .to_return(
70
+ status: 200,
71
+ body: {
72
+ id: "img-12345"
73
+ }.to_json
74
+ )
75
+ end
76
+
77
+ it "does not error" do
78
+ expect { output }.to_not raise_error
79
+
80
+ expect(stderr).to match("")
81
+ expect(stderr).not_to match("ERROR")
82
+ expect(stdout).to match("img-12345")
83
+ end
84
+ end
85
+
86
+ context "with 'source' argument" do
27
87
  let(:argv) { %w[images register --arch x86_64 --source custom.img] }
28
88
 
29
89
  before do
@@ -61,6 +121,82 @@ describe "brightbox images" do
61
121
  end
62
122
  end
63
123
 
124
+ context "with 'url' argument" do
125
+ let(:argv) { %w[images register --arch x86_64 --url https://example.com/os-22.iso] }
126
+
127
+ before do
128
+ expect(Brightbox::Image).to receive(:register)
129
+ .with(hash_including(
130
+ arch: "x86_64",
131
+ http_url: "https://example.com/os-22.iso"
132
+ ))
133
+ .and_call_original
134
+
135
+ stub_request(:post, "#{api_url}/1.0/images?account_id=acc-12345")
136
+ .with(body: %r{"http_url":"https://example.com/os-22.iso"})
137
+ .to_return(
138
+ status: 201,
139
+ body: {
140
+ id: "img-12345"
141
+ }.to_json
142
+ )
143
+
144
+ stub_request(:get, "#{api_url}/1.0/images/img-12345?account_id=acc-12345")
145
+ .to_return(
146
+ status: 200,
147
+ body: {
148
+ id: "img-12345"
149
+ }.to_json
150
+ )
151
+ end
152
+
153
+ it "does not error" do
154
+ expect { output }.to_not raise_error
155
+
156
+ expect(stderr).to match("")
157
+ expect(stderr).not_to match("ERROR")
158
+ expect(stdout).to match("img-12345")
159
+ end
160
+ end
161
+
162
+ context "with 'volume' argument" do
163
+ let(:argv) { %w[images register --arch x86_64 --volume vol-12345] }
164
+
165
+ before do
166
+ expect(Brightbox::Image).to receive(:register)
167
+ .with(hash_including(
168
+ arch: "x86_64",
169
+ volume: "vol-12345"
170
+ ))
171
+ .and_call_original
172
+
173
+ stub_request(:post, "#{api_url}/1.0/images?account_id=acc-12345")
174
+ .with(body: /"volume":"vol-12345"/)
175
+ .to_return(
176
+ status: 201,
177
+ body: {
178
+ id: "img-12345"
179
+ }.to_json
180
+ )
181
+
182
+ stub_request(:get, "#{api_url}/1.0/images/img-12345?account_id=acc-12345")
183
+ .to_return(
184
+ status: 200,
185
+ body: {
186
+ id: "img-12345"
187
+ }.to_json
188
+ )
189
+ end
190
+
191
+ it "does not error" do
192
+ expect { output }.to_not raise_error
193
+
194
+ expect(stderr).to match("")
195
+ expect(stderr).not_to match("ERROR")
196
+ expect(stdout).to match("img-12345")
197
+ end
198
+ end
199
+
64
200
  context "with min-ram argument" do
65
201
  let(:argv) { %w[images register --arch x86_64 --source custom.img --min-ram 2048] }
66
202
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brightbox-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Leach
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-08-31 00:00:00.000000000 Z
12
+ date: 1980-01-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog-brightbox
@@ -59,14 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '1.6'
62
+ version: '2.0'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '1.6'
69
+ version: '2.0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: hirb
72
72
  requirement: !ruby/object:Gem::Requirement