feat(recording): Add RetainUntil and DeleteAfter to Session Recording CLI

pull/4239/head
Louis Ruch 2 years ago
parent 0d71976437
commit 86f10f3ea4

@ -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
}

@ -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)
Loading…
Cancel
Save