Skip to content

Commit bcfc52f

Browse files
committed
fix empty result for listing snapshots
1 parent fb35768 commit bcfc52f

File tree

1 file changed

+12
-0
lines changed
  • internal/cmd/volume/snapshot/list

1 file changed

+12
-0
lines changed

internal/cmd/volume/snapshot/list/list.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
1919
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
2020

21+
"github.com/stackitcloud/stackit-cli/internal/pkg/projectname"
2122
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
2223
)
2324

@@ -69,6 +70,17 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
6970
return fmt.Errorf("list snapshots: %w", err)
7071
}
7172

73+
// Check if response is empty
74+
if resp.Items == nil || len(*resp.Items) == 0 {
75+
projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd)
76+
if err != nil {
77+
params.Printer.Debug(print.ErrorLevel, "get project name: %v", err)
78+
projectLabel = model.ProjectId
79+
}
80+
params.Printer.Info("No snapshots found for project %q\n", projectLabel)
81+
return nil
82+
}
83+
7284
// Filter results by label selector
7385
snapshots := *resp.Items
7486
if model.LabelSelector != nil {

0 commit comments

Comments
 (0)