Skip to content

Commit

Permalink
Use API hostname and not hardcoded value
Browse files Browse the repository at this point in the history
  • Loading branch information
tokengeek committed Dec 4, 2024
1 parent 596c862 commit 00be0e5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/brightbox-cli/servers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def attributes
a[:status] = fog_model.state
a[:locked] = locked?
a[:zone] = zone && zone["handle"]
a[:hostname] = id
a[:hostname] = hostname
a[:public_hostname] = "public.#{fqdn}" unless cloud_ips.empty?
a[:ipv6_hostname] = ipv6_fqdn if interfaces.any? { |i| i["ipv6_address"] }
a
Expand Down
27 changes: 27 additions & 0 deletions spec/unit/brightbox/server/hostname_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require "spec_helper"
require "fog/brightbox/models/compute/server"

RSpec.describe Brightbox::Server, "#hostname" do
let(:fog_model) { Fog::Brightbox::Compute::Server.new(fog_settings) }
let(:server) { described_class.new(fog_model) }

context "when hostname is not equal to id" do
let(:fog_settings) do
{
id: "srv-12345",
cloud_ips: [],
hostname: "server-hostname",
image_id: "img-12345",
interfaces: [],
server_type: "typ-12345"
}
end

it "returns the hostname" do
expect(server.attributes[:id]).to eq("srv-12345")
expect(server.attributes[:hostname]).to eq("server-hostname")

expect(server.hostname).to eq("server-hostname")
end
end
end

0 comments on commit 00be0e5

Please sign in to comment.