Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/cmd/beta/sfs/snapshot/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ func outputResult(p *print.Printer, outputFormat, snapshotLabel, resourcePoolLab
snapshotLabel,
resourcePoolLabel,
)

if resp.ResourcePoolSnapshot.SnaplockExpiryTime.IsSet() && resp.ResourcePoolSnapshot.SnaplockExpiryTime.Get() != nil {
p.Outputf("Snaplock expiry time: %s\n", utils.ConvertTimePToDateTimeString(resp.ResourcePoolSnapshot.SnaplockExpiryTime.Get()))
}

return nil
})
}
12 changes: 12 additions & 0 deletions internal/cmd/beta/sfs/snapshot/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package create
import (
"context"
"testing"
"time"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
Expand Down Expand Up @@ -205,6 +206,17 @@ func TestOutputResult(t *testing.T) {
},
wantErr: false,
},
{
name: "set full snapshot",
args: args{
resp: &sfs.CreateResourcePoolSnapshotResponse{
ResourcePoolSnapshot: &sfs.ResourcePoolSnapshot{
SnaplockExpiryTime: *sfs.NewNullableTime(utils.Ptr(time.Now().Add(time.Hour))),
},
},
},
wantErr: false,
},
}
params := testparams.NewTestParams()

Expand Down
6 changes: 6 additions & 0 deletions internal/cmd/beta/sfs/snapshot/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ func outputResult(p *print.Printer, outputFormat string, resp *sfs.GetResourcePo
table := tables.NewTable()

snap := *resp.ResourcePoolSnapshot
var snaplockExpiryTime string
if snap.SnaplockExpiryTime.IsSet() && snap.SnaplockExpiryTime.Get() != nil {
snaplockExpiryTime = utils.ConvertTimePToDateTimeString(snap.SnaplockExpiryTime.Get())
}
table.AddRow("NAME", utils.PtrString(snap.SnapshotName))
table.AddSeparator()
if snap.Comment.IsSet() && snap.Comment.Get() != nil {
Expand All @@ -123,6 +127,8 @@ func outputResult(p *print.Printer, outputFormat string, resp *sfs.GetResourcePo
table.AddSeparator()
table.AddRow("CREATED AT", utils.ConvertTimePToDateTimeString(snap.CreatedAt))
table.AddSeparator()
table.AddRow("SNAPLOCK EXPIRY TIME", snaplockExpiryTime)
table.AddSeparator()

p.Outputln(table.Render())
return nil
Expand Down
20 changes: 19 additions & 1 deletion internal/cmd/beta/sfs/snapshot/describe/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package describe
import (
"context"
"testing"
"time"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
Expand All @@ -12,6 +13,7 @@ import (
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/testparams"
"github.com/stackitcloud/stackit-cli/internal/pkg/testutils"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
)

var projectIdFlag = globalflags.ProjectIdFlag
Expand Down Expand Up @@ -212,14 +214,30 @@ func TestOutputResult(t *testing.T) {
wantErr: false,
},
{
name: " set empty snapshot",
name: "set empty snapshot",
args: args{
resp: &sfs.GetResourcePoolSnapshotResponse{
ResourcePoolSnapshot: &sfs.ResourcePoolSnapshot{},
},
},
wantErr: false,
},
{
name: "set full snapshot",
args: args{
resp: &sfs.GetResourcePoolSnapshotResponse{
ResourcePoolSnapshot: &sfs.ResourcePoolSnapshot{
SnapshotName: utils.Ptr("name"),
ResourcePoolId: utils.Ptr("rp-id"),
SizeGigabytes: utils.Ptr(int32(10)),
LogicalSizeGigabytes: utils.Ptr(int32(8)),
CreatedAt: utils.Ptr(time.Now()),
SnaplockExpiryTime: *sfs.NewNullableTime(utils.Ptr(time.Now().Add(time.Hour))),
},
},
},
wantErr: false,
},
}
params := testparams.NewTestParams()

Expand Down
6 changes: 6 additions & 0 deletions internal/cmd/beta/sfs/snapshot/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,26 @@ func outputResult(p *print.Printer, outputFormat string, resp []sfs.ResourcePool
"SIZE (GB)",
"LOGICAL SIZE (GB)",
"CREATED AT",
"SNAPLOCK EXPIRY TIME",
)

for _, snap := range resp {
var comment string
if snap.Comment.IsSet() && snap.Comment.Get() != nil {
comment = utils.PtrString(snap.Comment.Get())
}
var snaplockExpiryTime string
if snap.SnaplockExpiryTime.IsSet() && snap.SnaplockExpiryTime.Get() != nil {
snaplockExpiryTime = utils.ConvertTimePToDateTimeString(snap.SnaplockExpiryTime.Get())
}
table.AddRow(
utils.PtrString(snap.SnapshotName),
comment,
utils.PtrString(snap.ResourcePoolId),
utils.PtrString(snap.SizeGigabytes),
utils.PtrString(snap.LogicalSizeGigabytes),
utils.ConvertTimePToDateTimeString(snap.CreatedAt),
snaplockExpiryTime,
)
}

Expand Down
18 changes: 18 additions & 0 deletions internal/cmd/beta/sfs/snapshot/list/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package list
import (
"context"
"testing"
"time"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
Expand All @@ -12,6 +13,7 @@ import (
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/testparams"
"github.com/stackitcloud/stackit-cli/internal/pkg/testutils"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
)

var projectIdFlag = globalflags.ProjectIdFlag
Expand Down Expand Up @@ -160,6 +162,22 @@ func TestOutputResult(t *testing.T) {
},
wantErr: false,
},
{
name: "set full snapshot",
args: args{
resp: []sfs.ResourcePoolSnapshot{
{
SnapshotName: utils.Ptr("name"),
ResourcePoolId: utils.Ptr("rp-id"),
SizeGigabytes: utils.Ptr(int32(10)),
LogicalSizeGigabytes: utils.Ptr(int32(8)),
CreatedAt: utils.Ptr(time.Now()),
SnaplockExpiryTime: *sfs.NewNullableTime(utils.Ptr(time.Now().Add(time.Hour))),
},
},
},
wantErr: false,
},
}
params := testparams.NewTestParams()

Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/beta/sfs/snapshot/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ func outputResult(p *print.Printer, outputFormat, snapshotLabel, resourcePoolLab
snapshotLabel,
resourcePoolLabel,
)

if resp.ResourcePoolSnapshot.SnaplockExpiryTime.IsSet() && resp.ResourcePoolSnapshot.SnaplockExpiryTime.Get() != nil {
p.Outputf("Snaplock expiry time: %s\n", utils.ConvertTimePToDateTimeString(resp.ResourcePoolSnapshot.SnaplockExpiryTime.Get()))
}

return nil
})
}
12 changes: 12 additions & 0 deletions internal/cmd/beta/sfs/snapshot/update/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package update
import (
"context"
"testing"
"time"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
Expand Down Expand Up @@ -235,6 +236,17 @@ func TestOutputResult(t *testing.T) {
},
wantErr: false,
},
{
name: "set snaplock expiry time",
args: args{
resp: &sfs.UpdateResourcePoolSnapshotResponse{
ResourcePoolSnapshot: &sfs.ResourcePoolSnapshot{
SnaplockExpiryTime: *sfs.NewNullableTime(utils.Ptr(time.Now())),
},
},
},
wantErr: false,
},
}
params := testparams.NewTestParams()

Expand Down
Loading