diff --git a/internal/cmd/commands/sessionrecordingscmd/funcs.go b/internal/cmd/commands/sessionrecordingscmd/funcs.go index 7b163c0f6a..d7f8848d93 100644 --- a/internal/cmd/commands/sessionrecordingscmd/funcs.go +++ b/internal/cmd/commands/sessionrecordingscmd/funcs.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/boundary/api/scopes" "github.com/hashicorp/boundary/api/sessionrecordings" "github.com/hashicorp/boundary/internal/cmd/base" + "github.com/hashicorp/boundary/internal/policy/storage" ) type extraCmdVars struct{} @@ -115,6 +116,23 @@ func (c *Command) printListTable(items []*sessionrecordings.SessionRecording) st fmt.Sprintf(" State: %s", item.State), ) } + if !item.RetainUntil.IsZero() { + var retention string + switch item.RetainUntil { + case storage.InfinityTS: + retention = "Keep Forever" + default: + retention = item.RetainUntil.Local().Format(time.RFC1123) + } + output = append(output, + fmt.Sprintf(" Retain Until: %s", retention), + ) + } + if !item.DeleteAfter.IsZero() { + output = append(output, + fmt.Sprintf(" Delete After: %s", item.DeleteAfter.Local().Format(time.RFC1123)), + ) + } if len(item.AuthorizedActions) > 0 { output = append(output, " Authorized Actions:", @@ -164,6 +182,19 @@ func printItemTable(item *sessionrecordings.SessionRecording, resp *api.Response if item.Duration.Duration != 0 { nonAttributeMap[durationKey] = item.Duration.Seconds() } + if !item.RetainUntil.IsZero() { + var retention string + switch item.RetainUntil { + case storage.InfinityTS: + retention = "Keep Forever" + default: + retention = item.RetainUntil.Local().Format(time.RFC1123) + } + nonAttributeMap["Retain Until"] = retention + } + if !item.DeleteAfter.IsZero() { + nonAttributeMap["Delete After"] = item.DeleteAfter.Local().Format(time.RFC1123) + } if item.Type != "" { nonAttributeMap["Type"] = item.Type } diff --git a/internal/policy/storage/time.go b/internal/policy/storage/time.go new file mode 100644 index 0000000000..fec678a455 --- /dev/null +++ b/internal/policy/storage/time.go @@ -0,0 +1,10 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + +package storage + +import "time" + +// InfinityTS is the max protobuf timestamp value of 9999-12-31T23:59:59.999999999Z. It is +// used to represent a infinite retention value in storage policies. +var InfinityTS = time.Date(9999, time.December, 31, 23, 23, 23, 1e9-1, time.UTC)