Skip to content

Commit 61b6bae

Browse files
lukasmetznerphm07
authored andcommitted
fix: storage box type snapshot limit type
`snapshot_limit` and `automatic_snapshot_limit` are pointers now.
1 parent b13dd80 commit 61b6bae

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
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ Displays a list of Storage Box Types.
88

99
Output can be controlled with the -o flag. Use -o noheader to suppress the
1010
table header. Displayed columns and their order can be set with
11-
-o columns=deprecated,description (see available columns below).
11+
-o columns=automatic_snapshot_limit,deprecated (see available columns below).
1212

1313
Columns:
14+
- automatic_snapshot_limit
1415
- deprecated
1516
- description
1617
- id
1718
- name
1819
- size
20+
- snapshot_limit
1921
- subaccounts_limit
2022

2123
```

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)