Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add retention flag, call to update retention #93

Merged
merged 14 commits into from
Oct 31, 2022
8 changes: 8 additions & 0 deletions app/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
const (
ServerFlagName = "server"
ConfigDirFlagName = "config-dir"
RetentionFlagName = "retention-days"
laniehei marked this conversation as resolved.
Show resolved Hide resolved
NamespaceFlagName = "namespace"
RequestIDFlagName = "request-id"
ResourceVersionFlagName = "resource-version"
Expand All @@ -32,6 +33,13 @@ var (
Hidden: true,
Required: false,
}
RetentionFlag = &cli.StringFlag{
laniehei marked this conversation as resolved.
Show resolved Hide resolved
Name: RetentionFlagName,
Usage: "The retention of the namespace",
Aliases: []string{"ret"},
laniehei marked this conversation as resolved.
Show resolved Hide resolved
EnvVars: []string{"NAMESPACE_RETENTION"},
Required: true,
}
NamespaceFlag = &cli.StringFlag{
Name: NamespaceFlagName,
Usage: "The namespace hosted on temporal cloud",
Expand Down
27 changes: 27 additions & 0 deletions app/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,33 @@ func NewNamespaceCommand(getNamespaceClientFn GetNamespaceClientFn) (CommandOut,
},
},
},
{
Name: "retention",
laniehei marked this conversation as resolved.
Show resolved Hide resolved
Usage: "The length of time a closed workflow will be preserved before deletion",
laniehei marked this conversation as resolved.
Show resolved Hide resolved
Aliases: []string{"r"},
Subcommands: []*cli.Command{{
Name: "set",
laniehei marked this conversation as resolved.
Show resolved Hide resolved
Aliases: []string{"s"},
Usage: "Set the length of time a closed workflow will be preserved before deletion per namespace",
Flags: []cli.Flag{
laniehei marked this conversation as resolved.
Show resolved Hide resolved
NamespaceFlag,
RetentionFlag,
RequestIDFlag,
},
Action: func(ctx *cli.Context) error {
retention := ctx.Int(RetentionFlagName)
n, err := c.getNamespace(ctx.String(NamespaceFlagName))
if err != nil {
return err
}
if int32(retention) == n.Spec.RetentionDays {
laniehei marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("retention for namespace is already set at %d days", ctx.Int(RetentionFlagName))
}
n.Spec.RetentionDays = int32(retention)
return c.updateNamespace(ctx, n)
},
}},
},
laniehei marked this conversation as resolved.
Show resolved Hide resolved
{
Name: "search-attributes",
Usage: "Manage search attributes used by namespace",
Expand Down