Skip to content

Commit 2ef1ff3

Browse files
authored
feat(iaas): show image status on image describe (#1317)
relates to STACKITCLI-231 and #908
1 parent 9e242dc commit 2ef1ff3

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

internal/cmd/image/describe/describe.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,16 @@ func outputResult(p *print.Printer, outputFormat string, resp *iaas.Image) error
9696
table := tables.NewTable()
9797
if id := resp.Id; id != nil {
9898
table.AddRow("ID", *id)
99+
table.AddSeparator()
99100
}
100-
table.AddSeparator()
101-
102101
if name := resp.Name; name != nil {
103102
table.AddRow("NAME", *name)
104103
table.AddSeparator()
105104
}
105+
if status := resp.Status; status != nil {
106+
table.AddRow("STATUS", *status)
107+
table.AddSeparator()
108+
}
106109
if format := resp.DiskFormat; format != nil {
107110
table.AddRow("FORMAT", *format)
108111
table.AddSeparator()

internal/cmd/image/describe/describe_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
8+
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
89

910
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1011
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
@@ -225,6 +226,33 @@ func TestOutputResult(t *testing.T) {
225226
args: args{},
226227
wantErr: true,
227228
},
229+
{
230+
name: "valid value",
231+
args: args{
232+
resp: &iaas.Image{
233+
Id: utils.Ptr(uuid.NewString()),
234+
Name: utils.Ptr("Image"),
235+
Status: utils.Ptr("STATUS"),
236+
DiskFormat: utils.Ptr("format"),
237+
MinDiskSize: utils.Ptr(int64(0)),
238+
MinRam: utils.Ptr(int64(0)),
239+
Config: &iaas.ImageConfig{
240+
Architecture: utils.Ptr("architecture"),
241+
OperatingSystem: utils.Ptr("os"),
242+
OperatingSystemDistro: iaas.NewNullableString(utils.Ptr("os distro")),
243+
OperatingSystemVersion: iaas.NewNullableString(utils.Ptr("0.00.0")),
244+
Uefi: utils.Ptr(true),
245+
},
246+
Labels: utils.Ptr(map[string]any{
247+
"label1": true,
248+
"label2": false,
249+
"label3": 42,
250+
"foo": "bar",
251+
}),
252+
},
253+
},
254+
wantErr: false,
255+
},
228256
}
229257
p := print.NewPrinter()
230258
p.Cmd = NewCmd(&types.CmdParams{Printer: p})

0 commit comments

Comments
 (0)