forked from TrueCloudLab/frostfs-node
[#1607] adm/ape: Extend kind flag to accept integer
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
beba79ed7d
commit
ee4c32ad6e
3 changed files with 11 additions and 4 deletions
|
@ -26,7 +26,7 @@ const (
|
|||
|
||||
func initListChainNamesCmd() {
|
||||
listChainNamesCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
||||
listChainNamesCmd.Flags().String(kindFlag, "n", "Target kind (1-byte) to list (n(namespace)/c(container)/g(group)/u(user)/i(iam))")
|
||||
listChainNamesCmd.Flags().String(kindFlag, "n", "Target kind (1-byte) to list (n(namespace)/c(container)/g(group)/u(user)/i(iam)) or its integer representation")
|
||||
listChainNamesCmd.Flags().String(nameFlag, "", "Target name to list")
|
||||
listChainNamesCmd.Flags().Bool(nameBase64Flag, false, "Use this flag if you provide name in base64 format")
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ const (
|
|||
|
||||
func initListChainsByPrefixCmd() {
|
||||
listChainsByPrefixCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
||||
listChainsByPrefixCmd.Flags().String(kindFlag, "n", "Target kind (1-byte) to list (n(namespace)/c(container)/g(group)/u(user)/i(iam))")
|
||||
listChainsByPrefixCmd.Flags().String(kindFlag, "n", "Target kind (1-byte) to list (n(namespace)/c(container)/g(group)/u(user)/i(iam)) or its integer representation")
|
||||
listChainsByPrefixCmd.Flags().String(nameFlag, "", "Target name to list")
|
||||
listChainsByPrefixCmd.Flags().String(prefixFlag, "", "Prefix to list")
|
||||
listChainsByPrefixCmd.Flags().Bool(prefixBase64Flag, false, "Use this flag if you provide prefix in base64 format")
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/base64"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strconv"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-contract/commonclient"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||
|
@ -22,7 +23,8 @@ var listTargetsCmd = &cobra.Command{
|
|||
Short: "Invoke 'listTargets' method",
|
||||
Long: "Invoke 'listTargets' method in policy contract and print results to stdout",
|
||||
Example: `raw -r http://localhost:40332 list-targets
|
||||
raw -r http://localhost:40332 --policy-hash 81c1a41d09e08087a4b679418b12be5d3ab15742 list-targets --kind c`,
|
||||
raw -r http://localhost:40332 --policy-hash 81c1a41d09e08087a4b679418b12be5d3ab15742 list-targets --kind c
|
||||
raw -r http://localhost:40332 --policy-hash 81c1a41d09e08087a4b679418b12be5d3ab15742 list-targets --kind 99`,
|
||||
RunE: runListTargetsCmd,
|
||||
}
|
||||
|
||||
|
@ -38,7 +40,7 @@ const (
|
|||
|
||||
func initListTargetsCmd() {
|
||||
listTargetsCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
||||
listTargetsCmd.Flags().String(kindFlag, "n", "Target kind (1-byte) to list (n(namespace)/c(container)/g(group)/u(user)/i(iam))")
|
||||
listTargetsCmd.Flags().String(kindFlag, "n", "Target kind (1-byte) to list (n(namespace)/c(container)/g(group)/u(user)/i(iam)) or its integer representation")
|
||||
}
|
||||
|
||||
func runListTargetsCmd(cmd *cobra.Command, _ []string) error {
|
||||
|
@ -63,6 +65,11 @@ func runListTargetsCmd(cmd *cobra.Command, _ []string) error {
|
|||
}
|
||||
|
||||
func parseTargetKind(typ string) (*big.Int, error) {
|
||||
val, err := strconv.ParseInt(typ, 10, 64)
|
||||
if err == nil {
|
||||
return big.NewInt(val), nil
|
||||
}
|
||||
|
||||
if len(typ) != 1 {
|
||||
return nil, fmt.Errorf("invalid type: %s", typ)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue