forked from TrueCloudLab/frostfs-node
[#1649] cli: Refactor --owner
flag definition in container list
cmd
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
7a26b2a57a
commit
67af4c89a8
1 changed files with 9 additions and 7 deletions
|
@ -15,15 +15,15 @@ import (
|
||||||
// flags of list command
|
// flags of list command
|
||||||
const (
|
const (
|
||||||
flagListPrintAttr = "with-attr"
|
flagListPrintAttr = "with-attr"
|
||||||
|
flagListContainerOwner = "owner"
|
||||||
)
|
)
|
||||||
|
|
||||||
// flag vars of list command
|
// flag vars of list command
|
||||||
var (
|
var (
|
||||||
flagVarListPrintAttr bool
|
flagVarListPrintAttr bool
|
||||||
|
flagVarListContainerOwner string
|
||||||
)
|
)
|
||||||
|
|
||||||
var containerOwner string
|
|
||||||
|
|
||||||
var listContainersCmd = &cobra.Command{
|
var listContainersCmd = &cobra.Command{
|
||||||
Use: "list",
|
Use: "list",
|
||||||
Short: "List all created containers",
|
Short: "List all created containers",
|
||||||
|
@ -33,10 +33,10 @@ var listContainersCmd = &cobra.Command{
|
||||||
|
|
||||||
key := key.GetOrGenerate(cmd)
|
key := key.GetOrGenerate(cmd)
|
||||||
|
|
||||||
if containerOwner == "" {
|
if flagVarListContainerOwner == "" {
|
||||||
user.IDFromKey(&idUser, key.PublicKey)
|
user.IDFromKey(&idUser, key.PublicKey)
|
||||||
} else {
|
} else {
|
||||||
err := idUser.DecodeString(containerOwner)
|
err := idUser.DecodeString(flagVarListContainerOwner)
|
||||||
common.ExitOnErr(cmd, "invalid user ID: %w", err)
|
common.ExitOnErr(cmd, "invalid user ID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,9 @@ func initContainerListContainersCmd() {
|
||||||
|
|
||||||
flags := listContainersCmd.Flags()
|
flags := listContainersCmd.Flags()
|
||||||
|
|
||||||
flags.StringVar(&containerOwner, "owner", "", "owner of containers (omit to use owner from private key)")
|
flags.StringVar(&flagVarListContainerOwner, flagListContainerOwner, "",
|
||||||
|
"owner of containers (omit to use owner from private key)",
|
||||||
|
)
|
||||||
flags.BoolVar(&flagVarListPrintAttr, flagListPrintAttr, false,
|
flags.BoolVar(&flagVarListPrintAttr, flagListPrintAttr, false,
|
||||||
"request and print attributes of each container",
|
"request and print attributes of each container",
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue