forked from TrueCloudLab/frostfs-node
[#1612] neofs-cli: Unify expiration flags
Use `expire-at` everywhere expiration epoch is expected. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
175e9da3a7
commit
a52e7c2c99
7 changed files with 33 additions and 30 deletions
|
@ -2,6 +2,7 @@ package object
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
@ -19,8 +20,6 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const lockExpiresOnFlag = "expires-on"
|
||||
|
||||
// object lock command.
|
||||
var objectLockCmd = &cobra.Command{
|
||||
Use: "lock CONTAINER OBJECT...",
|
||||
|
@ -50,10 +49,13 @@ var objectLockCmd = &cobra.Command{
|
|||
var lock objectSDK.Lock
|
||||
lock.WriteMembers(lockList)
|
||||
|
||||
exp, relative, err := common.ParseEpoch(cmd, lockExpiresOnFlag)
|
||||
common.ExitOnErr(cmd, "Parsing expiration epoch: %w", err)
|
||||
exp, _ := cmd.Flags().GetUint64(commonflags.ExpireAt)
|
||||
lifetime, _ := cmd.Flags().GetUint64(commonflags.Lifetime)
|
||||
if exp == 0 && lifetime == 0 { // mutual exclusion is ensured by cobra
|
||||
common.ExitOnErr(cmd, "", errors.New("either expiration epoch of a lifetime is required"))
|
||||
}
|
||||
|
||||
if relative {
|
||||
if lifetime != 0 {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
|
||||
defer cancel()
|
||||
|
||||
|
@ -94,6 +96,7 @@ func initCommandObjectLock() {
|
|||
commonflags.Init(objectLockCmd)
|
||||
commonflags.InitSession(objectLockCmd)
|
||||
|
||||
objectLockCmd.Flags().StringP(lockExpiresOnFlag, "e", "", "Lock expiration epoch")
|
||||
_ = objectLockCmd.MarkFlagRequired(lockExpiresOnFlag)
|
||||
objectLockCmd.Flags().Uint64P(commonflags.ExpireAt, "e", 0, "Lock expiration epoch")
|
||||
objectLockCmd.Flags().Uint64(commonflags.Lifetime, 0, "Lock lifetime")
|
||||
objectLockCmd.MarkFlagsMutuallyExclusive(commonflags.ExpireAt, commonflags.Lifetime)
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
putExpiresOnFlag = "expires-on"
|
||||
noProgressFlag = "no-progress"
|
||||
notificationFlag = "notify"
|
||||
)
|
||||
|
@ -52,7 +51,7 @@ func initObjectPutCmd() {
|
|||
flags.String("attributes", "", "User attributes in form of Key1=Value1,Key2=Value2")
|
||||
flags.Bool("disable-filename", false, "Do not set well-known filename attribute")
|
||||
flags.Bool("disable-timestamp", false, "Do not set well-known timestamp attribute")
|
||||
flags.Uint64VarP(&putExpiredOn, putExpiresOnFlag, "e", 0, "Last epoch in the life of the object")
|
||||
flags.Uint64VarP(&putExpiredOn, commonflags.ExpireAt, "e", 0, "Last epoch in the life of the object")
|
||||
flags.Bool(noProgressFlag, false, "Do not show progress bar")
|
||||
|
||||
flags.String(notificationFlag, "", "Object notification in the form of *epoch*:*topic*; '-' topic means using default")
|
||||
|
@ -76,7 +75,7 @@ func putObject(cmd *cobra.Command, _ []string) {
|
|||
attrs, err := parseObjectAttrs(cmd)
|
||||
common.ExitOnErr(cmd, "can't parse object attributes: %w", err)
|
||||
|
||||
expiresOn, _ := cmd.Flags().GetUint64(putExpiresOnFlag)
|
||||
expiresOn, _ := cmd.Flags().GetUint64(commonflags.ExpireAt)
|
||||
if expiresOn > 0 {
|
||||
var expAttrFound bool
|
||||
expAttrValue := strconv.FormatUint(expiresOn, 10)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue