brightbox-cli 5.0.0.alpha → 5.0.0.rc2
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/.github/workflows/ruby.yml +2 -1
- data/CHANGELOG.md +63 -0
- data/Gemfile.lock +1 -1
- data/lib/brightbox-cli/accounts.rb +5 -1
- data/lib/brightbox-cli/api.rb +34 -1
- data/lib/brightbox-cli/cloud_ips.rb +6 -6
- data/lib/brightbox-cli/collaboration.rb +3 -7
- data/lib/brightbox-cli/commands/images/show.rb +5 -1
- data/lib/brightbox-cli/commands/lbs/create.rb +0 -2
- data/lib/brightbox-cli/commands/lbs/show.rb +9 -1
- data/lib/brightbox-cli/commands/servers/show.rb +5 -1
- data/lib/brightbox-cli/commands/users/show.rb +5 -1
- data/lib/brightbox-cli/commands/volumes/show.rb +5 -1
- data/lib/brightbox-cli/config.rb +10 -4
- data/lib/brightbox-cli/database_server.rb +20 -20
- data/lib/brightbox-cli/database_snapshot.rb +5 -5
- data/lib/brightbox-cli/database_type.rb +4 -8
- data/lib/brightbox-cli/detailed_server.rb +26 -28
- data/lib/brightbox-cli/detailed_server_group.rb +2 -2
- data/lib/brightbox-cli/firewall_policy.rb +5 -9
- data/lib/brightbox-cli/firewall_rule.rb +14 -15
- data/lib/brightbox-cli/images.rb +22 -21
- data/lib/brightbox-cli/indifferent_access_hash.rb +50 -0
- data/lib/brightbox-cli/load_balancers.rb +27 -11
- data/lib/brightbox-cli/server_groups.rb +4 -8
- data/lib/brightbox-cli/servers.rb +22 -16
- data/lib/brightbox-cli/types.rb +4 -8
- data/lib/brightbox-cli/user_collaboration.rb +1 -1
- data/lib/brightbox-cli/users.rb +3 -5
- data/lib/brightbox-cli/version.rb +1 -1
- data/lib/brightbox-cli/volume.rb +9 -13
- data/lib/brightbox-cli/zones.rb +0 -4
- data/lib/brightbox_cli.rb +1 -0
- data/spec/commands/cloudips/update_spec.rb +7 -5
- data/spec/commands/configmaps/create_spec.rb +6 -6
- data/spec/commands/configmaps/destroy_spec.rb +1 -1
- data/spec/commands/configmaps/list_spec.rb +1 -1
- data/spec/commands/configmaps/show_spec.rb +3 -3
- data/spec/commands/configmaps/update_spec.rb +9 -9
- data/spec/commands/images/show_spec.rb +49 -19
- data/spec/commands/lbs/create_spec.rb +12 -26
- data/spec/commands/lbs/show_spec.rb +120 -22
- data/spec/commands/lbs/update_spec.rb +4 -4
- data/spec/commands/servers/show_spec.rb +83 -1
- data/spec/commands/servers/update_spec.rb +7 -7
- data/spec/commands/sql/instances/create_spec.rb +8 -8
- data/spec/commands/sql/instances/reset_spec.rb +3 -3
- data/spec/commands/sql/instances/resize_spec.rb +4 -4
- data/spec/commands/sql/instances/show_spec.rb +2 -1
- data/spec/commands/sql/instances/update_spec.rb +3 -3
- data/spec/commands/sql/snapshots/list_spec.rb +1 -1
- data/spec/commands/sql/snapshots/show_spec.rb +50 -7
- data/spec/commands/users/show_spec.rb +66 -1
- data/spec/commands/volumes/attach_spec.rb +4 -4
- data/spec/commands/volumes/copy_spec.rb +2 -2
- data/spec/commands/volumes/destroy_spec.rb +1 -1
- data/spec/commands/volumes/detach_spec.rb +1 -1
- data/spec/commands/volumes/list_spec.rb +1 -1
- data/spec/commands/volumes/resize_spec.rb +3 -3
- data/spec/commands/volumes/show_spec.rb +54 -25
- data/spec/commands/volumes/update_spec.rb +4 -4
- data/spec/spec_helper.rb +14 -10
- data/spec/support/shared/api_resource_examples.rb +25 -0
- data/spec/unit/brightbox/account/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/api/attributes_spec.rb +65 -0
- data/spec/unit/brightbox/api/fog_attributes_spec.rb +65 -0
- data/spec/unit/brightbox/cloud_ip/attributes_spec.rb +19 -0
- data/spec/unit/brightbox/collaborating_account/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/database_server/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/database_snapshot/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/database_type/attributes_spec.rb +20 -0
- data/spec/unit/brightbox/detailed_server/attributes_spec.rb +29 -0
- data/spec/unit/brightbox/detailed_server_group/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/firewall_policy/attributes_spec.rb +21 -0
- data/spec/unit/brightbox/firewall_rule/attributes_spec.rb +18 -0
- data/spec/unit/brightbox/image/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/image/status_spec.rb +67 -0
- data/spec/unit/brightbox/load_balancer/acme_cert_spec.rb +75 -0
- data/spec/unit/brightbox/load_balancer/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/load_balancer/formatted_acme_domains_spec.rb +78 -0
- data/spec/unit/brightbox/server/attributes_spec.rb +29 -0
- data/spec/unit/brightbox/server_group/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/type/attributes_spec.rb +20 -0
- data/spec/unit/brightbox/user/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/user_collaboration/attributes_spec.rb +13 -0
- metadata +50 -10
- data/spec/cassettes/brightbox_sql_snapshots/show/when_resource_exists/does_not_output_to_stderr.yml +0 -93
@@ -0,0 +1,50 @@
|
|
1
|
+
# A simpler wrapper to allows either String or Symbol keys to be used
|
2
|
+
# when accessing attributes since fog applies a change on the top
|
3
|
+
# level resulting in a mix of both which has introduced issues.
|
4
|
+
class IndifferentAccessHash
|
5
|
+
def initialize(hash)
|
6
|
+
@hash = hash
|
7
|
+
end
|
8
|
+
|
9
|
+
# @param key [String, Symbol] the key to look up
|
10
|
+
# @return [Object] the value of the key
|
11
|
+
def [](key)
|
12
|
+
value = @hash[key.to_s] || @hash[key.to_sym]
|
13
|
+
wrap(value)
|
14
|
+
end
|
15
|
+
|
16
|
+
# @param key [String, Symbol] the key to set
|
17
|
+
# @param value [Object] the value to set
|
18
|
+
# @return [Object] the value of the key
|
19
|
+
def []=(key, value)
|
20
|
+
@hash[key.to_sym] = value
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param other [Object] the object to compare
|
24
|
+
# @return [Object] the result of the comparison
|
25
|
+
def ==(other)
|
26
|
+
@hash == (other.is_a?(IndifferentAccessHash) ? other.to_h : other)
|
27
|
+
end
|
28
|
+
|
29
|
+
def method_missing(method, *args, &block)
|
30
|
+
@hash.send(method, *args, &block)
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_h
|
34
|
+
@hash
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
# This is to handle nested hashes to avoid the original issue again
|
40
|
+
def wrap(value)
|
41
|
+
case value
|
42
|
+
when Hash
|
43
|
+
IndifferentAccessHash.new(value)
|
44
|
+
when Array
|
45
|
+
value.map { |v| wrap(v) }
|
46
|
+
else
|
47
|
+
value
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -9,26 +9,42 @@ module Brightbox
|
|
9
9
|
new(conn.load_balancers.create(options))
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
if attributes[
|
14
|
-
|
15
|
-
[
|
16
|
-
|
12
|
+
def acme_cert
|
13
|
+
if attributes[:acme] && attributes[:acme][:certificate]
|
14
|
+
OpenStruct.new(
|
15
|
+
:expires_at => attributes[:acme][:certificate][:expires_at],
|
16
|
+
:fingerprint => attributes[:acme][:certificate][:fingerprint],
|
17
|
+
:issued_at => attributes[:acme][:certificate][:issued_at],
|
18
|
+
:subjects => attributes[:acme][:certificate][:domains].join(",")
|
19
|
+
)
|
17
20
|
else
|
18
|
-
|
21
|
+
OpenStruct.new(
|
22
|
+
:expires_at => "",
|
23
|
+
:fingerprint => "",
|
24
|
+
:issued_at => "",
|
25
|
+
:subjects => ""
|
26
|
+
)
|
19
27
|
end
|
20
|
-
rescue StandardError
|
21
|
-
[]
|
22
28
|
end
|
23
29
|
|
24
|
-
def
|
25
|
-
|
30
|
+
def formatted_acme_domains
|
31
|
+
return "" unless attributes[:acme]
|
32
|
+
|
33
|
+
attributes[:acme][:domains].map do |domain|
|
34
|
+
[domain[:identifier], domain[:status]].join(":")
|
35
|
+
end.join(",")
|
36
|
+
rescue StandardError
|
37
|
+
""
|
26
38
|
end
|
27
39
|
|
28
40
|
def to_row
|
29
41
|
attributes.merge(
|
30
42
|
:locked => locked?,
|
31
|
-
:acme_domains =>
|
43
|
+
:acme_domains => formatted_acme_domains,
|
44
|
+
:acme_cert_expires_at => acme_cert.expires_at,
|
45
|
+
:acme_cert_fingerprint => acme_cert.fingerprint,
|
46
|
+
:acme_cert_issued_at => acme_cert.issued_at,
|
47
|
+
:acme_cert_subjects => acme_cert.subjects,
|
32
48
|
:ssl_minimum_version => ssl_minimum_version,
|
33
49
|
:ssl_issuer => certificate_issuer,
|
34
50
|
:ssl_subject => certificate_subject,
|
@@ -34,15 +34,11 @@ module Brightbox
|
|
34
34
|
fog_model.destroy
|
35
35
|
end
|
36
36
|
|
37
|
-
def attributes
|
38
|
-
fog_model.attributes
|
39
|
-
end
|
40
|
-
|
41
37
|
def to_row
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
38
|
+
super.merge(
|
39
|
+
servers: server_string,
|
40
|
+
server_count: server_count
|
41
|
+
).to_h
|
46
42
|
end
|
47
43
|
|
48
44
|
def server_ids
|
@@ -37,25 +37,31 @@ module Brightbox
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def attributes
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
40
|
+
fog_attributes.tap do |attrs|
|
41
|
+
attrs[:created_at] = created_at
|
42
|
+
attrs[:created_on] = created_on
|
43
|
+
attrs[:hostname] = hostname
|
44
|
+
attrs[:image] = image_id
|
45
|
+
attrs[:locked] = locked?
|
46
|
+
attrs[:status] = fog_model.state
|
47
|
+
attrs[:type] = server_type["handle"]
|
48
|
+
attrs[:zone] = zone && zone["handle"]
|
49
|
+
|
50
|
+
unless cloud_ips.empty?
|
51
|
+
attrs[:public_hostname] = "public.#{fqdn}"
|
52
|
+
end
|
53
|
+
|
54
|
+
if interfaces.any? { |i| i["ipv6_address"] }
|
55
|
+
attrs[:ipv6_hostname] = ipv6_fqdn
|
56
|
+
end
|
57
|
+
end
|
52
58
|
end
|
53
59
|
|
54
60
|
def to_row
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
61
|
+
attributes.merge(
|
62
|
+
cloud_ips: cloud_ips.map { |i| i["public_ip"] }.join(", "),
|
63
|
+
ips: interfaces.map { |i| i["ipv4_address"] }.join(", ")
|
64
|
+
)
|
59
65
|
end
|
60
66
|
|
61
67
|
def deleted?
|
data/lib/brightbox-cli/types.rb
CHANGED
@@ -3,10 +3,10 @@ module Brightbox
|
|
3
3
|
def self.require_account?; true; end
|
4
4
|
|
5
5
|
def attributes
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
fog_attributes.tap do |attrs|
|
7
|
+
attrs[:ram] = ram
|
8
|
+
attrs[:disk] = disk
|
9
|
+
end
|
10
10
|
end
|
11
11
|
|
12
12
|
def ram
|
@@ -17,10 +17,6 @@ module Brightbox
|
|
17
17
|
fog_model.disk.to_i
|
18
18
|
end
|
19
19
|
|
20
|
-
def to_row
|
21
|
-
attributes
|
22
|
-
end
|
23
|
-
|
24
20
|
def render_cell
|
25
21
|
fog_model.handle
|
26
22
|
end
|
data/lib/brightbox-cli/users.rb
CHANGED
data/lib/brightbox-cli/volume.rb
CHANGED
@@ -57,19 +57,15 @@ module Brightbox
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def attributes
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
def to_row
|
72
|
-
attributes
|
60
|
+
super.merge(
|
61
|
+
id: fog_model.id,
|
62
|
+
image: image_id,
|
63
|
+
locked: locked?,
|
64
|
+
server: server_id,
|
65
|
+
status: state,
|
66
|
+
type: storage_type,
|
67
|
+
zone: zone_id
|
68
|
+
)
|
73
69
|
end
|
74
70
|
|
75
71
|
def update(options)
|
data/lib/brightbox-cli/zones.rb
CHANGED
data/lib/brightbox_cli.rb
CHANGED
@@ -71,6 +71,7 @@ require_relative "brightbox/cli/config"
|
|
71
71
|
require_relative "brightbox-cli/connection_manager"
|
72
72
|
require_relative "brightbox-cli/tables"
|
73
73
|
require_relative "brightbox-cli/logging"
|
74
|
+
require_relative "brightbox-cli/indifferent_access_hash"
|
74
75
|
require_relative "brightbox-cli/api"
|
75
76
|
require_relative "brightbox-cli/config/cache"
|
76
77
|
require_relative "brightbox-cli/config/gpg_encrypted_passwords"
|
@@ -59,7 +59,9 @@ describe "brightbox cloudips update" do
|
|
59
59
|
|
60
60
|
it "puts new name in update" do
|
61
61
|
expect(Brightbox::CloudIP.conn).to receive(:update_cloud_ip).with(*expected_args).and_call_original
|
62
|
-
|
62
|
+
|
63
|
+
expect(stderr).to be_empty unless ENV["DEBUG"]
|
64
|
+
|
63
65
|
expect(stdout).to include("cip-12345")
|
64
66
|
expect(stdout).to include("New name")
|
65
67
|
end
|
@@ -82,7 +84,7 @@ describe "brightbox cloudips update" do
|
|
82
84
|
|
83
85
|
it "puts new name in update" do
|
84
86
|
expect(Brightbox::CloudIP.conn).to receive(:update_cloud_ip).with(*expected_args).and_call_original
|
85
|
-
expect(stderr).to
|
87
|
+
expect(stderr).to be_empty unless ENV["DEBUG"]
|
86
88
|
expect(stdout).to include("cip-12345")
|
87
89
|
end
|
88
90
|
end
|
@@ -114,7 +116,7 @@ describe "brightbox cloudips update" do
|
|
114
116
|
end
|
115
117
|
|
116
118
|
it "puts new name in update" do
|
117
|
-
expect(stderr).to
|
119
|
+
expect(stderr).to be_empty unless ENV["DEBUG"]
|
118
120
|
expect(stdout).to include("cip-dfsa3")
|
119
121
|
expect(stdout).to include("domain.example")
|
120
122
|
end
|
@@ -146,7 +148,7 @@ describe "brightbox cloudips update" do
|
|
146
148
|
end
|
147
149
|
|
148
150
|
it "puts new name in update" do
|
149
|
-
expect(stderr).to
|
151
|
+
expect(stderr).to be_empty unless ENV["DEBUG"]
|
150
152
|
expect(stdout).to include("cip-dfsa3")
|
151
153
|
end
|
152
154
|
end
|
@@ -155,7 +157,7 @@ describe "brightbox cloudips update" do
|
|
155
157
|
let(:argv) { ["cloudips", "update", "--reverse-dns", "domain.example", "--delete-reverse-dns", "cip-dfsa3"] }
|
156
158
|
|
157
159
|
it "puts new name in update" do
|
158
|
-
expect(stderr).to
|
160
|
+
expect(stderr).to include("ERROR: You must either specify a reverse DNS record or --delete-reverse-dns\n")
|
159
161
|
expect(stdout).to eq("")
|
160
162
|
end
|
161
163
|
end
|
@@ -109,7 +109,7 @@ describe "brightbox configmaps create" do
|
|
109
109
|
it "does not error" do
|
110
110
|
expect { output }.to_not raise_error
|
111
111
|
|
112
|
-
expect(stderr).to
|
112
|
+
expect(stderr).to include("ERROR: Config map data was not valid JSON\n")
|
113
113
|
|
114
114
|
expect(stdout).to eq("")
|
115
115
|
end
|
@@ -156,7 +156,7 @@ describe "brightbox configmaps create" do
|
|
156
156
|
it "does not error" do
|
157
157
|
expect { output }.to_not raise_error
|
158
158
|
|
159
|
-
expect(stderr).to
|
159
|
+
expect(stderr).to include("Creating config map\n")
|
160
160
|
|
161
161
|
aggregate_failures do
|
162
162
|
expect(stdout).to match("cfg-s432l")
|
@@ -169,7 +169,7 @@ describe "brightbox configmaps create" do
|
|
169
169
|
it "does not error" do
|
170
170
|
expect { output }.to_not raise_error
|
171
171
|
|
172
|
-
expect(stderr).to
|
172
|
+
expect(stderr).to include("ERROR: Config map data was not valid JSON\n")
|
173
173
|
|
174
174
|
expect(stdout).to eq("")
|
175
175
|
end
|
@@ -219,7 +219,7 @@ describe "brightbox configmaps create" do
|
|
219
219
|
it "does not error" do
|
220
220
|
expect { output }.to_not raise_error
|
221
221
|
|
222
|
-
expect(stderr).to
|
222
|
+
expect(stderr).to include("Creating config map\n")
|
223
223
|
|
224
224
|
aggregate_failures do
|
225
225
|
expect(stdout).to match("cfg-mj53s")
|
@@ -232,7 +232,7 @@ describe "brightbox configmaps create" do
|
|
232
232
|
it "does not error" do
|
233
233
|
expect { output }.to_not raise_error
|
234
234
|
|
235
|
-
expect(stderr).to
|
235
|
+
expect(stderr).to include("ERROR: Config map data was not valid JSON\n")
|
236
236
|
|
237
237
|
expect(stdout).to eq("")
|
238
238
|
end
|
@@ -248,7 +248,7 @@ describe "brightbox configmaps create" do
|
|
248
248
|
it "does not error" do
|
249
249
|
expect { output }.to_not raise_error
|
250
250
|
|
251
|
-
expect(stderr).to
|
251
|
+
expect(stderr).to include("ERROR: Config map data can only be passed by either 'data' or 'data-file'\n")
|
252
252
|
|
253
253
|
expect(stdout).to eq("")
|
254
254
|
end
|
@@ -26,7 +26,7 @@ describe "brightbox configmaps destroy" do
|
|
26
26
|
it "does not error" do
|
27
27
|
expect { output }.to_not raise_error
|
28
28
|
|
29
|
-
expect(stderr).to
|
29
|
+
expect(stderr).to include("ERROR: You must specify config map IDs as arguments\n")
|
30
30
|
|
31
31
|
expect(stdout).to match("")
|
32
32
|
end
|
@@ -35,7 +35,7 @@ describe "brightbox configmaps show" do
|
|
35
35
|
it "does not error" do
|
36
36
|
expect { output }.to_not raise_error
|
37
37
|
|
38
|
-
expect(stderr).to
|
38
|
+
expect(stderr).to be_empty unless ENV["DEBUG"]
|
39
39
|
|
40
40
|
aggregate_failures do
|
41
41
|
expect(stdout).to match("id: cfg-12345")
|
@@ -81,7 +81,7 @@ describe "brightbox configmaps show" do
|
|
81
81
|
it "does not error" do
|
82
82
|
expect { output }.to_not raise_error
|
83
83
|
|
84
|
-
expect(stderr).to
|
84
|
+
expect(stderr).to include("ERROR: You can only access data for a single config map at a time\n")
|
85
85
|
|
86
86
|
expect(stdout).to eq("")
|
87
87
|
end
|
@@ -137,7 +137,7 @@ describe "brightbox configmaps show" do
|
|
137
137
|
it "does not error" do
|
138
138
|
expect { output }.to_not raise_error
|
139
139
|
|
140
|
-
expect(stderr).to
|
140
|
+
expect(stderr).to be_empty unless ENV["DEBUG"]
|
141
141
|
|
142
142
|
expect(stdout).to eq(%({"key":"value","name":"key name"}\n))
|
143
143
|
end
|
@@ -27,7 +27,7 @@ describe "brightbox configmaps update" do
|
|
27
27
|
it "does not error" do
|
28
28
|
expect { output }.to_not raise_error
|
29
29
|
|
30
|
-
expect(stderr).to
|
30
|
+
expect(stderr).to include("ERROR: You must specify the config map ID as the first argument\n")
|
31
31
|
|
32
32
|
expect(stdout).to match("")
|
33
33
|
end
|
@@ -73,7 +73,7 @@ describe "brightbox configmaps update" do
|
|
73
73
|
it "does not error" do
|
74
74
|
expect { output }.to_not raise_error
|
75
75
|
|
76
|
-
expect(stderr).to
|
76
|
+
expect(stderr).to include("Updating cfg-0932s\n")
|
77
77
|
|
78
78
|
aggregate_failures do
|
79
79
|
expect(stdout).to match("cfg-0932s")
|
@@ -134,7 +134,7 @@ describe "brightbox configmaps update" do
|
|
134
134
|
it "does not error" do
|
135
135
|
expect { output }.to_not raise_error
|
136
136
|
|
137
|
-
expect(stderr).to
|
137
|
+
expect(stderr).to include("Updating cfg-25hrt\n")
|
138
138
|
|
139
139
|
aggregate_failures do
|
140
140
|
expect(stdout).to match("cfg-25hrt")
|
@@ -148,7 +148,7 @@ describe "brightbox configmaps update" do
|
|
148
148
|
it "does not error" do
|
149
149
|
expect { output }.to_not raise_error
|
150
150
|
|
151
|
-
expect(stderr).to
|
151
|
+
expect(stderr).to include("ERROR: Config map data was not valid JSON\n")
|
152
152
|
|
153
153
|
expect(stdout).to eq("")
|
154
154
|
end
|
@@ -218,7 +218,7 @@ describe "brightbox configmaps update" do
|
|
218
218
|
it "does not error" do
|
219
219
|
expect { output }.to_not raise_error
|
220
220
|
|
221
|
-
expect(stderr).to
|
221
|
+
expect(stderr).to include("Updating cfg-gr45a\n")
|
222
222
|
|
223
223
|
aggregate_failures do
|
224
224
|
expect(stdout).to match("cfg-gr45a")
|
@@ -231,7 +231,7 @@ describe "brightbox configmaps update" do
|
|
231
231
|
it "does not error" do
|
232
232
|
expect { output }.to_not raise_error
|
233
233
|
|
234
|
-
expect(stderr).to
|
234
|
+
expect(stderr).to include("ERROR: Config map data was not valid JSON\n")
|
235
235
|
|
236
236
|
expect(stdout).to eq("")
|
237
237
|
end
|
@@ -303,7 +303,7 @@ describe "brightbox configmaps update" do
|
|
303
303
|
it "does not error" do
|
304
304
|
expect { output }.to_not raise_error
|
305
305
|
|
306
|
-
expect(stderr).to
|
306
|
+
expect(stderr).to include("Updating cfg-stdin\n")
|
307
307
|
|
308
308
|
aggregate_failures do
|
309
309
|
expect(stdout).to match("cfg-stdin")
|
@@ -316,7 +316,7 @@ describe "brightbox configmaps update" do
|
|
316
316
|
it "does not error" do
|
317
317
|
expect { output }.to_not raise_error
|
318
318
|
|
319
|
-
expect(stderr).to
|
319
|
+
expect(stderr).to include("ERROR: Config map data was not valid JSON\n")
|
320
320
|
|
321
321
|
expect(stdout).to eq("")
|
322
322
|
end
|
@@ -332,7 +332,7 @@ describe "brightbox configmaps update" do
|
|
332
332
|
it "does not error" do
|
333
333
|
expect { output }.to_not raise_error
|
334
334
|
|
335
|
-
expect(stderr).to
|
335
|
+
expect(stderr).to include("ERROR: Config map data can only be passed by either 'data' or 'data-file'\n")
|
336
336
|
|
337
337
|
expect(stdout).to eq("")
|
338
338
|
end
|
@@ -17,35 +17,51 @@ RSpec.describe "brightbox images" do
|
|
17
17
|
context "without arguments" do
|
18
18
|
let(:argv) { %w[images show] }
|
19
19
|
|
20
|
+
it "reports missing IDs" do
|
21
|
+
expect { output }.to_not raise_error
|
22
|
+
|
23
|
+
aggregate_failures do
|
24
|
+
expect(stderr).to match("ERROR: You must specify image IDs to show")
|
25
|
+
expect(stdout).to eq("")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "with identifier argument" do
|
31
|
+
let(:argv) { %w[images show img-11111] }
|
32
|
+
|
20
33
|
before do
|
21
|
-
|
34
|
+
expect(Brightbox::Image).to receive(:find)
|
35
|
+
.with("img-11111")
|
36
|
+
.and_call_original
|
37
|
+
|
38
|
+
stub_request(:get, "#{api_url}/1.0/images/img-11111?account_id=acc-12345")
|
22
39
|
.to_return(
|
23
40
|
status: 200,
|
24
|
-
body:
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
].to_json
|
41
|
+
body: {
|
42
|
+
id: "img-11111",
|
43
|
+
min_ram: 2_048
|
44
|
+
}.to_json
|
29
45
|
)
|
30
46
|
end
|
31
47
|
|
32
48
|
it "does not error" do
|
33
49
|
expect { output }.to_not raise_error
|
34
50
|
|
35
|
-
|
36
|
-
|
37
|
-
|
51
|
+
aggregate_failures do
|
52
|
+
expect(stderr).to match("")
|
53
|
+
expect(stderr).not_to match("ERROR")
|
54
|
+
expect(stdout).to match("img-11111")
|
55
|
+
|
56
|
+
expect(stdout).to match("min_ram: 2048")
|
57
|
+
end
|
38
58
|
end
|
39
59
|
end
|
40
60
|
|
41
|
-
context "with
|
42
|
-
let(:argv) { %w[images show img-11111] }
|
61
|
+
context "with multiple identifiers" do
|
62
|
+
let(:argv) { %w[images show img-11111 img-22222] }
|
43
63
|
|
44
64
|
before do
|
45
|
-
expect(Brightbox::Image).to receive(:find)
|
46
|
-
.with("img-11111")
|
47
|
-
.and_call_original
|
48
|
-
|
49
65
|
stub_request(:get, "#{api_url}/1.0/images/img-11111?account_id=acc-12345")
|
50
66
|
.to_return(
|
51
67
|
status: 200,
|
@@ -54,16 +70,30 @@ RSpec.describe "brightbox images" do
|
|
54
70
|
min_ram: 2_048
|
55
71
|
}.to_json
|
56
72
|
)
|
73
|
+
|
74
|
+
stub_request(:get, "#{api_url}/1.0/images/img-22222?account_id=acc-12345")
|
75
|
+
.to_return(
|
76
|
+
status: 200,
|
77
|
+
body: {
|
78
|
+
id: "img-22222",
|
79
|
+
min_ram: 4_096
|
80
|
+
}.to_json
|
81
|
+
)
|
57
82
|
end
|
58
83
|
|
59
84
|
it "does not error" do
|
60
85
|
expect { output }.to_not raise_error
|
61
86
|
|
62
|
-
|
63
|
-
|
64
|
-
|
87
|
+
aggregate_failures do
|
88
|
+
expect(stderr).to match("")
|
89
|
+
expect(stderr).not_to match("ERROR")
|
90
|
+
|
91
|
+
expect(stdout).to match("img-11111")
|
92
|
+
expect(stdout).to match("min_ram: 2048")
|
65
93
|
|
66
|
-
|
94
|
+
expect(stdout).to match("img-22222")
|
95
|
+
expect(stdout).to match("min_ram: 4096")
|
96
|
+
end
|
67
97
|
end
|
68
98
|
end
|
69
99
|
end
|