diff --git a/internal/cmd/beta/sfs/snapshot/create/create.go b/internal/cmd/beta/sfs/snapshot/create/create.go index 90efa3dd3..62be42ef3 100644 --- a/internal/cmd/beta/sfs/snapshot/create/create.go +++ b/internal/cmd/beta/sfs/snapshot/create/create.go @@ -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 }) } diff --git a/internal/cmd/beta/sfs/snapshot/create/create_test.go b/internal/cmd/beta/sfs/snapshot/create/create_test.go index 94abf5712..5d672a6f8 100644 --- a/internal/cmd/beta/sfs/snapshot/create/create_test.go +++ b/internal/cmd/beta/sfs/snapshot/create/create_test.go @@ -3,6 +3,7 @@ package create import ( "context" "testing" + "time" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" @@ -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() diff --git a/internal/cmd/beta/sfs/snapshot/describe/describe.go b/internal/cmd/beta/sfs/snapshot/describe/describe.go index 1d5b01a1c..359701838 100644 --- a/internal/cmd/beta/sfs/snapshot/describe/describe.go +++ b/internal/cmd/beta/sfs/snapshot/describe/describe.go @@ -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 { @@ -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 diff --git a/internal/cmd/beta/sfs/snapshot/describe/describe_test.go b/internal/cmd/beta/sfs/snapshot/describe/describe_test.go index 91a4ee5a4..4c086c056 100644 --- a/internal/cmd/beta/sfs/snapshot/describe/describe_test.go +++ b/internal/cmd/beta/sfs/snapshot/describe/describe_test.go @@ -3,6 +3,7 @@ package describe import ( "context" "testing" + "time" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" @@ -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 @@ -212,7 +214,7 @@ func TestOutputResult(t *testing.T) { wantErr: false, }, { - name: " set empty snapshot", + name: "set empty snapshot", args: args{ resp: &sfs.GetResourcePoolSnapshotResponse{ ResourcePoolSnapshot: &sfs.ResourcePoolSnapshot{}, @@ -220,6 +222,22 @@ func TestOutputResult(t *testing.T) { }, 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() diff --git a/internal/cmd/beta/sfs/snapshot/list/list.go b/internal/cmd/beta/sfs/snapshot/list/list.go index 5f0b55364..418434846 100644 --- a/internal/cmd/beta/sfs/snapshot/list/list.go +++ b/internal/cmd/beta/sfs/snapshot/list/list.go @@ -126,6 +126,7 @@ func outputResult(p *print.Printer, outputFormat string, resp []sfs.ResourcePool "SIZE (GB)", "LOGICAL SIZE (GB)", "CREATED AT", + "SNAPLOCK EXPIRY TIME", ) for _, snap := range resp { @@ -133,6 +134,10 @@ func outputResult(p *print.Printer, outputFormat string, resp []sfs.ResourcePool 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, @@ -140,6 +145,7 @@ func outputResult(p *print.Printer, outputFormat string, resp []sfs.ResourcePool utils.PtrString(snap.SizeGigabytes), utils.PtrString(snap.LogicalSizeGigabytes), utils.ConvertTimePToDateTimeString(snap.CreatedAt), + snaplockExpiryTime, ) } diff --git a/internal/cmd/beta/sfs/snapshot/list/list_test.go b/internal/cmd/beta/sfs/snapshot/list/list_test.go index 98d3abbf8..ede7e22d1 100644 --- a/internal/cmd/beta/sfs/snapshot/list/list_test.go +++ b/internal/cmd/beta/sfs/snapshot/list/list_test.go @@ -3,6 +3,7 @@ package list import ( "context" "testing" + "time" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" @@ -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 @@ -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() diff --git a/internal/cmd/beta/sfs/snapshot/update/update.go b/internal/cmd/beta/sfs/snapshot/update/update.go index 1651eace4..d39747431 100644 --- a/internal/cmd/beta/sfs/snapshot/update/update.go +++ b/internal/cmd/beta/sfs/snapshot/update/update.go @@ -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 }) } diff --git a/internal/cmd/beta/sfs/snapshot/update/update_test.go b/internal/cmd/beta/sfs/snapshot/update/update_test.go index a53ce6417..7de6d5c29 100644 --- a/internal/cmd/beta/sfs/snapshot/update/update_test.go +++ b/internal/cmd/beta/sfs/snapshot/update/update_test.go @@ -3,6 +3,7 @@ package update import ( "context" "testing" + "time" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" @@ -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()