brightbox-cli 4.0.0 → 4.1.0

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
  SHA256:
3
- metadata.gz: cf8d230d121ac70d4971ed2acf19776ed75bac9256d4f4ea7d980af8e563350a
4
- data.tar.gz: feb53ae71fe302c76fcbe2f6b4e1e67723b64d706266ed3db5531195df9ec167
3
+ metadata.gz: fc36c35cb32073368b55abc445d0720ce2e635336e1c3b8af4ef9e1dcedc0000
4
+ data.tar.gz: '0351935cba15d3c1503c1e8c44d7d4f5258d3d07f67700d363a5b043e58e287e'
5
5
  SHA512:
6
- metadata.gz: c5325d637d559f620a9b5a4cff4157aa67f6da2a802329c59d81270a429958afbf5e7d9f982d59d99786f099931b64bd1f50feedd123e6221371580234ac8986
7
- data.tar.gz: 97431207227f81834213a4ab61c6d77d78f526ba4ec1a1885975c4169299cb4f88c323197984391ffed000feee9523b0a4aabbc7075fc15fe8389943400cb8d9
6
+ metadata.gz: e230034d8c611139a5ed70b1508f1aef3ff3dd263e8f8f53acd58aad72c0616bdcfd5c44ae267e1fa27be66c7958e25e7de986f9169e29c484a47f4b5ceb1e0b
7
+ data.tar.gz: c4672a3f3efcb30390a6fb536d2542c36988fbb1ba82b5fa59d6dfa1f58868d5518e36ac48f54d9987294b0de46531f0c9b8cb383d21817631a0436008d3e825
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### v4.1.0 / 2022-08-01
2
+
3
+ [Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v4.0.0...v4.1.0)
4
+
5
+ Changes:
6
+
7
+ * Add `volume-size` to `servers create` to allow passing of arbitary sizes for network based storage types.
8
+
1
9
  ### v4.0.0 / 2022-08-01
2
10
 
3
11
  [Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v3.3.0...v4.0.0)
data/Gemfile.lock CHANGED
@@ -1,16 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brightbox-cli (4.0.0)
4
+ brightbox-cli (4.1.0)
5
5
  dry-inflector (= 0.2.0)
6
- fog-brightbox (>= 1.7.0)
6
+ fog-brightbox (>= 1.8.0)
7
7
  fog-core (< 2.0)
8
- gli (~> 2.21.0)
9
- highline (~> 1.6.0)
8
+ gli (~> 2.21)
9
+ highline (~> 1.6)
10
10
  hirb (~> 0.6)
11
11
  i18n (>= 0.6, < 1.11)
12
- mime-types (~> 2.6)
13
- multi_json (~> 1.11.0)
12
+ mime-types (~> 3.0)
13
+ multi_json (~> 1.11)
14
14
 
15
15
  GEM
16
16
  remote: https://rubygems.org/
@@ -26,7 +26,7 @@ GEM
26
26
  diff-lcs (1.5.0)
27
27
  dry-inflector (0.2.0)
28
28
  excon (0.92.4)
29
- fog-brightbox (1.7.0)
29
+ fog-brightbox (1.8.0)
30
30
  dry-inflector
31
31
  fog-core (>= 1.45, < 3.0)
32
32
  fog-json
@@ -40,14 +40,16 @@ GEM
40
40
  formatador (0.3.0)
41
41
  gli (2.21.0)
42
42
  hashdiff (1.0.1)
43
- highline (1.6.21)
43
+ highline (1.7.10)
44
44
  hirb (0.7.3)
45
45
  i18n (1.10.0)
46
46
  concurrent-ruby (~> 1.0)
47
47
  method_source (1.0.0)
48
- mime-types (2.99.3)
48
+ mime-types (3.4.1)
49
+ mime-types-data (~> 3.2015)
50
+ mime-types-data (3.2022.0105)
49
51
  mocha (1.14.0)
50
- multi_json (1.11.3)
52
+ multi_json (1.15.0)
51
53
  parallel (1.22.1)
52
54
  parser (3.1.2.0)
53
55
  ast (~> 2.4.1)
data/Jenkinsfile CHANGED
@@ -9,54 +9,34 @@ pipeline {
9
9
  stages {
10
10
  stage("Run tests") {
11
11
  parallel {
12
- stage("Ruby 2.0") {
13
- agent {
14
- docker {
15
- image 'ruby:2.0'
16
- }
17
- }
18
- steps {
19
- sh 'bundle install --deployment'
20
- sh 'bundle exec rake spec'
21
- }
22
- }
23
- stage("Ruby 2.1") {
24
- agent {
25
- docker {
26
- image 'ruby:2.1'
27
- }
28
- }
29
- steps {
30
- sh 'bundle install --deployment'
31
- sh 'bundle exec rake spec'
32
- }
33
- }
34
- stage("Ruby 2.2") {
12
+ stage("Ruby 2.5") {
35
13
  agent {
36
14
  docker {
37
- image 'ruby:2.2'
15
+ image 'ruby:2.5'
38
16
  }
39
17
  }
40
18
  steps {
19
+ sh 'gem install bundler:2.1.4'
41
20
  sh 'bundle install --deployment'
42
21
  sh 'bundle exec rake spec'
43
22
  }
44
23
  }
45
- stage("Ruby 2.3") {
24
+ stage("Ruby 2.6") {
46
25
  agent {
47
26
  docker {
48
- image 'ruby:2.3'
27
+ image 'ruby:2.6'
49
28
  }
50
29
  }
51
30
  steps {
31
+ sh 'gem install bundler:2.1.4'
52
32
  sh 'bundle install --deployment'
53
33
  sh 'bundle exec rake spec'
54
34
  }
55
35
  }
56
- stage("Ruby 2.4") {
36
+ stage("Ruby 2.7") {
57
37
  agent {
58
38
  docker {
59
- image 'ruby:2.4'
39
+ image 'ruby:2.7'
60
40
  }
61
41
  }
62
42
  steps {
@@ -64,10 +44,10 @@ pipeline {
64
44
  sh 'bundle exec rake spec'
65
45
  }
66
46
  }
67
- stage("Ruby 2.5") {
47
+ stage("Ruby 3.0") {
68
48
  agent {
69
49
  docker {
70
- image 'ruby:2.5'
50
+ image 'ruby:3.0'
71
51
  }
72
52
  }
73
53
  steps {
@@ -75,10 +55,10 @@ pipeline {
75
55
  sh 'bundle exec rake spec'
76
56
  }
77
57
  }
78
- stage("Ruby 2.6") {
58
+ stage("Ruby 3.1") {
79
59
  agent {
80
60
  docker {
81
- image 'ruby:2.6'
61
+ image 'ruby:3.1'
82
62
  }
83
63
  }
84
64
  steps {
@@ -21,14 +21,14 @@ Gem::Specification.new do |s|
21
21
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
22
22
  s.require_paths = ["lib"]
23
23
 
24
- s.add_dependency "fog-brightbox", ">= 1.7.0"
24
+ s.add_dependency "fog-brightbox", ">= 1.8.0"
25
25
  s.add_dependency "fog-core", "< 2.0"
26
- s.add_dependency "gli", "~> 2.21.0"
27
- s.add_dependency "highline", "~> 1.6.0"
26
+ s.add_dependency "gli", "~> 2.21"
27
+ s.add_dependency "highline", "~> 1.6"
28
28
  s.add_dependency "hirb", "~> 0.6"
29
29
  s.add_dependency "i18n", ">= 0.6", "< 1.11"
30
- s.add_dependency "mime-types", "~> 2.6"
31
- s.add_dependency "multi_json", "~> 1.11.0"
30
+ s.add_dependency "mime-types", "~> 3.0"
31
+ s.add_dependency "multi_json", "~> 1.11"
32
32
 
33
33
  # Indirect dependency
34
34
  # 0.3 drops support for Ruby < 2.7
@@ -37,6 +37,9 @@ module Brightbox
37
37
  c.desc I18n.t("servers.create.cloud_ip.desc")
38
38
  c.flag ["cloud-ip"]
39
39
 
40
+ c.desc I18n.t("servers.create.volume_size.desc")
41
+ c.flag ["volume-size"]
42
+
40
43
  c.action do |global_options, options, args|
41
44
  if args.empty?
42
45
  raise "You must specify the image_id as the first argument"
@@ -114,13 +117,17 @@ module Brightbox
114
117
  :flavor_id => type.id,
115
118
  :zone_id => zone.to_s,
116
119
  :name => options[:n],
117
- :user_data => user_data,
118
- :server_groups => server_groups.map(&:id)
120
+ :user_data => user_data
119
121
  }
120
122
 
123
+ params[:server_groups] = server_groups.map(&:id) if server_groups.any?
121
124
  params[:cloud_ip] = options[:"cloud-ip"] if options.key?(:"cloud-ip")
122
125
  params[:disk_encrypted] = options[:"disk-encrypted"] if options.key?(:"disk-encrypted")
123
126
 
127
+ if options.key?(:"volume-size") && !options[:"volume-size"].nil?
128
+ params[:volume_size] = options[:"volume-size"].to_i
129
+ end
130
+
124
131
  servers = Server.create_servers options[:i], params
125
132
  render_table(servers, global_options)
126
133
  end
@@ -1,3 +1,3 @@
1
1
  module Brightbox
2
- VERSION = "4.0.0".freeze unless defined?(Brightbox::VERSION)
2
+ VERSION = "4.1.0".freeze unless defined?(Brightbox::VERSION)
3
3
  end
data/locales/en.yml CHANGED
@@ -144,6 +144,8 @@ en:
144
144
  desc: Create servers
145
145
  cloud_ip:
146
146
  desc: Immediately map a Cloud IP to new server? Either "true" or the identifier of the Cloud IP
147
+ volume_size:
148
+ desc: Specify a custom volume size (in MiB) when building a network block storage server
147
149
  destroy:
148
150
  desc: Destroy servers
149
151
  lock:
@@ -28,6 +28,24 @@ describe "brightbox servers" do
28
28
  end
29
29
  end
30
30
 
31
+ context "with image argument" do
32
+ let(:argv) { %w[servers create img-12345] }
33
+
34
+ before do
35
+ expect(Brightbox::Image).to receive(:find).with("img-12345").and_return(image)
36
+ expect(Brightbox::Type).to receive(:find_by_handle).and_return(type)
37
+ end
38
+
39
+ it "does not error" do
40
+ stub_request(:post, "http://api.brightbox.localhost/1.0/servers?account_id=acc-12345")
41
+ .with(:body => hash_including(image: "img-12345"))
42
+ .and_return(:status => 202, :body => sample_response)
43
+
44
+ expect(stderr).not_to match("ERROR")
45
+ expect(stdout).to match("srv-12345")
46
+ end
47
+ end
48
+
31
49
  context "with --cloud-ip with nominated IP argument" do
32
50
  let(:argv) { %w[servers create --cloud-ip cip-12345 img-12345] }
33
51
 
@@ -86,6 +104,90 @@ describe "brightbox servers" do
86
104
  end
87
105
  end
88
106
 
107
+ context "with --server-groups flag" do
108
+ let(:argv) { %w[servers create --server-groups grp-12345,grp-67890 img-12345] }
109
+ let(:group_ids) { %w(grp-12345 grp-67890) }
110
+ let(:group_one) { double(:id => "grp-12345") }
111
+ let(:group_two) { double(:id => "grp-67890") }
112
+
113
+ before do
114
+ expect(Brightbox::Image).to receive(:find).with("img-12345").and_return(image)
115
+ expect(Brightbox::Type).to receive(:find_by_handle).and_return(type)
116
+ expect(Brightbox::ServerGroup).to receive(:find_or_call).with(group_ids).and_return([group_one, group_two])
117
+ end
118
+
119
+ it "requests new server be in both server groups" do
120
+ stub_request(:post, "http://api.brightbox.localhost/1.0/servers?account_id=acc-12345")
121
+ .with(:headers => { "Content-Type" => "application/json" },
122
+ :body => hash_including(:server_groups => group_ids))
123
+ .and_return(:status => 202, :body => sample_response)
124
+
125
+ expect(stderr).to match("Creating a nano")
126
+ expect(stderr).not_to match("ERROR")
127
+ expect(stdout).to match("srv-12345")
128
+ end
129
+ end
130
+
131
+ context "without --server-groups flag" do
132
+ let(:argv) { %w[servers create img-12345] }
133
+
134
+ before do
135
+ expect(Brightbox::Image).to receive(:find).with("img-12345").and_return(image)
136
+ expect(Brightbox::Type).to receive(:find_by_handle).and_return(type)
137
+ end
138
+
139
+ it "requests new server be in both server groups" do
140
+ stub_request(:post, "http://api.brightbox.localhost/1.0/servers?account_id=acc-12345")
141
+ .with(:headers => { "Content-Type" => "application/json" })
142
+ .with { |request| hash_excluding("server_groups") === JSON.parse(request.body) }
143
+ .and_return(:status => 202, :body => sample_response)
144
+
145
+ expect(stderr).to match("Creating a nano")
146
+ expect(stderr).not_to match("ERROR")
147
+ expect(stdout).to match("srv-12345")
148
+ end
149
+ end
150
+
151
+ context "with --volume-size switch", vcr: false do
152
+ context "with network storage" do
153
+ let(:argv) { %w[servers create --type=2gb.nbs --volume-size=10000 img-12345] }
154
+
155
+ before do
156
+ expect(Brightbox::Image).to receive(:find).with("img-12345").and_return(image)
157
+ expect(Brightbox::Type).to receive(:find_by_handle).and_return(type)
158
+ end
159
+
160
+ it "requests new server with a custom volume size" do
161
+ stub_request(:post, "http://api.brightbox.localhost/1.0/servers?account_id=acc-12345")
162
+ .with(:headers => { "Content-Type" => "application/json" },
163
+ body: hash_including(volumes: [{ image: "img-12345", size: 10000 }]))
164
+ .and_return(status: 202, body: sample_response)
165
+
166
+ expect(stderr).not_to match("ERROR")
167
+ expect(stdout).to match("srv-12345")
168
+ end
169
+ end
170
+
171
+ context "without network storage type" do
172
+ let(:argv) { %w[servers create --type=nano --volume-size=10000 img-12345] }
173
+
174
+ before do
175
+ expect(Brightbox::Image).to receive(:find).with("img-12345").and_return(image)
176
+ expect(Brightbox::Type).to receive(:find_by_handle).and_return(type)
177
+ end
178
+
179
+ it "requests new server with a custom volume size" do
180
+ stub_request(:post, "http://api.brightbox.localhost/1.0/servers?account_id=acc-12345")
181
+ .with(:headers => { "Content-Type" => "application/json" },
182
+ body: hash_including(volumes: [{ image: "img-12345", size: 10000 }]))
183
+ .and_return(status: 202, body: sample_response)
184
+
185
+ expect(stderr).not_to match("ERROR")
186
+ expect(stdout).to match("srv-12345")
187
+ end
188
+ end
189
+ end
190
+
89
191
  def sample_response
90
192
  '{
91
193
  "id": "srv-12345",
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.0.0
4
+ version: 4.1.0
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: 1980-01-01 00:00:00.000000000 Z
12
+ date: 2022-08-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog-brightbox
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 1.7.0
20
+ version: 1.8.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 1.7.0
27
+ version: 1.8.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: fog-core
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -45,28 +45,28 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 2.21.0
48
+ version: '2.21'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: 2.21.0
55
+ version: '2.21'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: highline
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: 1.6.0
62
+ version: '1.6'
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.0
69
+ version: '1.6'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: hirb
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -107,28 +107,28 @@ dependencies:
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '2.6'
110
+ version: '3.0'
111
111
  type: :runtime
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '2.6'
117
+ version: '3.0'
118
118
  - !ruby/object:Gem::Dependency
119
119
  name: multi_json
120
120
  requirement: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 1.11.0
124
+ version: '1.11'
125
125
  type: :runtime
126
126
  prerelease: false
127
127
  version_requirements: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.11.0
131
+ version: '1.11'
132
132
  - !ruby/object:Gem::Dependency
133
133
  name: dry-inflector
134
134
  requirement: !ruby/object:Gem::Requirement