Skip to content

Commit 6c47144

Browse files
lukasmetznerapricote
authored andcommitted
fix: storage box type snapshot limit type
`snapshot_limit` and `automatic_snapshot_limit` are pointers now.
1 parent b2223ab commit 6c47144

File tree

5 files changed

+29
-7
lines changed

5 files changed

+29
-7
lines changed

docs/reference/manual/hcloud_storage-box-type_list.md

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cmd/storageboxtype/describe.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ var DescribeCmd = base.DescribeCmd[*hcloud.StorageBoxType]{
2727
cmd.Printf("Name:\t\t\t\t%s\n", storageBoxType.Name)
2828
cmd.Printf("Description:\t\t\t%s\n", storageBoxType.Description)
2929
cmd.Printf("Size:\t\t\t\t%s\n", humanize.IBytes(uint64(storageBoxType.Size)))
30-
cmd.Printf("Snapshot Limit:\t\t\t%d\n", storageBoxType.SnapshotLimit)
31-
cmd.Printf("Automatic Snapshot Limit:\t%d\n", storageBoxType.AutomaticSnapshotLimit)
30+
if storageBoxType.SnapshotLimit != nil {
31+
cmd.Printf("Snapshot Limit:\t\t\t%d\n", *storageBoxType.SnapshotLimit)
32+
}
33+
if storageBoxType.AutomaticSnapshotLimit != nil {
34+
cmd.Printf("Automatic Snapshot Limit:\t%d\n", *storageBoxType.AutomaticSnapshotLimit)
35+
}
3236
cmd.Printf("Subaccounts Limit:\t\t%d\n", storageBoxType.SubaccountsLimit)
3337
cmd.Print(util.DescribeDeprecation(storageBoxType))
3438

internal/cmd/storageboxtype/describe_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ func TestDescribe(t *testing.T) {
2525
ID: 42,
2626
Name: "bx11",
2727
Description: "BX11",
28-
SnapshotLimit: 10,
29-
AutomaticSnapshotLimit: 10,
28+
SnapshotLimit: hcloud.Ptr(10),
29+
AutomaticSnapshotLimit: hcloud.Ptr(10),
3030
SubaccountsLimit: 200,
3131
Size: 1073741824,
3232
Pricings: []hcloud.StorageBoxTypeLocationPricing{

internal/cmd/storageboxtype/list.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package storageboxtype
22

33
import (
4+
"strconv"
5+
46
"github.com/dustin/go-humanize"
57
"github.com/spf13/pflag"
68

@@ -37,6 +39,20 @@ var ListCmd = base.ListCmd[*hcloud.StorageBoxType, schema.StorageBoxType]{
3739
return "-"
3840
}
3941
return util.Datetime(storageBoxType.UnavailableAfter())
42+
}).
43+
AddFieldFn("snapshot_limit", func(obj interface{}) string {
44+
storageBoxType := obj.(*hcloud.StorageBoxType)
45+
if storageBoxType.SnapshotLimit == nil {
46+
return "-"
47+
}
48+
return strconv.Itoa(*storageBoxType.SnapshotLimit)
49+
}).
50+
AddFieldFn("automatic_snapshot_limit", func(obj interface{}) string {
51+
storageBoxType := obj.(*hcloud.StorageBoxType)
52+
if storageBoxType.AutomaticSnapshotLimit == nil {
53+
return "-"
54+
}
55+
return strconv.Itoa(*storageBoxType.AutomaticSnapshotLimit)
4056
})
4157
},
4258

internal/cmd/storageboxtype/list_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ func TestList(t *testing.T) {
3434
ID: 42,
3535
Name: "bx11",
3636
Description: "BX11",
37-
SnapshotLimit: 10,
38-
AutomaticSnapshotLimit: 10,
37+
SnapshotLimit: hcloud.Ptr(10),
38+
AutomaticSnapshotLimit: hcloud.Ptr(10),
3939
SubaccountsLimit: 200,
4040
Size: 1073741824,
4141
Pricings: []hcloud.StorageBoxTypeLocationPricing{},

0 commit comments

Comments
 (0)