brightbox-cli 4.8.0 → 5.0.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +4 -1
- data/Gemfile.lock +17 -10
- data/brightbox-cli.gemspec +3 -7
- data/lib/brightbox-cli/commands/cloudips/unmap.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/policies_apply.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/policies_create.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/policies_destroy.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/policies_list.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/policies_remove.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/policies_show.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/policies_update.rb +1 -1
- data/lib/brightbox-cli/commands/lbs/create.rb +28 -14
- data/lib/brightbox-cli/commands/lbs/show.rb +1 -0
- data/lib/brightbox-cli/commands/lbs/update.rb +9 -2
- data/lib/brightbox-cli/config.rb +2 -1
- data/lib/brightbox-cli/images.rb +2 -2
- data/lib/brightbox-cli/load_balancers.rb +20 -2
- data/lib/brightbox-cli/servers.rb +1 -1
- data/lib/brightbox-cli/version.rb +1 -1
- data/spec/commands/lbs/create_spec.rb +169 -3
- data/spec/commands/lbs/show_spec.rb +87 -3
- data/spec/commands/lbs/update_spec.rb +47 -3
- data/spec/spec_helper.rb +12 -0
- data/spec/unit/brightbox/bb_config/config_directory_spec.rb +23 -3
- data/spec/unit/brightbox/server/hostname_spec.rb +27 -0
- metadata +23 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4acdda82f537081ebb5cb73f47463dcb76aa4d13903ef59df37e9c7159e6bcef
|
4
|
+
data.tar.gz: 653ee68c860f906a56daa9c859fcd62b625bcaa32f2c7610fdd62ea57513544e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64289163116f1e986cad76c3794870c7fe28ac5d2a96ad7cf433ad3bf4fb4f8cb4445930dbddd13d7e9a803df1497940df47877689a3cee5fac5f50561b3f99d
|
7
|
+
data.tar.gz: 793e0f20d1b18450a7024272a6eebb1b61e470c250e3dee740c7251c963b63914fd38ee48af2ae113a27d4046f251320267fece5b8cdd4d298222524aeb46d64
|
data/.github/workflows/ruby.yml
CHANGED
@@ -19,8 +19,9 @@ jobs:
|
|
19
19
|
runs-on: ubuntu-latest
|
20
20
|
|
21
21
|
strategy:
|
22
|
+
fail-fast: false
|
22
23
|
matrix:
|
23
|
-
ruby: ["2.
|
24
|
+
ruby: ["2.7", "3.0", "3.1", "3.2", "3.3"]
|
24
25
|
|
25
26
|
steps:
|
26
27
|
- uses: actions/checkout@v3
|
@@ -30,6 +31,8 @@ jobs:
|
|
30
31
|
uses: ruby/setup-ruby@v1
|
31
32
|
with:
|
32
33
|
ruby-version: ${{ matrix.ruby }}
|
34
|
+
- name: Install Bundler
|
35
|
+
run: gem install bundler -v $(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1 | awk '{print $1}')
|
33
36
|
- name: Install dependencies
|
34
37
|
run: bundle install
|
35
38
|
- name: Run tests
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
brightbox-cli (
|
5
|
-
|
6
|
-
fog-brightbox (>= 1.11.0)
|
4
|
+
brightbox-cli (5.0.0.alpha)
|
5
|
+
fog-brightbox (>= 1.12.0)
|
7
6
|
fog-core (< 2.0)
|
8
7
|
gli (~> 2.21)
|
9
8
|
highline (~> 2.0)
|
@@ -24,9 +23,10 @@ GEM
|
|
24
23
|
crack (0.4.5)
|
25
24
|
rexml
|
26
25
|
diff-lcs (1.5.0)
|
27
|
-
|
26
|
+
docile (1.4.1)
|
27
|
+
dry-inflector (1.1.0)
|
28
28
|
excon (0.112.0)
|
29
|
-
fog-brightbox (1.
|
29
|
+
fog-brightbox (1.12.0)
|
30
30
|
dry-inflector
|
31
31
|
fog-core (>= 1.45, < 3.0)
|
32
32
|
fog-json
|
@@ -38,18 +38,18 @@ GEM
|
|
38
38
|
fog-core
|
39
39
|
multi_json (~> 1.10)
|
40
40
|
formatador (0.3.0)
|
41
|
-
gli (2.
|
41
|
+
gli (2.22.0)
|
42
42
|
hashdiff (1.0.1)
|
43
43
|
highline (2.1.0)
|
44
44
|
hirb (0.7.3)
|
45
45
|
i18n (1.10.0)
|
46
46
|
concurrent-ruby (~> 1.0)
|
47
|
-
logger (1.6.
|
47
|
+
logger (1.6.2)
|
48
48
|
method_source (1.0.0)
|
49
49
|
mime-types (3.6.0)
|
50
50
|
logger
|
51
51
|
mime-types-data (~> 3.2015)
|
52
|
-
mime-types-data (3.2024.
|
52
|
+
mime-types-data (3.2024.1203)
|
53
53
|
mocha (1.14.0)
|
54
54
|
multi_json (1.15.0)
|
55
55
|
parallel (1.22.1)
|
@@ -65,7 +65,7 @@ GEM
|
|
65
65
|
rainbow (3.1.1)
|
66
66
|
rake (13.0.6)
|
67
67
|
regexp_parser (2.5.0)
|
68
|
-
rexml (3.
|
68
|
+
rexml (3.3.9)
|
69
69
|
rspec (3.11.0)
|
70
70
|
rspec-core (~> 3.11.0)
|
71
71
|
rspec-expectations (~> 3.11.0)
|
@@ -95,6 +95,12 @@ GEM
|
|
95
95
|
rubocop-rspec (2.10.0)
|
96
96
|
rubocop (~> 1.19)
|
97
97
|
ruby-progressbar (1.11.0)
|
98
|
+
simplecov (0.22.0)
|
99
|
+
docile (~> 1.1)
|
100
|
+
simplecov-html (~> 0.11)
|
101
|
+
simplecov_json_formatter (~> 0.1)
|
102
|
+
simplecov-html (0.13.1)
|
103
|
+
simplecov_json_formatter (0.1.4)
|
98
104
|
slop (3.6.0)
|
99
105
|
unicode-display_width (2.1.0)
|
100
106
|
vcr (2.9.3)
|
@@ -115,8 +121,9 @@ DEPENDENCIES
|
|
115
121
|
rubocop
|
116
122
|
rubocop-rake
|
117
123
|
rubocop-rspec
|
124
|
+
simplecov
|
118
125
|
vcr (~> 2.5)
|
119
126
|
webmock
|
120
127
|
|
121
128
|
BUNDLED WITH
|
122
|
-
2.
|
129
|
+
2.4.22
|
data/brightbox-cli.gemspec
CHANGED
@@ -14,14 +14,14 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.license = "MIT"
|
15
15
|
s.metadata['rubygems_mfa_required'] = 'true'
|
16
16
|
|
17
|
-
s.required_ruby_version = ">= 2.
|
17
|
+
s.required_ruby_version = ">= 2.7"
|
18
18
|
|
19
19
|
s.files = `git ls-files`.split("\n") + `find lib/brightbox-cli/vendor`.split("\n")
|
20
20
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
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.
|
24
|
+
s.add_dependency "fog-brightbox", ">= 1.12.0"
|
25
25
|
s.add_dependency "fog-core", "< 2.0"
|
26
26
|
s.add_dependency "gli", "~> 2.21"
|
27
27
|
s.add_dependency "highline", "~> 2.0"
|
@@ -30,11 +30,6 @@ Gem::Specification.new do |s|
|
|
30
30
|
s.add_dependency "mime-types", "~> 3.0"
|
31
31
|
s.add_dependency "multi_json", "~> 1.11"
|
32
32
|
|
33
|
-
# Indirect dependency
|
34
|
-
# 0.3 drops support for Ruby < 2.7
|
35
|
-
# 0.2.1 drops support for Ruby < 2.6
|
36
|
-
s.add_dependency "dry-inflector", "= 0.2.0"
|
37
|
-
|
38
33
|
s.add_development_dependency "mocha"
|
39
34
|
s.add_development_dependency "pry-remote"
|
40
35
|
s.add_development_dependency "rake"
|
@@ -42,6 +37,7 @@ Gem::Specification.new do |s|
|
|
42
37
|
s.add_development_dependency "rubocop"
|
43
38
|
s.add_development_dependency "rubocop-rake"
|
44
39
|
s.add_development_dependency "rubocop-rspec"
|
40
|
+
s.add_development_dependency "simplecov"
|
45
41
|
s.add_development_dependency "vcr", "~> 2.5"
|
46
42
|
s.add_development_dependency "webmock"
|
47
43
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Brightbox
|
2
2
|
desc I18n.t("firewall.policies.desc")
|
3
|
-
command [
|
3
|
+
command ["firewall-policies", "firewall-policy"] do |cmd|
|
4
4
|
cmd.desc I18n.t("firewall.policies.apply.desc")
|
5
5
|
cmd.arg_name "firewall-policy-id server-group-id"
|
6
6
|
cmd.command [:apply] do |c|
|
@@ -32,18 +32,21 @@ module Brightbox
|
|
32
32
|
c.default_value "/"
|
33
33
|
c.flag [:s, "hc-request"]
|
34
34
|
|
35
|
-
c.desc "
|
35
|
+
c.desc "Health check interval"
|
36
36
|
c.default_value "5000"
|
37
37
|
c.flag [:e, "hc-interval"]
|
38
38
|
|
39
|
-
c.desc "
|
39
|
+
c.desc "Health check threshold up. Number of successful health checks for the node to be considered up."
|
40
40
|
c.default_value "3"
|
41
41
|
c.flag [:u, "hc-up"]
|
42
42
|
|
43
|
-
c.desc "
|
43
|
+
c.desc "Health check threshold down. Number of failed health checks for the node to be considered down."
|
44
44
|
c.default_value "3"
|
45
45
|
c.flag [:d, "hc-down"]
|
46
46
|
|
47
|
+
c.desc "ACME domains"
|
48
|
+
c.flag ["acme_domains"]
|
49
|
+
|
47
50
|
c.desc "Filepath to the SSL certificate file to use."
|
48
51
|
c.flag ["ssl-cert"]
|
49
52
|
|
@@ -78,6 +81,14 @@ module Brightbox
|
|
78
81
|
options[:y] = listeners.first[:protocol]
|
79
82
|
end
|
80
83
|
|
84
|
+
if options[:b]
|
85
|
+
options[:b] = options[:b].to_i
|
86
|
+
end
|
87
|
+
|
88
|
+
if options["acme_domains"]
|
89
|
+
options["acme_domains"] = options["acme_domains"].split(",")
|
90
|
+
end
|
91
|
+
|
81
92
|
hc_arg_lookup = {
|
82
93
|
:k => :port,
|
83
94
|
:y => :type,
|
@@ -96,7 +107,7 @@ module Brightbox
|
|
96
107
|
end
|
97
108
|
end
|
98
109
|
|
99
|
-
# SSL
|
110
|
+
# SSL arguments
|
100
111
|
ssl_cert_path = options["ssl-cert"]
|
101
112
|
ssl_key_path = options["ssl-key"]
|
102
113
|
|
@@ -113,16 +124,19 @@ module Brightbox
|
|
113
124
|
|
114
125
|
msg = "Creating a new load balancer"
|
115
126
|
info msg
|
116
|
-
lb = LoadBalancer.create(
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
127
|
+
lb = LoadBalancer.create(
|
128
|
+
domains: options["acme_domains"],
|
129
|
+
buffer_size: options[:b],
|
130
|
+
certificate_pem: ssl_cert,
|
131
|
+
certificate_private_key: ssl_key,
|
132
|
+
healthcheck: healthcheck,
|
133
|
+
listeners: listeners,
|
134
|
+
name: options[:n],
|
135
|
+
nodes: nodes,
|
136
|
+
policy: options[:policy],
|
137
|
+
ssl_minimum_version: options["ssl-min-ver"],
|
138
|
+
sslv3: options["sslv3"]
|
139
|
+
)
|
126
140
|
render_table([lb], global_options)
|
127
141
|
end
|
128
142
|
end
|
@@ -37,6 +37,9 @@ module Brightbox
|
|
37
37
|
c.desc "Healthcheck threshold down. Number of failed healthchecks for the node to be considered down."
|
38
38
|
c.flag [:d, "hc-down"]
|
39
39
|
|
40
|
+
c.desc "ACME domains"
|
41
|
+
c.flag ["acme_domains"]
|
42
|
+
|
40
43
|
c.desc "Filepath to the SSL certificate file to use."
|
41
44
|
c.flag ["ssl-cert"]
|
42
45
|
|
@@ -100,10 +103,10 @@ module Brightbox
|
|
100
103
|
end
|
101
104
|
|
102
105
|
if options[:b]
|
103
|
-
lbopts[:buffer_size] = options[:b]
|
106
|
+
lbopts[:buffer_size] = options[:b].to_i
|
104
107
|
end
|
105
108
|
|
106
|
-
# SSL
|
109
|
+
# SSL arguments
|
107
110
|
ssl_cert_path = options["ssl-cert"]
|
108
111
|
ssl_key_path = options["ssl-key"]
|
109
112
|
remove_ssl = options["remove-ssl"]
|
@@ -132,6 +135,10 @@ module Brightbox
|
|
132
135
|
lbopts[:ssl_minimum_version] = options["ssl-min-ver"]
|
133
136
|
end
|
134
137
|
|
138
|
+
if options["acme_domains"]
|
139
|
+
lbopts[:domains] = options["acme_domains"].split(",")
|
140
|
+
end
|
141
|
+
|
135
142
|
lbopts.nilify_blanks
|
136
143
|
|
137
144
|
lb = LoadBalancer.find lb_id
|
data/lib/brightbox-cli/config.rb
CHANGED
data/lib/brightbox-cli/images.rb
CHANGED
@@ -16,7 +16,7 @@ module Brightbox
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.default_field_order
|
19
|
-
%i[id owner type created_on status size name]
|
19
|
+
%i[id owner type created_on status size arch name]
|
20
20
|
end
|
21
21
|
|
22
22
|
# Filter out images that are not of the right type, account or status if the option is passed
|
@@ -82,7 +82,7 @@ module Brightbox
|
|
82
82
|
o[:locked] = locked?
|
83
83
|
o[:username] = username
|
84
84
|
o[:arch] = arch
|
85
|
-
o[:name] = name.to_s
|
85
|
+
o[:name] = name.to_s
|
86
86
|
o[:owner] = owner_id
|
87
87
|
o[:owner] = "brightbox" if official
|
88
88
|
o[:type] = type
|
@@ -3,9 +3,24 @@ module Brightbox
|
|
3
3
|
def self.require_account?; true; end
|
4
4
|
|
5
5
|
def self.create(options)
|
6
|
+
options.delete(:buffer_size) if options[:buffer_size].nil?
|
7
|
+
options[:buffer_size] = options[:buffer_size].to_i if options[:buffer_size]
|
8
|
+
|
6
9
|
new(conn.load_balancers.create(options))
|
7
10
|
end
|
8
11
|
|
12
|
+
def acme_domains
|
13
|
+
if attributes["acme"]
|
14
|
+
attributes["acme"]["domains"].map do |domain|
|
15
|
+
[domain["identifier"], domain["status"]].join(":")
|
16
|
+
end.join(",")
|
17
|
+
else
|
18
|
+
[]
|
19
|
+
end
|
20
|
+
rescue StandardError
|
21
|
+
[]
|
22
|
+
end
|
23
|
+
|
9
24
|
def attributes
|
10
25
|
fog_model.attributes
|
11
26
|
end
|
@@ -13,6 +28,7 @@ module Brightbox
|
|
13
28
|
def to_row
|
14
29
|
attributes.merge(
|
15
30
|
:locked => locked?,
|
31
|
+
:acme_domains => acme_domains,
|
16
32
|
:ssl_minimum_version => ssl_minimum_version,
|
17
33
|
:ssl_issuer => certificate_issuer,
|
18
34
|
:ssl_subject => certificate_subject,
|
@@ -31,11 +47,13 @@ module Brightbox
|
|
31
47
|
end
|
32
48
|
|
33
49
|
def cloud_ip_ids
|
34
|
-
|
50
|
+
cips = attributes["cloud_ips"] || attributes[:cloud_ips]
|
51
|
+
@cloud_ip_ids ||= cips.map { |n| n["id"] } if cips
|
35
52
|
end
|
36
53
|
|
37
54
|
def cloud_ips
|
38
|
-
|
55
|
+
cips = attributes["cloud_ips"] || attributes[:cloud_ips]
|
56
|
+
@cloud_ips ||= cips.map { |n| n["public_ip"] } if cips
|
39
57
|
end
|
40
58
|
|
41
59
|
def listeners
|
@@ -45,7 +45,7 @@ module Brightbox
|
|
45
45
|
a[:status] = fog_model.state
|
46
46
|
a[:locked] = locked?
|
47
47
|
a[:zone] = zone && zone["handle"]
|
48
|
-
a[:hostname] =
|
48
|
+
a[:hostname] = hostname
|
49
49
|
a[:public_hostname] = "public.#{fqdn}" unless cloud_ips.empty?
|
50
50
|
a[:ipv6_hostname] = ipv6_fqdn if interfaces.any? { |i| i["ipv6_address"] }
|
51
51
|
a
|
@@ -11,20 +11,145 @@ describe "brightbox lbs" do
|
|
11
11
|
cache_access_token(config, "f83da712e6299cda953513ec07f7a754f747d727")
|
12
12
|
end
|
13
13
|
|
14
|
-
context "" do
|
14
|
+
context "without required nodes arguments" do
|
15
15
|
let(:argv) { %w[lbs create] }
|
16
16
|
|
17
17
|
it "does not error" do
|
18
18
|
expect { output }.to_not raise_error
|
19
|
+
|
20
|
+
expect(stderr).to eq("ERROR: You must specify which servers to balance connections to\n")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "with required nodes arguments" do
|
25
|
+
let(:argv) { %w[lbs create srv-12345] }
|
26
|
+
let(:expected_args) { { nodes: [{ node: "srv-12345" }] } }
|
27
|
+
|
28
|
+
let(:json_response) do
|
29
|
+
<<~EOS
|
30
|
+
{
|
31
|
+
"id": "lba-12345",
|
32
|
+
"nodes": [
|
33
|
+
{
|
34
|
+
"id": "srv-12345"
|
35
|
+
}
|
36
|
+
]
|
37
|
+
}
|
38
|
+
EOS
|
39
|
+
end
|
40
|
+
|
41
|
+
before do
|
42
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/load_balancers?account_id=acc-12345")
|
43
|
+
.with(:body => hash_including("nodes" => [{ "node" => "srv-12345" }]))
|
44
|
+
.to_return(:status => 202, :body => json_response)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "makes request" do
|
48
|
+
expect(Brightbox::LoadBalancer).to receive(:create).with(hash_including(expected_args)).and_call_original
|
49
|
+
|
50
|
+
expect(stderr).to eq("Creating a new load balancer\n")
|
51
|
+
expect(stdout).to include("lba-12345")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "with required nodes arguments" do
|
56
|
+
let(:argv) { %w[lbs create srv-12345] }
|
57
|
+
let(:expected_args) { { nodes: [{ node: "srv-12345" }] } }
|
58
|
+
|
59
|
+
let(:json_response) do
|
60
|
+
<<~EOS
|
61
|
+
{
|
62
|
+
"id": "lba-12345",
|
63
|
+
"nodes": [
|
64
|
+
{
|
65
|
+
"id": "srv-12345"
|
66
|
+
}
|
67
|
+
]
|
68
|
+
}
|
69
|
+
EOS
|
70
|
+
end
|
71
|
+
|
72
|
+
before do
|
73
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/load_balancers?account_id=acc-12345")
|
74
|
+
.with(:body => hash_including("nodes" => [{ "node" => "srv-12345" }]))
|
75
|
+
.to_return(:status => 202, :body => json_response)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "makes request" do
|
79
|
+
expect(Brightbox::LoadBalancer).to receive(:create).with(hash_including(expected_args)).and_call_original
|
80
|
+
|
81
|
+
expect(stderr).to eq("Creating a new load balancer\n")
|
82
|
+
expect(stdout).to include("lba-12345")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context "with multiple nodes" do
|
87
|
+
let(:argv) { %w[lbs create srv-12345 srv-54321] }
|
88
|
+
let(:expected_args) { { nodes: [{ node: "srv-12345" }, { node: "srv-54321" }] } }
|
89
|
+
|
90
|
+
let(:json_response) do
|
91
|
+
<<~EOS
|
92
|
+
{
|
93
|
+
"id": "lba-12345",
|
94
|
+
"nodes": [
|
95
|
+
{
|
96
|
+
"id": "srv-12345"
|
97
|
+
},
|
98
|
+
{
|
99
|
+
"id": "srv-54321"
|
100
|
+
}
|
101
|
+
]
|
102
|
+
}
|
103
|
+
EOS
|
104
|
+
end
|
105
|
+
|
106
|
+
before do
|
107
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/load_balancers?account_id=acc-12345")
|
108
|
+
.with(:body => hash_including("nodes" => [{ "node" => "srv-12345" }, { "node" => "srv-54321" }]))
|
109
|
+
.to_return(:status => 202, :body => json_response)
|
110
|
+
end
|
111
|
+
|
112
|
+
it "makes request" do
|
113
|
+
expect(Brightbox::LoadBalancer).to receive(:create).with(hash_including(expected_args)).and_call_original
|
114
|
+
|
115
|
+
expect(stderr).to eq("Creating a new load balancer\n")
|
116
|
+
expect(stdout).to include("lba-12345")
|
19
117
|
end
|
20
118
|
end
|
21
119
|
|
22
|
-
context "--
|
120
|
+
context "with --buffer_size" do
|
121
|
+
let(:argv) { %w[lbs create --buffer-size 1024 srv-12345] }
|
122
|
+
let(:expected_args) { { nodes: [{ node: "srv-12345" }], buffer_size: 1024 } }
|
123
|
+
|
124
|
+
let(:json_response) do
|
125
|
+
<<~EOS
|
126
|
+
{
|
127
|
+
"id": "lba-12345",
|
128
|
+
"buffer_size": 1024
|
129
|
+
}
|
130
|
+
EOS
|
131
|
+
end
|
132
|
+
|
133
|
+
before do
|
134
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/load_balancers?account_id=acc-12345")
|
135
|
+
.with(:body => hash_including("buffer_size" => 1024))
|
136
|
+
.to_return(:status => 202, :body => json_response)
|
137
|
+
end
|
138
|
+
|
139
|
+
it "includes buffer_size in response" do
|
140
|
+
expect(Brightbox::LoadBalancer).to receive(:create).with(hash_including(expected_args)).and_call_original
|
141
|
+
|
142
|
+
expect(stderr).to eq("Creating a new load balancer\n")
|
143
|
+
expect(stdout).to include("lba-12345")
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context "with --ssl-min-ver=TLSv1.0" do
|
23
148
|
let(:argv) { ["lbs", "create", "--ssl-min-ver", "TLSv1.0", "srv-12345"] }
|
24
149
|
let(:expected_args) { { ssl_minimum_version: "TLSv1.0" } }
|
25
150
|
|
26
151
|
let(:json_response) do
|
27
|
-
|
152
|
+
<<~EOS
|
28
153
|
{
|
29
154
|
"id":"lba-12345",
|
30
155
|
"ssl_minimum_version":"TLSv1.0"
|
@@ -44,5 +169,46 @@ describe "brightbox lbs" do
|
|
44
169
|
expect(stdout).to include("lba-12345")
|
45
170
|
end
|
46
171
|
end
|
172
|
+
|
173
|
+
context "--acme-domains=example.com" do
|
174
|
+
let(:argv) { ["lbs", "create", "--acme-domains", "example.com", "--listeners", "443:443:https:5000", "lba-12345"] }
|
175
|
+
let(:json_response) do
|
176
|
+
<<~EOS
|
177
|
+
{
|
178
|
+
"id":"lba-12345",
|
179
|
+
"acme": {
|
180
|
+
"domains": [
|
181
|
+
{
|
182
|
+
"identifier": "example.com",
|
183
|
+
"last_message": null,
|
184
|
+
"status": "pending"
|
185
|
+
}
|
186
|
+
]
|
187
|
+
},
|
188
|
+
"certificate": null,
|
189
|
+
"listeners": [
|
190
|
+
{
|
191
|
+
"in": 443,
|
192
|
+
"out": 443,
|
193
|
+
"protocol": "https",
|
194
|
+
"proxy_protocol": null,
|
195
|
+
"timeout": 5000
|
196
|
+
}
|
197
|
+
]
|
198
|
+
}
|
199
|
+
EOS
|
200
|
+
end
|
201
|
+
|
202
|
+
before do
|
203
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/load_balancers?account_id=acc-12345")
|
204
|
+
.with(body: hash_including(domains: ["example.com"]))
|
205
|
+
.to_return(:status => 202, :body => json_response)
|
206
|
+
end
|
207
|
+
|
208
|
+
it "includes acme_certificate_domain in response" do
|
209
|
+
expect(stderr).to eq("Creating a new load balancer\n")
|
210
|
+
expect(stdout).to include("lba-12345")
|
211
|
+
end
|
212
|
+
end
|
47
213
|
end
|
48
214
|
end
|
@@ -6,11 +6,95 @@ describe "brightbox lbs" do
|
|
6
6
|
let(:stdout) { output.stdout }
|
7
7
|
let(:stderr) { output.stderr }
|
8
8
|
|
9
|
-
|
9
|
+
before do
|
10
|
+
config = config_from_contents(USER_APP_CONFIG_CONTENTS)
|
11
|
+
cache_access_token(config, "f83da712e6299cda953513ec07f7a754f747d727")
|
12
|
+
end
|
13
|
+
|
14
|
+
context "without identifier argument" do
|
10
15
|
let(:argv) { %w[lbs show] }
|
16
|
+
let(:json_response) do
|
17
|
+
<<~EOS
|
18
|
+
[
|
19
|
+
{
|
20
|
+
"id":"lba-12345",
|
21
|
+
"name":"app-lb1",
|
22
|
+
"status":"active",
|
23
|
+
"created_at":"2012-03-05T12:00:00Z",
|
24
|
+
"nodes":[
|
25
|
+
{
|
26
|
+
"id":"srv-12345",
|
27
|
+
"status":"active"
|
28
|
+
}
|
29
|
+
]
|
30
|
+
}
|
31
|
+
]
|
32
|
+
EOS
|
33
|
+
end
|
34
|
+
|
35
|
+
before do
|
36
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/load_balancers?account_id=acc-12345")
|
37
|
+
.to_return(:status => 200, :body => json_response)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "shows load balancer details" do
|
41
|
+
aggregate_failures do
|
42
|
+
expect(stderr).to eq("")
|
43
|
+
expect(stdout).to include("id: lba-12345")
|
44
|
+
expect(stdout).to include("status: active")
|
45
|
+
expect(stdout).to include("name: app-lb1")
|
46
|
+
expect(stdout).to include("created_at: 2012-03-05T12:00Z")
|
47
|
+
expect(stdout).to include("nodes: srv-12345")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "with identifier argument" do
|
53
|
+
let(:argv) { %w[lbs show lba-12345] }
|
54
|
+
let(:json_response) do
|
55
|
+
<<~EOS
|
56
|
+
{
|
57
|
+
"id":"lba-12345",
|
58
|
+
"name":"app-lb1",
|
59
|
+
"status":"active",
|
60
|
+
"created_at":"2012-03-05T12:00:00Z",
|
61
|
+
"acme": {
|
62
|
+
"domains": [
|
63
|
+
{
|
64
|
+
"identifier": "domain.test",
|
65
|
+
"status": "verified"
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"identifier": "domain2.test",
|
69
|
+
"status": "verified"
|
70
|
+
}
|
71
|
+
]
|
72
|
+
},
|
73
|
+
"nodes":[
|
74
|
+
{
|
75
|
+
"id":"srv-12345",
|
76
|
+
"status":"active"
|
77
|
+
}
|
78
|
+
]
|
79
|
+
}
|
80
|
+
EOS
|
81
|
+
end
|
82
|
+
|
83
|
+
before do
|
84
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/load_balancers/lba-12345?account_id=acc-12345")
|
85
|
+
.to_return(:status => 200, :body => json_response)
|
86
|
+
end
|
11
87
|
|
12
|
-
it "
|
13
|
-
|
88
|
+
it "shows load balancer details" do
|
89
|
+
aggregate_failures do
|
90
|
+
expect(stderr).to eq("")
|
91
|
+
expect(stdout).to include("id: lba-12345")
|
92
|
+
expect(stdout).to include("status: active")
|
93
|
+
expect(stdout).to include("name: app-lb1")
|
94
|
+
expect(stdout).to include("created_at: 2012-03-05T12:00Z")
|
95
|
+
expect(stdout).to include("nodes: srv-12345")
|
96
|
+
expect(stdout).to include("acme_domains: domain.test:verified,domain2.test:verified")
|
97
|
+
end
|
14
98
|
end
|
15
99
|
end
|
16
100
|
end
|
@@ -23,7 +23,7 @@ describe "brightbox lbs" do
|
|
23
23
|
let(:argv) { ["lbs", "update", "--ssl-min-ver", "TLSv1.0", "lba-12345"] }
|
24
24
|
|
25
25
|
let(:json_response) do
|
26
|
-
|
26
|
+
<<~EOS
|
27
27
|
{
|
28
28
|
"id":"lba-12345",
|
29
29
|
"ssl_minimum_version":"TLSv1.0"
|
@@ -50,7 +50,7 @@ describe "brightbox lbs" do
|
|
50
50
|
let(:argv) { ["lbs", "update", "--sslv3", "lba-grt24"] }
|
51
51
|
|
52
52
|
let(:json_response) do
|
53
|
-
|
53
|
+
<<~EOS
|
54
54
|
{
|
55
55
|
"id":"lba-grt24",
|
56
56
|
"ssl_minimum_version":"TLSv1.0"
|
@@ -77,7 +77,7 @@ describe "brightbox lbs" do
|
|
77
77
|
let(:argv) { ["lbs", "update", "--no-sslv3", "lba-kl432"] }
|
78
78
|
|
79
79
|
let(:json_response) do
|
80
|
-
|
80
|
+
<<~EOS
|
81
81
|
{
|
82
82
|
"id":"lba-kl432",
|
83
83
|
"ssl_minimum_version":"TLSv1.0"
|
@@ -99,5 +99,49 @@ describe "brightbox lbs" do
|
|
99
99
|
expect(stdout).to include("lba-kl432")
|
100
100
|
end
|
101
101
|
end
|
102
|
+
|
103
|
+
context "--acme-domains=example.com" do
|
104
|
+
let(:argv) { ["lbs", "update", "--acme-domains", "example.com", "--listeners", "443:443:https:5000", "lba-12345"] }
|
105
|
+
let(:json_response) do
|
106
|
+
<<~EOS
|
107
|
+
{
|
108
|
+
"id":"lba-12345",
|
109
|
+
"acme": {
|
110
|
+
"domains": [
|
111
|
+
{
|
112
|
+
"identifier": "example.com",
|
113
|
+
"last_message": null,
|
114
|
+
"status": "pending"
|
115
|
+
}
|
116
|
+
]
|
117
|
+
},
|
118
|
+
"certificate": null,
|
119
|
+
"listeners": [
|
120
|
+
{
|
121
|
+
"in": 443,
|
122
|
+
"out": 443,
|
123
|
+
"protocol": "https",
|
124
|
+
"proxy_protocol": null,
|
125
|
+
"timeout": 5000
|
126
|
+
}
|
127
|
+
]
|
128
|
+
}
|
129
|
+
EOS
|
130
|
+
end
|
131
|
+
|
132
|
+
before do
|
133
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/load_balancers/lba-12345?account_id=acc-12345")
|
134
|
+
.to_return(:status => 200, :body => '{"id":"lba-12345"}')
|
135
|
+
|
136
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/load_balancers/lba-12345?account_id=acc-12345")
|
137
|
+
.with(body: hash_including(domains: ["example.com"]))
|
138
|
+
.to_return(:status => 202, :body => json_response)
|
139
|
+
end
|
140
|
+
|
141
|
+
it "includes acme_certificate_domain in response" do
|
142
|
+
expect(stderr).to eq("Updating load balancer lba-12345\n")
|
143
|
+
expect(stdout).to include("lba-12345")
|
144
|
+
end
|
145
|
+
end
|
102
146
|
end
|
103
147
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,6 +3,7 @@ LIB_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
|
|
3
3
|
$LOAD_PATH.unshift LIB_DIR unless
|
4
4
|
$LOAD_PATH.include?(LIB_DIR) || $LOAD_PATH.include?(File.expand_path(LIB_DIR))
|
5
5
|
|
6
|
+
require "simplecov"
|
6
7
|
require "brightbox_cli"
|
7
8
|
require "json"
|
8
9
|
require "tmpdir"
|
@@ -28,6 +29,17 @@ TEST_RUNNER_HOME = ENV.fetch("HOME", nil)
|
|
28
29
|
# Reduce the default fog timeout
|
29
30
|
Fog.timeout = 10
|
30
31
|
|
32
|
+
require "fog/brightbox"
|
33
|
+
|
34
|
+
SimpleCov.start do
|
35
|
+
add_filter "/spec/"
|
36
|
+
add_filter "/config/"
|
37
|
+
add_filter "/vendor/"
|
38
|
+
end
|
39
|
+
|
40
|
+
# Currently just above 80% coverage - don't make it worse
|
41
|
+
SimpleCov.minimum_coverage 80
|
42
|
+
|
31
43
|
RSpec.configure do |config|
|
32
44
|
config.include CommonHelpers
|
33
45
|
config.include ConfigHelpers
|
@@ -2,25 +2,45 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Brightbox::BBConfig do
|
4
4
|
describe "#config_directory" do
|
5
|
+
context "when HOME is not set" do
|
6
|
+
let(:working_dir) { Dir.mktmpdir("working") }
|
7
|
+
|
8
|
+
before do
|
9
|
+
allow(Dir).to receive(:pwd).and_return(working_dir)
|
10
|
+
allow(ENV).to receive(:fetch).with("HOME", nil).and_return(nil)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns current directory" do
|
14
|
+
config = Brightbox::BBConfig.new
|
15
|
+
|
16
|
+
expect(config.config_directory).to start_with(working_dir)
|
17
|
+
expect(config.config_directory).to end_with(".brightbox")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
5
21
|
context "when default location is used" do
|
6
22
|
it "returns a String of the users `.brightbox` directory" do
|
7
23
|
config = Brightbox::BBConfig.new
|
8
24
|
|
9
25
|
expanded_path = File.expand_path("~/.brightbox")
|
10
|
-
expect(config.config_directory).to
|
26
|
+
expect(config.config_directory).to eq(expanded_path)
|
11
27
|
end
|
12
28
|
end
|
13
29
|
|
14
30
|
context "when absolute custom location is set" do
|
15
31
|
let(:custom_dir) { Dir.mktmpdir("custom") }
|
16
32
|
|
33
|
+
after do
|
34
|
+
FileUtils.rm_rf(custom_dir)
|
35
|
+
end
|
36
|
+
|
17
37
|
it "returns a String of the expanded directory" do
|
18
38
|
config_options = {
|
19
39
|
:directory => custom_dir
|
20
40
|
}
|
21
41
|
config = Brightbox::BBConfig.new(config_options)
|
22
42
|
|
23
|
-
expect(config.config_directory).to
|
43
|
+
expect(config.config_directory).to eq(custom_dir)
|
24
44
|
end
|
25
45
|
end
|
26
46
|
|
@@ -32,7 +52,7 @@ describe Brightbox::BBConfig do
|
|
32
52
|
config = Brightbox::BBConfig.new(config_options)
|
33
53
|
|
34
54
|
expanded_path = File.expand_path("~/.cli_config")
|
35
|
-
expect(config.config_directory).to
|
55
|
+
expect(config.config_directory).to eq(expanded_path)
|
36
56
|
end
|
37
57
|
end
|
38
58
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fog/brightbox/models/compute/server"
|
3
|
+
|
4
|
+
RSpec.describe Brightbox::Server, "#hostname" do
|
5
|
+
let(:fog_model) { Fog::Brightbox::Compute::Server.new(fog_settings) }
|
6
|
+
let(:server) { described_class.new(fog_model) }
|
7
|
+
|
8
|
+
context "when hostname is not equal to id" do
|
9
|
+
let(:fog_settings) do
|
10
|
+
{
|
11
|
+
id: "srv-12345",
|
12
|
+
cloud_ips: [],
|
13
|
+
hostname: "server-hostname",
|
14
|
+
image_id: "img-12345",
|
15
|
+
interfaces: [],
|
16
|
+
server_type: "typ-12345"
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
it "returns the hostname" do
|
21
|
+
expect(server.attributes[:id]).to eq("srv-12345")
|
22
|
+
expect(server.attributes[:hostname]).to eq("server-hostname")
|
23
|
+
|
24
|
+
expect(server.hostname).to eq("server-hostname")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
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
|
+
version: 5.0.0.alpha
|
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: 2024-
|
12
|
+
date: 2024-12-11 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.
|
20
|
+
version: 1.12.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.
|
27
|
+
version: 1.12.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: fog-core
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,21 +130,21 @@ dependencies:
|
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '1.11'
|
132
132
|
- !ruby/object:Gem::Dependency
|
133
|
-
name:
|
133
|
+
name: mocha
|
134
134
|
requirement: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0
|
139
|
-
type: :
|
138
|
+
version: '0'
|
139
|
+
type: :development
|
140
140
|
prerelease: false
|
141
141
|
version_requirements: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0
|
145
|
+
version: '0'
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
|
-
name:
|
147
|
+
name: pry-remote
|
148
148
|
requirement: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - ">="
|
@@ -158,7 +158,7 @@ dependencies:
|
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0'
|
160
160
|
- !ruby/object:Gem::Dependency
|
161
|
-
name:
|
161
|
+
name: rake
|
162
162
|
requirement: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - ">="
|
@@ -172,7 +172,7 @@ dependencies:
|
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '0'
|
174
174
|
- !ruby/object:Gem::Dependency
|
175
|
-
name:
|
175
|
+
name: rspec
|
176
176
|
requirement: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - ">="
|
@@ -186,7 +186,7 @@ dependencies:
|
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
- !ruby/object:Gem::Dependency
|
189
|
-
name:
|
189
|
+
name: rubocop
|
190
190
|
requirement: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
192
|
- - ">="
|
@@ -200,7 +200,7 @@ dependencies:
|
|
200
200
|
- !ruby/object:Gem::Version
|
201
201
|
version: '0'
|
202
202
|
- !ruby/object:Gem::Dependency
|
203
|
-
name: rubocop
|
203
|
+
name: rubocop-rake
|
204
204
|
requirement: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
206
|
- - ">="
|
@@ -214,7 +214,7 @@ dependencies:
|
|
214
214
|
- !ruby/object:Gem::Version
|
215
215
|
version: '0'
|
216
216
|
- !ruby/object:Gem::Dependency
|
217
|
-
name: rubocop-
|
217
|
+
name: rubocop-rspec
|
218
218
|
requirement: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
220
|
- - ">="
|
@@ -228,7 +228,7 @@ dependencies:
|
|
228
228
|
- !ruby/object:Gem::Version
|
229
229
|
version: '0'
|
230
230
|
- !ruby/object:Gem::Dependency
|
231
|
-
name:
|
231
|
+
name: simplecov
|
232
232
|
requirement: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
234
|
- - ">="
|
@@ -781,6 +781,7 @@ files:
|
|
781
781
|
- spec/unit/brightbox/server/destroy_spec.rb
|
782
782
|
- spec/unit/brightbox/server/find_or_call_spec.rb
|
783
783
|
- spec/unit/brightbox/server/find_spec.rb
|
784
|
+
- spec/unit/brightbox/server/hostname_spec.rb
|
784
785
|
- spec/unit/brightbox/server/shutdown_spec.rb
|
785
786
|
- spec/unit/brightbox/server/start_spec.rb
|
786
787
|
- spec/unit/brightbox/server/stop_spec.rb
|
@@ -812,14 +813,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
812
813
|
requirements:
|
813
814
|
- - ">="
|
814
815
|
- !ruby/object:Gem::Version
|
815
|
-
version: '2.
|
816
|
+
version: '2.7'
|
816
817
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
817
818
|
requirements:
|
818
|
-
- - "
|
819
|
+
- - ">"
|
819
820
|
- !ruby/object:Gem::Version
|
820
|
-
version:
|
821
|
+
version: 1.3.1
|
821
822
|
requirements: []
|
822
|
-
rubygems_version: 3.
|
823
|
+
rubygems_version: 3.4.19
|
823
824
|
signing_key:
|
824
825
|
specification_version: 4
|
825
826
|
summary: The Brightbox cloud management system
|
@@ -1149,6 +1150,7 @@ test_files:
|
|
1149
1150
|
- spec/unit/brightbox/server/destroy_spec.rb
|
1150
1151
|
- spec/unit/brightbox/server/find_or_call_spec.rb
|
1151
1152
|
- spec/unit/brightbox/server/find_spec.rb
|
1153
|
+
- spec/unit/brightbox/server/hostname_spec.rb
|
1152
1154
|
- spec/unit/brightbox/server/shutdown_spec.rb
|
1153
1155
|
- spec/unit/brightbox/server/start_spec.rb
|
1154
1156
|
- spec/unit/brightbox/server/stop_spec.rb
|