Skip to content

Commit 45cff28

Browse files
committed
Display private deprecated images as "private"
A UI change to report private images that are now deprecated as `private` in the CLI to prevent adding an entire meta-state on top of the real status as two settings have become conflated.
1 parent 0a28d74 commit 45cff28

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

lib/brightbox-cli/images.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ def type
7070
def status
7171
if fog_model.attributes[:status] == "available"
7272
public? ? "public" : "private"
73+
elsif fog_model.attributes[:status] == "deprecated"
74+
public? ? "deprecated" : "private"
7375
else
7476
fog_model.attributes[:status]
7577
end
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
require "spec_helper"
2+
3+
RSpec.describe Brightbox::Image, "#status" do
4+
subject(:image) { Brightbox::Image.new(fog_model) }
5+
6+
let(:fog_model) do
7+
double(
8+
"Fog::Compute::Brightbox::Image",
9+
id: "img-12345",
10+
attributes: {
11+
"id": "img-12345",
12+
"status": status,
13+
"public": is_public
14+
},
15+
public: is_public
16+
)
17+
end
18+
let(:is_public) { false }
19+
20+
context "when the image is pending" do
21+
let(:status) { "pending" }
22+
23+
it "returns 'pending'" do
24+
expect(image.status).to eq("pending")
25+
end
26+
end
27+
28+
context "when the image is available" do
29+
let(:status) { "available" }
30+
31+
context "with public visibility" do
32+
let(:is_public) { true }
33+
34+
it "returns 'public'" do
35+
expect(image.status).to eq("public")
36+
end
37+
end
38+
39+
context "without public visibility" do
40+
let(:is_public) { false }
41+
42+
it "returns 'private'" do
43+
expect(image.status).to eq("private")
44+
end
45+
end
46+
end
47+
48+
context "when the image is deprecated" do
49+
let(:status) { "deprecated" }
50+
51+
context "with public visibility" do
52+
let(:is_public) { true }
53+
54+
it "returns 'deprecated'" do
55+
expect(image.status).to eq("deprecated")
56+
end
57+
end
58+
59+
context "without public visibility" do
60+
let(:is_public) { false }
61+
62+
it "returns 'private'" do
63+
expect(image.status).to eq("private")
64+
end
65+
end
66+
end
67+
end

0 commit comments

Comments
 (0)