From a049cfa1c643cbdc3fff3174e389c0c917787cd3 Mon Sep 17 00:00:00 2001 From: Carlo Goetz Date: Fri, 8 May 2026 17:04:29 +0200 Subject: [PATCH 1/2] feat(sfs): show usedBySnapshotsGB in resource-pool list/describe STACKITCLI-397 --- .../sfs/resource-pool/describe/describe.go | 2 ++ .../resource-pool/describe/describe_test.go | 19 ++++++++++++++++++ .../cmd/beta/sfs/resource-pool/list/list.go | 6 ++++-- .../beta/sfs/resource-pool/list/list_test.go | 20 +++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/internal/cmd/beta/sfs/resource-pool/describe/describe.go b/internal/cmd/beta/sfs/resource-pool/describe/describe.go index c3a451fae..c057b5674 100644 --- a/internal/cmd/beta/sfs/resource-pool/describe/describe.go +++ b/internal/cmd/beta/sfs/resource-pool/describe/describe.go @@ -140,6 +140,8 @@ func outputResult(p *print.Printer, outputFormat, resourcePoolId, projectLabel s table.AddSeparator() table.AddRow("USED SIZE (GB)", utils.PtrString(resourcePool.Space.UsedGigabytes.Get())) table.AddSeparator() + table.AddRow("USED BY SNAPSHOTS (GB)", utils.PtrString(resourcePool.Space.UsedBySnapshotsGigabytes.Get())) + table.AddSeparator() } table.AddRow("STATE", utils.PtrString(resourcePool.State)) table.AddSeparator() diff --git a/internal/cmd/beta/sfs/resource-pool/describe/describe_test.go b/internal/cmd/beta/sfs/resource-pool/describe/describe_test.go index 6a125f802..54a7387f2 100644 --- a/internal/cmd/beta/sfs/resource-pool/describe/describe_test.go +++ b/internal/cmd/beta/sfs/resource-pool/describe/describe_test.go @@ -7,6 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" @@ -197,6 +198,24 @@ func TestOutputResult(t *testing.T) { }, wantErr: false, }, + { + name: "full response", + args: args{ + resp: &sfs.ResourcePool{ + Id: utils.Ptr("id"), + Name: utils.Ptr("name"), + AvailabilityZone: utils.Ptr("az"), + State: utils.Ptr("state"), + Space: &sfs.ResourcePoolSpace{ + SizeGigabytes: utils.Ptr(int32(100)), + AvailableGigabytes: *sfs.NewNullableFloat64(utils.Ptr(float64(50))), + UsedGigabytes: *sfs.NewNullableFloat64(utils.Ptr(float64(50))), + UsedBySnapshotsGigabytes: *sfs.NewNullableFloat64(utils.Ptr(float64(10))), + }, + }, + }, + wantErr: false, + }, } params := testparams.NewTestParams() diff --git a/internal/cmd/beta/sfs/resource-pool/list/list.go b/internal/cmd/beta/sfs/resource-pool/list/list.go index be46ce2ec..aae15972b 100644 --- a/internal/cmd/beta/sfs/resource-pool/list/list.go +++ b/internal/cmd/beta/sfs/resource-pool/list/list.go @@ -128,12 +128,13 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, resourceP } table := tables.NewTable() - table.SetHeader("ID", "NAME", "AVAILABILITY ZONE", "STATE", "TOTAL SIZE (GB)", "USED SIZE (GB)") + table.SetHeader("ID", "NAME", "AVAILABILITY ZONE", "STATE", "TOTAL SIZE (GB)", "USED SIZE (GB)", "USED BY SNAPSHOTS (GB)") for _, resourcePool := range resourcePools { - totalSizeGigabytes, usedSizeGigabytes := "", "" + totalSizeGigabytes, usedSizeGigabytes, usedBySnapshotsGigabytes := "", "", "" if resourcePool.HasSpace() { totalSizeGigabytes = utils.PtrString(resourcePool.Space.SizeGigabytes) usedSizeGigabytes = utils.PtrString(resourcePool.Space.UsedGigabytes.Get()) + usedBySnapshotsGigabytes = utils.PtrString(resourcePool.Space.UsedBySnapshotsGigabytes.Get()) } table.AddRow( utils.PtrString(resourcePool.Id), @@ -142,6 +143,7 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, resourceP utils.PtrString(resourcePool.State), totalSizeGigabytes, usedSizeGigabytes, + usedBySnapshotsGigabytes, ) } err := table.Display(p) diff --git a/internal/cmd/beta/sfs/resource-pool/list/list_test.go b/internal/cmd/beta/sfs/resource-pool/list/list_test.go index 675b7092b..a7f2a2d32 100644 --- a/internal/cmd/beta/sfs/resource-pool/list/list_test.go +++ b/internal/cmd/beta/sfs/resource-pool/list/list_test.go @@ -185,6 +185,26 @@ func TestOutputResult(t *testing.T) { }, wantErr: false, }, + { + name: "values", + args: args{ + resourcePools: []sfs.ResourcePool{ + { + Id: utils.Ptr("id"), + Name: utils.Ptr("name"), + AvailabilityZone: utils.Ptr("az"), + State: utils.Ptr("state"), + Space: &sfs.ResourcePoolSpace{ + SizeGigabytes: utils.Ptr(int32(100)), + AvailableGigabytes: *sfs.NewNullableFloat64(utils.Ptr(float64(50))), + UsedGigabytes: *sfs.NewNullableFloat64(utils.Ptr(float64(50))), + UsedBySnapshotsGigabytes: *sfs.NewNullableFloat64(utils.Ptr(float64(10))), + }, + }, + }, + }, + wantErr: false, + }, } params := testparams.NewTestParams() From 0360d788baee11f54eb8e0c1bf6e82ce3fd71cc8 Mon Sep 17 00:00:00 2001 From: Carlo Goetz Date: Fri, 8 May 2026 17:27:03 +0200 Subject: [PATCH 2/2] fix(sfs): resource-pool describe_test import order --- internal/cmd/beta/sfs/resource-pool/describe/describe_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/cmd/beta/sfs/resource-pool/describe/describe_test.go b/internal/cmd/beta/sfs/resource-pool/describe/describe_test.go index 54a7387f2..36f27fa7c 100644 --- a/internal/cmd/beta/sfs/resource-pool/describe/describe_test.go +++ b/internal/cmd/beta/sfs/resource-pool/describe/describe_test.go @@ -7,9 +7,10 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils"