Skip to content

Commit 1640792

Browse files
feat(sfs): show usedBySnapshotsGB in resource-pool list/describe (#1400)
* feat(sfs): show usedBySnapshotsGB in resource-pool list/describe STACKITCLI-397 * fix(sfs): resource-pool describe_test import order
1 parent f6c5649 commit 1640792

4 files changed

Lines changed: 46 additions & 2 deletions

File tree

internal/cmd/beta/sfs/resource-pool/describe/describe.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ func outputResult(p *print.Printer, outputFormat, resourcePoolId, projectLabel s
140140
table.AddSeparator()
141141
table.AddRow("USED SIZE (GB)", utils.PtrString(resourcePool.Space.UsedGigabytes.Get()))
142142
table.AddSeparator()
143+
table.AddRow("USED BY SNAPSHOTS (GB)", utils.PtrString(resourcePool.Space.UsedBySnapshotsGigabytes.Get()))
144+
table.AddSeparator()
143145
}
144146
table.AddRow("STATE", utils.PtrString(resourcePool.State))
145147
table.AddSeparator()

internal/cmd/beta/sfs/resource-pool/describe/describe_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"github.com/google/uuid"
1010
sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api"
1111

12+
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
13+
1214
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1315
"github.com/stackitcloud/stackit-cli/internal/pkg/testparams"
1416
"github.com/stackitcloud/stackit-cli/internal/pkg/testutils"
@@ -197,6 +199,24 @@ func TestOutputResult(t *testing.T) {
197199
},
198200
wantErr: false,
199201
},
202+
{
203+
name: "full response",
204+
args: args{
205+
resp: &sfs.ResourcePool{
206+
Id: utils.Ptr("id"),
207+
Name: utils.Ptr("name"),
208+
AvailabilityZone: utils.Ptr("az"),
209+
State: utils.Ptr("state"),
210+
Space: &sfs.ResourcePoolSpace{
211+
SizeGigabytes: utils.Ptr(int32(100)),
212+
AvailableGigabytes: *sfs.NewNullableFloat64(utils.Ptr(float64(50))),
213+
UsedGigabytes: *sfs.NewNullableFloat64(utils.Ptr(float64(50))),
214+
UsedBySnapshotsGigabytes: *sfs.NewNullableFloat64(utils.Ptr(float64(10))),
215+
},
216+
},
217+
},
218+
wantErr: false,
219+
},
200220
}
201221

202222
params := testparams.NewTestParams()

internal/cmd/beta/sfs/resource-pool/list/list.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,13 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, resourceP
128128
}
129129

130130
table := tables.NewTable()
131-
table.SetHeader("ID", "NAME", "AVAILABILITY ZONE", "STATE", "TOTAL SIZE (GB)", "USED SIZE (GB)")
131+
table.SetHeader("ID", "NAME", "AVAILABILITY ZONE", "STATE", "TOTAL SIZE (GB)", "USED SIZE (GB)", "USED BY SNAPSHOTS (GB)")
132132
for _, resourcePool := range resourcePools {
133-
totalSizeGigabytes, usedSizeGigabytes := "", ""
133+
totalSizeGigabytes, usedSizeGigabytes, usedBySnapshotsGigabytes := "", "", ""
134134
if resourcePool.HasSpace() {
135135
totalSizeGigabytes = utils.PtrString(resourcePool.Space.SizeGigabytes)
136136
usedSizeGigabytes = utils.PtrString(resourcePool.Space.UsedGigabytes.Get())
137+
usedBySnapshotsGigabytes = utils.PtrString(resourcePool.Space.UsedBySnapshotsGigabytes.Get())
137138
}
138139
table.AddRow(
139140
utils.PtrString(resourcePool.Id),
@@ -142,6 +143,7 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, resourceP
142143
utils.PtrString(resourcePool.State),
143144
totalSizeGigabytes,
144145
usedSizeGigabytes,
146+
usedBySnapshotsGigabytes,
145147
)
146148
}
147149
err := table.Display(p)

internal/cmd/beta/sfs/resource-pool/list/list_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,26 @@ func TestOutputResult(t *testing.T) {
185185
},
186186
wantErr: false,
187187
},
188+
{
189+
name: "values",
190+
args: args{
191+
resourcePools: []sfs.ResourcePool{
192+
{
193+
Id: utils.Ptr("id"),
194+
Name: utils.Ptr("name"),
195+
AvailabilityZone: utils.Ptr("az"),
196+
State: utils.Ptr("state"),
197+
Space: &sfs.ResourcePoolSpace{
198+
SizeGigabytes: utils.Ptr(int32(100)),
199+
AvailableGigabytes: *sfs.NewNullableFloat64(utils.Ptr(float64(50))),
200+
UsedGigabytes: *sfs.NewNullableFloat64(utils.Ptr(float64(50))),
201+
UsedBySnapshotsGigabytes: *sfs.NewNullableFloat64(utils.Ptr(float64(10))),
202+
},
203+
},
204+
},
205+
},
206+
wantErr: false,
207+
},
188208
}
189209

190210
params := testparams.NewTestParams()

0 commit comments

Comments
 (0)