[#1889] Move netmap.go and exit.go from cli
to cmd/internal/common
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
5a9d6a09d8
commit
2b09564355
62 changed files with 269 additions and 247 deletions
2
Makefile
2
Makefile
|
@ -16,7 +16,7 @@ RELEASE = release
|
||||||
DIRS = $(BIN) $(RELEASE)
|
DIRS = $(BIN) $(RELEASE)
|
||||||
|
|
||||||
# List of binaries to build.
|
# List of binaries to build.
|
||||||
CMDS = $(notdir $(basename $(wildcard cmd/*)))
|
CMDS = $(notdir $(basename $(wildcard cmd/frostfs-*)))
|
||||||
BINS = $(addprefix $(BIN)/, $(CMDS))
|
BINS = $(addprefix $(BIN)/, $(CMDS))
|
||||||
|
|
||||||
# .deb package versioning
|
# .deb package versioning
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/network"
|
"github.com/TrueCloudLab/frostfs-node/pkg/network"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/client"
|
"github.com/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -23,7 +24,7 @@ var errInvalidEndpoint = errors.New("provided RPC endpoint is incorrect")
|
||||||
func GetSDKClientByFlag(cmd *cobra.Command, key *ecdsa.PrivateKey, endpointFlag string) *client.Client {
|
func GetSDKClientByFlag(cmd *cobra.Command, key *ecdsa.PrivateKey, endpointFlag string) *client.Client {
|
||||||
cli, err := getSDKClientByFlag(cmd, key, endpointFlag)
|
cli, err := getSDKClientByFlag(cmd, key, endpointFlag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.ExitOnErr(cmd, "can't create API client: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't create API client: %w", err)
|
||||||
}
|
}
|
||||||
return cli
|
return cli
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/core/version"
|
"github.com/TrueCloudLab/frostfs-node/pkg/core/version"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/eacl"
|
"github.com/TrueCloudLab/frostfs-sdk-go/eacl"
|
||||||
versionSDK "github.com/TrueCloudLab/frostfs-sdk-go/version"
|
versionSDK "github.com/TrueCloudLab/frostfs-sdk-go/version"
|
||||||
|
@ -16,13 +17,13 @@ var errUnsupportedEACLFormat = errors.New("unsupported eACL format")
|
||||||
func ReadEACL(cmd *cobra.Command, eaclPath string) *eacl.Table {
|
func ReadEACL(cmd *cobra.Command, eaclPath string) *eacl.Table {
|
||||||
_, err := os.Stat(eaclPath) // check if `eaclPath` is an existing file
|
_, err := os.Stat(eaclPath) // check if `eaclPath` is an existing file
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ExitOnErr(cmd, "", errors.New("incorrect path to file with EACL"))
|
commonCmd.ExitOnErr(cmd, "", errors.New("incorrect path to file with EACL"))
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintVerbose(cmd, "Reading EACL from file: %s", eaclPath)
|
PrintVerbose(cmd, "Reading EACL from file: %s", eaclPath)
|
||||||
|
|
||||||
data, err := os.ReadFile(eaclPath)
|
data, err := os.ReadFile(eaclPath)
|
||||||
ExitOnErr(cmd, "can't read file with EACL: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't read file with EACL: %w", err)
|
||||||
|
|
||||||
table := eacl.NewTable()
|
table := eacl.NewTable()
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ func ReadEACL(cmd *cobra.Command, eaclPath string) *eacl.Table {
|
||||||
return table
|
return table
|
||||||
}
|
}
|
||||||
|
|
||||||
ExitOnErr(cmd, "", errUnsupportedEACLFormat)
|
commonCmd.ExitOnErr(cmd, "", errUnsupportedEACLFormat)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/bearer"
|
"github.com/TrueCloudLab/frostfs-sdk-go/bearer"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -13,7 +14,7 @@ import (
|
||||||
// ReadBearerToken reads bearer token from the path provided in a specified flag.
|
// ReadBearerToken reads bearer token from the path provided in a specified flag.
|
||||||
func ReadBearerToken(cmd *cobra.Command, flagname string) *bearer.Token {
|
func ReadBearerToken(cmd *cobra.Command, flagname string) *bearer.Token {
|
||||||
path, err := cmd.Flags().GetString(flagname)
|
path, err := cmd.Flags().GetString(flagname)
|
||||||
ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
|
|
||||||
if len(path) == 0 {
|
if len(path) == 0 {
|
||||||
return nil
|
return nil
|
||||||
|
@ -24,7 +25,7 @@ func ReadBearerToken(cmd *cobra.Command, flagname string) *bearer.Token {
|
||||||
var tok bearer.Token
|
var tok bearer.Token
|
||||||
|
|
||||||
err = ReadBinaryOrJSON(cmd, &tok, path)
|
err = ReadBinaryOrJSON(cmd, &tok, path)
|
||||||
ExitOnErr(cmd, "invalid bearer token: %v", err)
|
commonCmd.ExitOnErr(cmd, "invalid bearer token: %v", err)
|
||||||
|
|
||||||
return &tok
|
return &tok
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -21,7 +21,7 @@ var errCantGenerateKey = errors.New("can't generate new private key")
|
||||||
// This function assumes that all flags were bind to viper in a `PersistentPreRun`.
|
// This function assumes that all flags were bind to viper in a `PersistentPreRun`.
|
||||||
func Get(cmd *cobra.Command) *ecdsa.PrivateKey {
|
func Get(cmd *cobra.Command) *ecdsa.PrivateKey {
|
||||||
pk, err := get(cmd)
|
pk, err := get(cmd)
|
||||||
common.ExitOnErr(cmd, "can't fetch private key: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't fetch private key: %w", err)
|
||||||
return pk
|
return pk
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ func get(cmd *cobra.Command) (*ecdsa.PrivateKey, error) {
|
||||||
// GetOrGenerate is similar to get but generates a new key if commonflags.GenerateKey is set.
|
// GetOrGenerate is similar to get but generates a new key if commonflags.GenerateKey is set.
|
||||||
func GetOrGenerate(cmd *cobra.Command) *ecdsa.PrivateKey {
|
func GetOrGenerate(cmd *cobra.Command) *ecdsa.PrivateKey {
|
||||||
pk, err := getOrGenerate(cmd)
|
pk, err := getOrGenerate(cmd)
|
||||||
common.ExitOnErr(cmd, "can't fetch private key: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't fetch private key: %w", err)
|
||||||
return pk
|
return pk
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/util/precision"
|
"github.com/TrueCloudLab/frostfs-node/pkg/util/precision"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/accounting"
|
"github.com/TrueCloudLab/frostfs-sdk-go/accounting"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/user"
|
"github.com/TrueCloudLab/frostfs-sdk-go/user"
|
||||||
|
@ -32,7 +32,7 @@ var accountingBalanceCmd = &cobra.Command{
|
||||||
if balanceOwner == "" {
|
if balanceOwner == "" {
|
||||||
user.IDFromKey(&idUser, pk.PublicKey)
|
user.IDFromKey(&idUser, pk.PublicKey)
|
||||||
} else {
|
} else {
|
||||||
common.ExitOnErr(cmd, "can't decode owner ID wallet address: %w", idUser.DecodeString(balanceOwner))
|
commonCmd.ExitOnErr(cmd, "can't decode owner ID wallet address: %w", idUser.DecodeString(balanceOwner))
|
||||||
}
|
}
|
||||||
|
|
||||||
cli := internalclient.GetSDKClientByFlag(cmd, pk, commonflags.RPC)
|
cli := internalclient.GetSDKClientByFlag(cmd, pk, commonflags.RPC)
|
||||||
|
@ -42,7 +42,7 @@ var accountingBalanceCmd = &cobra.Command{
|
||||||
prm.SetAccount(idUser)
|
prm.SetAccount(idUser)
|
||||||
|
|
||||||
res, err := internalclient.BalanceOf(prm)
|
res, err := internalclient.BalanceOf(prm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
// print to stdout
|
// print to stdout
|
||||||
prettyPrintDecimal(cmd, res.Balance())
|
prettyPrintDecimal(cmd, res.Balance())
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package basic
|
package basic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/util"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/util"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/container/acl"
|
"github.com/TrueCloudLab/frostfs-sdk-go/container/acl"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -23,6 +23,6 @@ InnerRing members are allowed to data audit ops only:
|
||||||
|
|
||||||
func printACL(cmd *cobra.Command, args []string) {
|
func printACL(cmd *cobra.Command, args []string) {
|
||||||
var bacl acl.Basic
|
var bacl acl.Basic
|
||||||
common.ExitOnErr(cmd, "unable to parse basic acl: %w", bacl.DecodeString(args[0]))
|
commonCmd.ExitOnErr(cmd, "unable to parse basic acl: %w", bacl.DecodeString(args[0]))
|
||||||
util.PrettyPrintTableBACL(cmd, &bacl)
|
util.PrettyPrintTableBACL(cmd, &bacl)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/util"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/util"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/eacl"
|
"github.com/TrueCloudLab/frostfs-sdk-go/eacl"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -84,7 +84,7 @@ func createEACL(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tb := eacl.NewTable()
|
tb := eacl.NewTable()
|
||||||
common.ExitOnErr(cmd, "unable to parse provided rules: %w", util.ParseEACLRules(tb, rules))
|
commonCmd.ExitOnErr(cmd, "unable to parse provided rules: %w", util.ParseEACLRules(tb, rules))
|
||||||
|
|
||||||
tb.SetCID(containerID)
|
tb.SetCID(containerID)
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/util"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/util"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/eacl"
|
"github.com/TrueCloudLab/frostfs-sdk-go/eacl"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -27,12 +27,12 @@ func printEACL(cmd *cobra.Command, _ []string) {
|
||||||
file, _ := cmd.Flags().GetString("file")
|
file, _ := cmd.Flags().GetString("file")
|
||||||
eaclTable := new(eacl.Table)
|
eaclTable := new(eacl.Table)
|
||||||
data, err := os.ReadFile(file)
|
data, err := os.ReadFile(file)
|
||||||
common.ExitOnErr(cmd, "can't read file with EACL: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't read file with EACL: %w", err)
|
||||||
if strings.HasSuffix(file, ".json") {
|
if strings.HasSuffix(file, ".json") {
|
||||||
common.ExitOnErr(cmd, "unable to parse json: %w", eaclTable.UnmarshalJSON(data))
|
commonCmd.ExitOnErr(cmd, "unable to parse json: %w", eaclTable.UnmarshalJSON(data))
|
||||||
} else {
|
} else {
|
||||||
rules := strings.Split(strings.TrimSpace(string(data)), "\n")
|
rules := strings.Split(strings.TrimSpace(string(data)), "\n")
|
||||||
common.ExitOnErr(cmd, "can't parse file with EACL: %w", util.ParseEACLRules(eaclTable, rules))
|
commonCmd.ExitOnErr(cmd, "can't parse file with EACL: %w", util.ParseEACLRules(eaclTable, rules))
|
||||||
}
|
}
|
||||||
util.PrettyPrintTableEACL(cmd, eaclTable)
|
util.PrettyPrintTableEACL(cmd, eaclTable)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/bearer"
|
"github.com/TrueCloudLab/frostfs-sdk-go/bearer"
|
||||||
eaclSDK "github.com/TrueCloudLab/frostfs-sdk-go/eacl"
|
eaclSDK "github.com/TrueCloudLab/frostfs-sdk-go/eacl"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/user"
|
"github.com/TrueCloudLab/frostfs-sdk-go/user"
|
||||||
|
@ -58,13 +59,13 @@ func init() {
|
||||||
|
|
||||||
func createToken(cmd *cobra.Command, _ []string) {
|
func createToken(cmd *cobra.Command, _ []string) {
|
||||||
iat, iatRelative, err := common.ParseEpoch(cmd, issuedAtFlag)
|
iat, iatRelative, err := common.ParseEpoch(cmd, issuedAtFlag)
|
||||||
common.ExitOnErr(cmd, "can't parse --"+issuedAtFlag+" flag: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't parse --"+issuedAtFlag+" flag: %w", err)
|
||||||
|
|
||||||
exp, expRelative, err := common.ParseEpoch(cmd, commonflags.ExpireAt)
|
exp, expRelative, err := common.ParseEpoch(cmd, commonflags.ExpireAt)
|
||||||
common.ExitOnErr(cmd, "can't parse --"+commonflags.ExpireAt+" flag: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't parse --"+commonflags.ExpireAt+" flag: %w", err)
|
||||||
|
|
||||||
nvb, nvbRelative, err := common.ParseEpoch(cmd, notValidBeforeFlag)
|
nvb, nvbRelative, err := common.ParseEpoch(cmd, notValidBeforeFlag)
|
||||||
common.ExitOnErr(cmd, "can't parse --"+notValidBeforeFlag+" flag: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't parse --"+notValidBeforeFlag+" flag: %w", err)
|
||||||
|
|
||||||
if iatRelative || expRelative || nvbRelative {
|
if iatRelative || expRelative || nvbRelative {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
|
||||||
|
@ -72,7 +73,7 @@ func createToken(cmd *cobra.Command, _ []string) {
|
||||||
|
|
||||||
endpoint, _ := cmd.Flags().GetString(commonflags.RPC)
|
endpoint, _ := cmd.Flags().GetString(commonflags.RPC)
|
||||||
currEpoch, err := internalclient.GetCurrentEpoch(ctx, cmd, endpoint)
|
currEpoch, err := internalclient.GetCurrentEpoch(ctx, cmd, endpoint)
|
||||||
common.ExitOnErr(cmd, "can't fetch current epoch: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't fetch current epoch: %w", err)
|
||||||
|
|
||||||
if iatRelative {
|
if iatRelative {
|
||||||
iat += currEpoch
|
iat += currEpoch
|
||||||
|
@ -85,14 +86,14 @@ func createToken(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if exp < nvb {
|
if exp < nvb {
|
||||||
common.ExitOnErr(cmd, "",
|
commonCmd.ExitOnErr(cmd, "",
|
||||||
fmt.Errorf("expiration epoch is less than not-valid-before epoch: %d < %d", exp, nvb))
|
fmt.Errorf("expiration epoch is less than not-valid-before epoch: %d < %d", exp, nvb))
|
||||||
}
|
}
|
||||||
|
|
||||||
ownerStr, _ := cmd.Flags().GetString(ownerFlag)
|
ownerStr, _ := cmd.Flags().GetString(ownerFlag)
|
||||||
|
|
||||||
var ownerID user.ID
|
var ownerID user.ID
|
||||||
common.ExitOnErr(cmd, "can't parse recipient: %w", ownerID.DecodeString(ownerStr))
|
commonCmd.ExitOnErr(cmd, "can't parse recipient: %w", ownerID.DecodeString(ownerStr))
|
||||||
|
|
||||||
var b bearer.Token
|
var b bearer.Token
|
||||||
b.SetExp(exp)
|
b.SetExp(exp)
|
||||||
|
@ -104,8 +105,8 @@ func createToken(cmd *cobra.Command, _ []string) {
|
||||||
if eaclPath != "" {
|
if eaclPath != "" {
|
||||||
table := eaclSDK.NewTable()
|
table := eaclSDK.NewTable()
|
||||||
raw, err := os.ReadFile(eaclPath)
|
raw, err := os.ReadFile(eaclPath)
|
||||||
common.ExitOnErr(cmd, "can't read extended ACL file: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't read extended ACL file: %w", err)
|
||||||
common.ExitOnErr(cmd, "can't parse extended ACL: %w", json.Unmarshal(raw, table))
|
commonCmd.ExitOnErr(cmd, "can't parse extended ACL: %w", json.Unmarshal(raw, table))
|
||||||
b.SetEACLTable(*table)
|
b.SetEACLTable(*table)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,12 +115,12 @@ func createToken(cmd *cobra.Command, _ []string) {
|
||||||
toJSON, _ := cmd.Flags().GetBool(jsonFlag)
|
toJSON, _ := cmd.Flags().GetBool(jsonFlag)
|
||||||
if toJSON {
|
if toJSON {
|
||||||
data, err = json.Marshal(b)
|
data, err = json.Marshal(b)
|
||||||
common.ExitOnErr(cmd, "can't mashal token to JSON: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't mashal token to JSON: %w", err)
|
||||||
} else {
|
} else {
|
||||||
data = b.Marshal()
|
data = b.Marshal()
|
||||||
}
|
}
|
||||||
|
|
||||||
out, _ := cmd.Flags().GetString(outFlag)
|
out, _ := cmd.Flags().GetString(outFlag)
|
||||||
err = os.WriteFile(out, data, 0644)
|
err = os.WriteFile(out, data, 0644)
|
||||||
common.ExitOnErr(cmd, "can't write token to file: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't write token to file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/container"
|
"github.com/TrueCloudLab/frostfs-sdk-go/container"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/container/acl"
|
"github.com/TrueCloudLab/frostfs-sdk-go/container/acl"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/netmap"
|
"github.com/TrueCloudLab/frostfs-sdk-go/netmap"
|
||||||
|
@ -37,7 +38,7 @@ var createContainerCmd = &cobra.Command{
|
||||||
It will be stored in sidechain when inner ring will accepts it.`,
|
It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
placementPolicy, err := parseContainerPolicy(cmd, containerPolicy)
|
placementPolicy, err := parseContainerPolicy(cmd, containerPolicy)
|
||||||
common.ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
|
|
||||||
key := key.Get(cmd)
|
key := key.Get(cmd)
|
||||||
cli := internalclient.GetSDKClientByFlag(cmd, key, commonflags.RPC)
|
cli := internalclient.GetSDKClientByFlag(cmd, key, commonflags.RPC)
|
||||||
|
@ -47,16 +48,16 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
prm.SetClient(cli)
|
prm.SetClient(cli)
|
||||||
|
|
||||||
resmap, err := internalclient.NetMapSnapshot(prm)
|
resmap, err := internalclient.NetMapSnapshot(prm)
|
||||||
common.ExitOnErr(cmd, "unable to get netmap snapshot to validate container placement, "+
|
commonCmd.ExitOnErr(cmd, "unable to get netmap snapshot to validate container placement, "+
|
||||||
"use --force option to skip this check: %w", err)
|
"use --force option to skip this check: %w", err)
|
||||||
|
|
||||||
nodesByRep, err := resmap.NetMap().ContainerNodes(*placementPolicy, nil)
|
nodesByRep, err := resmap.NetMap().ContainerNodes(*placementPolicy, nil)
|
||||||
common.ExitOnErr(cmd, "could not build container nodes based on given placement policy, "+
|
commonCmd.ExitOnErr(cmd, "could not build container nodes based on given placement policy, "+
|
||||||
"use --force option to skip this check: %w", err)
|
"use --force option to skip this check: %w", err)
|
||||||
|
|
||||||
for i, nodes := range nodesByRep {
|
for i, nodes := range nodesByRep {
|
||||||
if placementPolicy.ReplicaNumberByIndex(i) > uint32(len(nodes)) {
|
if placementPolicy.ReplicaNumberByIndex(i) > uint32(len(nodes)) {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf(
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf(
|
||||||
"the number of nodes '%d' in selector is not enough for the number of replicas '%d', "+
|
"the number of nodes '%d' in selector is not enough for the number of replicas '%d', "+
|
||||||
"use --force option to skip this check",
|
"use --force option to skip this check",
|
||||||
len(nodes),
|
len(nodes),
|
||||||
|
@ -70,7 +71,7 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
var subnetID subnetid.ID
|
var subnetID subnetid.ID
|
||||||
|
|
||||||
err = subnetID.DecodeString(containerSubnet)
|
err = subnetID.DecodeString(containerSubnet)
|
||||||
common.ExitOnErr(cmd, "could not parse subnetID: %w", err)
|
commonCmd.ExitOnErr(cmd, "could not parse subnetID: %w", err)
|
||||||
|
|
||||||
placementPolicy.RestrictSubnet(subnetID)
|
placementPolicy.RestrictSubnet(subnetID)
|
||||||
}
|
}
|
||||||
|
@ -79,10 +80,10 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
cnr.Init()
|
cnr.Init()
|
||||||
|
|
||||||
err = parseAttributes(&cnr, containerAttributes)
|
err = parseAttributes(&cnr, containerAttributes)
|
||||||
common.ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
|
|
||||||
var basicACL acl.Basic
|
var basicACL acl.Basic
|
||||||
common.ExitOnErr(cmd, "decode basic ACL string: %w", basicACL.DecodeString(containerACL))
|
commonCmd.ExitOnErr(cmd, "decode basic ACL string: %w", basicACL.DecodeString(containerACL))
|
||||||
|
|
||||||
tok := getSession(cmd)
|
tok := getSession(cmd)
|
||||||
|
|
||||||
|
@ -104,7 +105,7 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
syncContainerPrm.SetContainer(&cnr)
|
syncContainerPrm.SetContainer(&cnr)
|
||||||
|
|
||||||
_, err = internalclient.SyncContainerSettings(syncContainerPrm)
|
_, err = internalclient.SyncContainerSettings(syncContainerPrm)
|
||||||
common.ExitOnErr(cmd, "syncing container's settings rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "syncing container's settings rpc error: %w", err)
|
||||||
|
|
||||||
var putPrm internalclient.PutContainerPrm
|
var putPrm internalclient.PutContainerPrm
|
||||||
putPrm.SetClient(cli)
|
putPrm.SetClient(cli)
|
||||||
|
@ -115,7 +116,7 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := internalclient.PutContainer(putPrm)
|
res, err := internalclient.PutContainer(putPrm)
|
||||||
common.ExitOnErr(cmd, "put container rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "put container rpc error: %w", err)
|
||||||
|
|
||||||
id := res.ID()
|
id := res.ID()
|
||||||
|
|
||||||
|
@ -138,7 +139,7 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common.ExitOnErr(cmd, "", errCreateTimeout)
|
commonCmd.ExitOnErr(cmd, "", errCreateTimeout)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
objectSDK "github.com/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "github.com/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/user"
|
"github.com/TrueCloudLab/frostfs-sdk-go/user"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -34,7 +35,7 @@ Only owner of the container has a permission to remove container.`,
|
||||||
getPrm.SetContainer(id)
|
getPrm.SetContainer(id)
|
||||||
|
|
||||||
resGet, err := internalclient.GetContainer(getPrm)
|
resGet, err := internalclient.GetContainer(getPrm)
|
||||||
common.ExitOnErr(cmd, "can't get the container: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't get the container: %w", err)
|
||||||
|
|
||||||
owner := resGet.Container().Owner()
|
owner := resGet.Container().Owner()
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ Only owner of the container has a permission to remove container.`,
|
||||||
common.PrintVerbose(cmd, "Checking session issuer...")
|
common.PrintVerbose(cmd, "Checking session issuer...")
|
||||||
|
|
||||||
if !tok.Issuer().Equals(owner) {
|
if !tok.Issuer().Equals(owner) {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("session issuer differs with the container owner: expected %s, has %s", owner, tok.Issuer()))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("session issuer differs with the container owner: expected %s, has %s", owner, tok.Issuer()))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
common.PrintVerbose(cmd, "Checking provided account...")
|
common.PrintVerbose(cmd, "Checking provided account...")
|
||||||
|
@ -51,7 +52,7 @@ Only owner of the container has a permission to remove container.`,
|
||||||
user.IDFromKey(&acc, pk.PublicKey)
|
user.IDFromKey(&acc, pk.PublicKey)
|
||||||
|
|
||||||
if !acc.Equals(owner) {
|
if !acc.Equals(owner) {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("provided account differs with the container owner: expected %s, has %s", owner, acc))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("provided account differs with the container owner: expected %s, has %s", owner, acc))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,10 +73,10 @@ Only owner of the container has a permission to remove container.`,
|
||||||
common.PrintVerbose(cmd, "Searching for LOCK objects...")
|
common.PrintVerbose(cmd, "Searching for LOCK objects...")
|
||||||
|
|
||||||
res, err := internalclient.SearchObjects(searchPrm)
|
res, err := internalclient.SearchObjects(searchPrm)
|
||||||
common.ExitOnErr(cmd, "can't search for LOCK objects: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't search for LOCK objects: %w", err)
|
||||||
|
|
||||||
if len(res.IDList()) != 0 {
|
if len(res.IDList()) != 0 {
|
||||||
common.ExitOnErr(cmd, "",
|
commonCmd.ExitOnErr(cmd, "",
|
||||||
fmt.Errorf("Container wasn't removed because LOCK objects were found.\n"+
|
fmt.Errorf("Container wasn't removed because LOCK objects were found.\n"+
|
||||||
"Use --%s flag to remove anyway.", commonflags.ForceFlag))
|
"Use --%s flag to remove anyway.", commonflags.ForceFlag))
|
||||||
}
|
}
|
||||||
|
@ -91,7 +92,7 @@ Only owner of the container has a permission to remove container.`,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := internalclient.DeleteContainer(delPrm)
|
_, err := internalclient.DeleteContainer(delPrm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
cmd.Println("container delete method invoked")
|
cmd.Println("container delete method invoked")
|
||||||
|
|
||||||
|
@ -112,7 +113,7 @@ Only owner of the container has a permission to remove container.`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common.ExitOnErr(cmd, "", errDeleteTimeout)
|
commonCmd.ExitOnErr(cmd, "", errDeleteTimeout)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/util"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/util"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/container"
|
"github.com/TrueCloudLab/frostfs-sdk-go/container"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/container/acl"
|
"github.com/TrueCloudLab/frostfs-sdk-go/container/acl"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
|
@ -44,13 +45,13 @@ var getContainerInfoCmd = &cobra.Command{
|
||||||
|
|
||||||
if containerJSON {
|
if containerJSON {
|
||||||
data, err = cnr.MarshalJSON()
|
data, err = cnr.MarshalJSON()
|
||||||
common.ExitOnErr(cmd, "can't JSON encode container: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't JSON encode container: %w", err)
|
||||||
} else {
|
} else {
|
||||||
data = cnr.Marshal()
|
data = cnr.Marshal()
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.WriteFile(containerPathTo, data, 0644)
|
err = os.WriteFile(containerPathTo, data, 0644)
|
||||||
common.ExitOnErr(cmd, "can't write container to file: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't write container to file: %w", err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -96,7 +97,7 @@ func prettyPrintContainer(cmd *cobra.Command, cnr container.Container, jsonEncod
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd.Println("placement policy:")
|
cmd.Println("placement policy:")
|
||||||
common.ExitOnErr(cmd, "write policy: %w", cnr.PlacementPolicy().WriteStringTo((*stringWriter)(cmd)))
|
commonCmd.ExitOnErr(cmd, "write policy: %w", cnr.PlacementPolicy().WriteStringTo((*stringWriter)(cmd)))
|
||||||
cmd.Println()
|
cmd.Println()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,10 +138,10 @@ func getContainer(cmd *cobra.Command) (container.Container, *ecdsa.PrivateKey) {
|
||||||
var pk *ecdsa.PrivateKey
|
var pk *ecdsa.PrivateKey
|
||||||
if containerPathFrom != "" {
|
if containerPathFrom != "" {
|
||||||
data, err := os.ReadFile(containerPathFrom)
|
data, err := os.ReadFile(containerPathFrom)
|
||||||
common.ExitOnErr(cmd, "can't read file: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't read file: %w", err)
|
||||||
|
|
||||||
err = cnr.Unmarshal(data)
|
err = cnr.Unmarshal(data)
|
||||||
common.ExitOnErr(cmd, "can't unmarshal container: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't unmarshal container: %w", err)
|
||||||
} else {
|
} else {
|
||||||
id := parseContainerID(cmd)
|
id := parseContainerID(cmd)
|
||||||
pk = key.GetOrGenerate(cmd)
|
pk = key.GetOrGenerate(cmd)
|
||||||
|
@ -151,7 +152,7 @@ func getContainer(cmd *cobra.Command) (container.Container, *ecdsa.PrivateKey) {
|
||||||
prm.SetContainer(id)
|
prm.SetContainer(id)
|
||||||
|
|
||||||
res, err := internalclient.GetContainer(prm)
|
res, err := internalclient.GetContainer(prm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
cnr = res.Container()
|
cnr = res.Container()
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ var getExtendedACLCmd = &cobra.Command{
|
||||||
eaclPrm.SetContainer(id)
|
eaclPrm.SetContainer(id)
|
||||||
|
|
||||||
res, err := internalclient.EACL(eaclPrm)
|
res, err := internalclient.EACL(eaclPrm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
eaclTable := res.EACL()
|
eaclTable := res.EACL()
|
||||||
|
|
||||||
|
@ -39,16 +40,16 @@ var getExtendedACLCmd = &cobra.Command{
|
||||||
|
|
||||||
if containerJSON {
|
if containerJSON {
|
||||||
data, err = eaclTable.MarshalJSON()
|
data, err = eaclTable.MarshalJSON()
|
||||||
common.ExitOnErr(cmd, "can't encode to JSON: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't encode to JSON: %w", err)
|
||||||
} else {
|
} else {
|
||||||
data, err = eaclTable.Marshal()
|
data, err = eaclTable.Marshal()
|
||||||
common.ExitOnErr(cmd, "can't encode to binary: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't encode to binary: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Println("dumping data to file:", containerPathTo)
|
cmd.Println("dumping data to file:", containerPathTo)
|
||||||
|
|
||||||
err = os.WriteFile(containerPathTo, data, 0644)
|
err = os.WriteFile(containerPathTo, data, 0644)
|
||||||
common.ExitOnErr(cmd, "could not write eACL to file: %w", err)
|
commonCmd.ExitOnErr(cmd, "could not write eACL to file: %w", err)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
|
|
||||||
"github.com/TrueCloudLab/frostfs-api-go/v2/container"
|
"github.com/TrueCloudLab/frostfs-api-go/v2/container"
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/user"
|
"github.com/TrueCloudLab/frostfs-sdk-go/user"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -37,7 +37,7 @@ var listContainersCmd = &cobra.Command{
|
||||||
user.IDFromKey(&idUser, key.PublicKey)
|
user.IDFromKey(&idUser, key.PublicKey)
|
||||||
} else {
|
} else {
|
||||||
err := idUser.DecodeString(flagVarListContainerOwner)
|
err := idUser.DecodeString(flagVarListContainerOwner)
|
||||||
common.ExitOnErr(cmd, "invalid user ID: %w", err)
|
commonCmd.ExitOnErr(cmd, "invalid user ID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cli := internalclient.GetSDKClientByFlag(cmd, key, commonflags.RPC)
|
cli := internalclient.GetSDKClientByFlag(cmd, key, commonflags.RPC)
|
||||||
|
@ -47,7 +47,7 @@ var listContainersCmd = &cobra.Command{
|
||||||
prm.SetAccount(idUser)
|
prm.SetAccount(idUser)
|
||||||
|
|
||||||
res, err := internalclient.ListContainers(prm)
|
res, err := internalclient.ListContainers(prm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
var prmGet internalclient.GetContainerPrm
|
var prmGet internalclient.GetContainerPrm
|
||||||
prmGet.SetClient(cli)
|
prmGet.SetClient(cli)
|
||||||
|
|
|
@ -5,10 +5,10 @@ import (
|
||||||
|
|
||||||
v2object "github.com/TrueCloudLab/frostfs-api-go/v2/object"
|
v2object "github.com/TrueCloudLab/frostfs-api-go/v2/object"
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
objectCli "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/object"
|
objectCli "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/object"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -52,7 +52,7 @@ var listContainerObjectsCmd = &cobra.Command{
|
||||||
prmSearch.SetFilters(*filters)
|
prmSearch.SetFilters(*filters)
|
||||||
|
|
||||||
res, err := internalclient.SearchObjects(prmSearch)
|
res, err := internalclient.SearchObjects(prmSearch)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
objectIDs := res.IDList()
|
objectIDs := res.IDList()
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
|
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
containerAPI "github.com/TrueCloudLab/frostfs-sdk-go/container"
|
containerAPI "github.com/TrueCloudLab/frostfs-sdk-go/container"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/netmap"
|
"github.com/TrueCloudLab/frostfs-sdk-go/netmap"
|
||||||
|
@ -32,7 +32,7 @@ var containerNodesCmd = &cobra.Command{
|
||||||
prm.SetClient(cli)
|
prm.SetClient(cli)
|
||||||
|
|
||||||
resmap, err := internalclient.NetMapSnapshot(prm)
|
resmap, err := internalclient.NetMapSnapshot(prm)
|
||||||
common.ExitOnErr(cmd, "unable to get netmap snapshot", err)
|
commonCmd.ExitOnErr(cmd, "unable to get netmap snapshot", err)
|
||||||
|
|
||||||
var id cid.ID
|
var id cid.ID
|
||||||
containerAPI.CalculateID(&id, cnr)
|
containerAPI.CalculateID(&id, cnr)
|
||||||
|
@ -43,12 +43,12 @@ var containerNodesCmd = &cobra.Command{
|
||||||
|
|
||||||
var cnrNodes [][]netmap.NodeInfo
|
var cnrNodes [][]netmap.NodeInfo
|
||||||
cnrNodes, err = resmap.NetMap().ContainerNodes(policy, binCnr)
|
cnrNodes, err = resmap.NetMap().ContainerNodes(policy, binCnr)
|
||||||
common.ExitOnErr(cmd, "could not build container nodes for given container: %w", err)
|
commonCmd.ExitOnErr(cmd, "could not build container nodes for given container: %w", err)
|
||||||
|
|
||||||
for i := range cnrNodes {
|
for i := range cnrNodes {
|
||||||
cmd.Printf("Descriptor #%d, REP %d:\n", i+1, policy.ReplicaNumberByIndex(i))
|
cmd.Printf("Descriptor #%d, REP %d:\n", i+1, policy.ReplicaNumberByIndex(i))
|
||||||
for j := range cnrNodes[i] {
|
for j := range cnrNodes[i] {
|
||||||
common.PrettyPrintNodeInfo(cmd, cnrNodes[i][j], j, "\t", short)
|
commonCmd.PrettyPrintNodeInfo(cmd, cnrNodes[i][j], j, "\t", short)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -38,10 +39,10 @@ Container ID in EACL table will be substituted with ID from the CLI.`,
|
||||||
cmd.Println("Checking the ability to modify access rights in the container...")
|
cmd.Println("Checking the ability to modify access rights in the container...")
|
||||||
|
|
||||||
extendable, err := internalclient.IsACLExtendable(cli, id)
|
extendable, err := internalclient.IsACLExtendable(cli, id)
|
||||||
common.ExitOnErr(cmd, "Extensibility check failure: %w", err)
|
commonCmd.ExitOnErr(cmd, "Extensibility check failure: %w", err)
|
||||||
|
|
||||||
if !extendable {
|
if !extendable {
|
||||||
common.ExitOnErr(cmd, "", errors.New("container ACL is immutable"))
|
commonCmd.ExitOnErr(cmd, "", errors.New("container ACL is immutable"))
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Println("ACL extension is enabled in the container, continue processing.")
|
cmd.Println("ACL extension is enabled in the container, continue processing.")
|
||||||
|
@ -56,11 +57,11 @@ Container ID in EACL table will be substituted with ID from the CLI.`,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := internalclient.SetEACL(setEACLPrm)
|
_, err := internalclient.SetEACL(setEACLPrm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
if containerAwait {
|
if containerAwait {
|
||||||
exp, err := eaclTable.Marshal()
|
exp, err := eaclTable.Marshal()
|
||||||
common.ExitOnErr(cmd, "broken EACL table: %w", err)
|
commonCmd.ExitOnErr(cmd, "broken EACL table: %w", err)
|
||||||
|
|
||||||
cmd.Println("awaiting...")
|
cmd.Println("awaiting...")
|
||||||
|
|
||||||
|
@ -87,7 +88,7 @@ Container ID in EACL table will be substituted with ID from the CLI.`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common.ExitOnErr(cmd, "", errSetEACLTimeout)
|
commonCmd.ExitOnErr(cmd, "", errSetEACLTimeout)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/session"
|
"github.com/TrueCloudLab/frostfs-sdk-go/session"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -24,12 +25,12 @@ var (
|
||||||
|
|
||||||
func parseContainerID(cmd *cobra.Command) cid.ID {
|
func parseContainerID(cmd *cobra.Command) cid.ID {
|
||||||
if containerID == "" {
|
if containerID == "" {
|
||||||
common.ExitOnErr(cmd, "", errors.New("container ID is not set"))
|
commonCmd.ExitOnErr(cmd, "", errors.New("container ID is not set"))
|
||||||
}
|
}
|
||||||
|
|
||||||
var id cid.ID
|
var id cid.ID
|
||||||
err := id.DecodeString(containerID)
|
err := id.DecodeString(containerID)
|
||||||
common.ExitOnErr(cmd, "can't decode container ID value: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't decode container ID value: %w", err)
|
||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ func getSession(cmd *cobra.Command) *session.Container {
|
||||||
var res session.Container
|
var res session.Container
|
||||||
|
|
||||||
err := common.ReadBinaryOrJSON(cmd, &res, path)
|
err := common.ReadBinaryOrJSON(cmd, &res, path)
|
||||||
common.ExitOnErr(cmd, "read container session: %v", err)
|
commonCmd.ExitOnErr(cmd, "read container session: %v", err)
|
||||||
|
|
||||||
common.PrintVerbose(cmd, "Session successfully read.")
|
common.PrintVerbose(cmd, "Session successfully read.")
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ package control
|
||||||
|
|
||||||
import (
|
import (
|
||||||
rawclient "github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
rawclient "github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -40,7 +40,7 @@ var dropObjectsCmd = &cobra.Command{
|
||||||
resp, err = control.DropObjects(client, req)
|
resp, err = control.DropObjects(client, req)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
common.ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
|
|
||||||
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ package control
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
"github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -32,7 +32,7 @@ func evacuateShard(cmd *cobra.Command, _ []string) {
|
||||||
resp, err = control.EvacuateShard(client, req)
|
resp, err = control.EvacuateShard(client, req)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
cmd.Printf("Objects moved: %d\n", resp.GetBody().GetCount())
|
cmd.Printf("Objects moved: %d\n", resp.GetBody().GetCount())
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ package control
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
"github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -31,7 +31,7 @@ func flushCache(cmd *cobra.Command, _ []string) {
|
||||||
resp, err = control.FlushCache(client, req)
|
resp, err = control.FlushCache(client, req)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
|
|
||||||
rawclient "github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
rawclient "github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
||||||
ircontrol "github.com/TrueCloudLab/frostfs-node/pkg/services/control/ir"
|
ircontrol "github.com/TrueCloudLab/frostfs-node/pkg/services/control/ir"
|
||||||
ircontrolsrv "github.com/TrueCloudLab/frostfs-node/pkg/services/control/ir/server"
|
ircontrolsrv "github.com/TrueCloudLab/frostfs-node/pkg/services/control/ir/server"
|
||||||
|
@ -52,7 +52,7 @@ func healthCheck(cmd *cobra.Command, _ []string) {
|
||||||
resp, err = control.HealthCheck(client, req)
|
resp, err = control.HealthCheck(client, req)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
||||||
|
|
||||||
|
@ -66,14 +66,14 @@ func healthCheckIR(cmd *cobra.Command, key *ecdsa.PrivateKey, c *client.Client)
|
||||||
req.SetBody(new(ircontrol.HealthCheckRequest_Body))
|
req.SetBody(new(ircontrol.HealthCheckRequest_Body))
|
||||||
|
|
||||||
err := ircontrolsrv.SignMessage(key, req)
|
err := ircontrolsrv.SignMessage(key, req)
|
||||||
common.ExitOnErr(cmd, "could not sign request: %w", err)
|
commonCmd.ExitOnErr(cmd, "could not sign request: %w", err)
|
||||||
|
|
||||||
var resp *ircontrol.HealthCheckResponse
|
var resp *ircontrol.HealthCheckResponse
|
||||||
err = c.ExecRaw(func(client *rawclient.Client) error {
|
err = c.ExecRaw(func(client *rawclient.Client) error {
|
||||||
resp, err = ircontrol.HealthCheck(client, req)
|
resp, err = ircontrol.HealthCheck(client, req)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -57,7 +58,7 @@ func setNetmapStatus(cmd *cobra.Command, _ []string) {
|
||||||
|
|
||||||
switch st, _ := cmd.Flags().GetString(netmapStatusFlag); st {
|
switch st, _ := cmd.Flags().GetString(netmapStatusFlag); st {
|
||||||
default:
|
default:
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("unsupported status %s", st))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("unsupported status %s", st))
|
||||||
case netmapStatusOnline:
|
case netmapStatusOnline:
|
||||||
body.SetStatus(control.NetmapStatus_ONLINE)
|
body.SetStatus(control.NetmapStatus_ONLINE)
|
||||||
printIgnoreForce(control.NetmapStatus_ONLINE)
|
printIgnoreForce(control.NetmapStatus_ONLINE)
|
||||||
|
@ -86,7 +87,7 @@ func setNetmapStatus(cmd *cobra.Command, _ []string) {
|
||||||
resp, err = control.SetNetmapStatus(client, req)
|
resp, err = control.SetNetmapStatus(client, req)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ package control
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
"github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -45,7 +45,7 @@ func dumpShard(cmd *cobra.Command, _ []string) {
|
||||||
resp, err = control.DumpShard(client, req)
|
resp, err = control.DumpShard(client, req)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
rawclient "github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
rawclient "github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
||||||
"github.com/mr-tron/base58"
|
"github.com/mr-tron/base58"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -45,7 +45,7 @@ func listShards(cmd *cobra.Command, _ []string) {
|
||||||
resp, err = control.ListShards(client, req)
|
resp, err = control.ListShards(client, req)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ func prettyPrintShardsJSON(cmd *cobra.Command, ii []*control.ShardInfo) {
|
||||||
buf := bytes.NewBuffer(nil)
|
buf := bytes.NewBuffer(nil)
|
||||||
enc := json.NewEncoder(buf)
|
enc := json.NewEncoder(buf)
|
||||||
enc.SetIndent("", " ")
|
enc.SetIndent("", " ")
|
||||||
common.ExitOnErr(cmd, "cannot shard info to JSON: %w", enc.Encode(out))
|
commonCmd.ExitOnErr(cmd, "cannot shard info to JSON: %w", enc.Encode(out))
|
||||||
|
|
||||||
cmd.Print(buf.String()) // pretty printer emits newline, to no need for Println
|
cmd.Print(buf.String()) // pretty printer emits newline, to no need for Println
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package control
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
"github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -45,7 +45,7 @@ func restoreShard(cmd *cobra.Command, _ []string) {
|
||||||
resp, err = control.RestoreShard(client, req)
|
resp, err = control.RestoreShard(client, req)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
rawclient "github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
rawclient "github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
||||||
"github.com/mr-tron/base58"
|
"github.com/mr-tron/base58"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -106,7 +106,7 @@ func setShardMode(cmd *cobra.Command, _ []string) {
|
||||||
|
|
||||||
mode, ok := lookUpShardModeFromString(strMode)
|
mode, ok := lookUpShardModeFromString(strMode)
|
||||||
if !ok {
|
if !ok {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("unsupported mode %s", strMode))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("unsupported mode %s", strMode))
|
||||||
}
|
}
|
||||||
|
|
||||||
req := new(control.SetShardModeRequest)
|
req := new(control.SetShardModeRequest)
|
||||||
|
@ -130,7 +130,7 @@ func setShardMode(cmd *cobra.Command, _ []string) {
|
||||||
resp, err = control.SetShardMode(client, req)
|
resp, err = control.SetShardMode(client, req)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ func setShardMode(cmd *cobra.Command, _ []string) {
|
||||||
func getShardID(cmd *cobra.Command) []byte {
|
func getShardID(cmd *cobra.Command) []byte {
|
||||||
sid, _ := cmd.Flags().GetString(shardIDFlag)
|
sid, _ := cmd.Flags().GetString(shardIDFlag)
|
||||||
raw, err := base58.Decode(sid)
|
raw, err := base58.Decode(sid)
|
||||||
common.ExitOnErr(cmd, "incorrect shard ID encoding: %w", err)
|
commonCmd.ExitOnErr(cmd, "incorrect shard ID encoding: %w", err)
|
||||||
return raw
|
return raw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ func getShardIDList(cmd *cobra.Command) [][]byte {
|
||||||
|
|
||||||
sidList, _ := cmd.Flags().GetStringSlice(shardIDFlag)
|
sidList, _ := cmd.Flags().GetStringSlice(shardIDFlag)
|
||||||
if len(sidList) == 0 {
|
if len(sidList) == 0 {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("either --%s or --%s flag must be provided", shardIDFlag, shardAllFlag))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("either --%s or --%s flag must be provided", shardIDFlag, shardAllFlag))
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can sort the ID list and perform this check without additional allocations,
|
// We can sort the ID list and perform this check without additional allocations,
|
||||||
|
@ -161,7 +161,7 @@ func getShardIDList(cmd *cobra.Command) [][]byte {
|
||||||
seen := make(map[string]struct{})
|
seen := make(map[string]struct{})
|
||||||
for i := range sidList {
|
for i := range sidList {
|
||||||
if _, ok := seen[sidList[i]]; ok {
|
if _, ok := seen[sidList[i]]; ok {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("duplicated shard IDs: %s", sidList[i]))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("duplicated shard IDs: %s", sidList[i]))
|
||||||
}
|
}
|
||||||
seen[sidList[i]] = struct{}{}
|
seen[sidList[i]] = struct{}{}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ func getShardIDList(cmd *cobra.Command) [][]byte {
|
||||||
res := make([][]byte, 0, len(sidList))
|
res := make([][]byte, 0, len(sidList))
|
||||||
for i := range sidList {
|
for i := range sidList {
|
||||||
raw, err := base58.Decode(sidList[i])
|
raw, err := base58.Decode(sidList[i])
|
||||||
common.ExitOnErr(cmd, "incorrect shard ID encoding: %w", err)
|
commonCmd.ExitOnErr(cmd, "incorrect shard ID encoding: %w", err)
|
||||||
|
|
||||||
res = append(res, raw)
|
res = append(res, raw)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
rawclient "github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
rawclient "github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
||||||
controlSvc "github.com/TrueCloudLab/frostfs-node/pkg/services/control/server"
|
controlSvc "github.com/TrueCloudLab/frostfs-node/pkg/services/control/server"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
|
@ -40,11 +40,11 @@ func synchronizeTree(cmd *cobra.Command, _ []string) {
|
||||||
|
|
||||||
var cnr cid.ID
|
var cnr cid.ID
|
||||||
cidStr, _ := cmd.Flags().GetString(commonflags.CIDFlag)
|
cidStr, _ := cmd.Flags().GetString(commonflags.CIDFlag)
|
||||||
common.ExitOnErr(cmd, "can't decode container ID: %w", cnr.DecodeString(cidStr))
|
commonCmd.ExitOnErr(cmd, "can't decode container ID: %w", cnr.DecodeString(cidStr))
|
||||||
|
|
||||||
treeID, _ := cmd.Flags().GetString("tree-id")
|
treeID, _ := cmd.Flags().GetString("tree-id")
|
||||||
if treeID == "" {
|
if treeID == "" {
|
||||||
common.ExitOnErr(cmd, "", errors.New("tree ID must not be empty"))
|
commonCmd.ExitOnErr(cmd, "", errors.New("tree ID must not be empty"))
|
||||||
}
|
}
|
||||||
|
|
||||||
height, _ := cmd.Flags().GetUint64("height")
|
height, _ := cmd.Flags().GetUint64("height")
|
||||||
|
@ -61,7 +61,7 @@ func synchronizeTree(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
err := controlSvc.SignMessage(pk, req)
|
err := controlSvc.SignMessage(pk, req)
|
||||||
common.ExitOnErr(cmd, "could not sign request: %w", err)
|
commonCmd.ExitOnErr(cmd, "could not sign request: %w", err)
|
||||||
|
|
||||||
cli := getClient(cmd, pk)
|
cli := getClient(cmd, pk)
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ func synchronizeTree(cmd *cobra.Command, _ []string) {
|
||||||
resp, err = control.SynchronizeTree(client, req)
|
resp, err = control.SynchronizeTree(client, req)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ import (
|
||||||
|
|
||||||
"github.com/TrueCloudLab/frostfs-api-go/v2/refs"
|
"github.com/TrueCloudLab/frostfs-api-go/v2/refs"
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
controlSvc "github.com/TrueCloudLab/frostfs-node/pkg/services/control/server"
|
controlSvc "github.com/TrueCloudLab/frostfs-node/pkg/services/control/server"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/client"
|
"github.com/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
frostfscrypto "github.com/TrueCloudLab/frostfs-sdk-go/crypto"
|
frostfscrypto "github.com/TrueCloudLab/frostfs-sdk-go/crypto"
|
||||||
|
@ -24,7 +24,7 @@ func initControlFlags(cmd *cobra.Command) {
|
||||||
|
|
||||||
func signRequest(cmd *cobra.Command, pk *ecdsa.PrivateKey, req controlSvc.SignedMessage) {
|
func signRequest(cmd *cobra.Command, pk *ecdsa.PrivateKey, req controlSvc.SignedMessage) {
|
||||||
err := controlSvc.SignMessage(pk, req)
|
err := controlSvc.SignMessage(pk, req)
|
||||||
common.ExitOnErr(cmd, "could not sign request: %w", err)
|
commonCmd.ExitOnErr(cmd, "could not sign request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyResponse(cmd *cobra.Command,
|
func verifyResponse(cmd *cobra.Command,
|
||||||
|
@ -37,7 +37,7 @@ func verifyResponse(cmd *cobra.Command,
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
if sigControl == nil {
|
if sigControl == nil {
|
||||||
common.ExitOnErr(cmd, "", errors.New("missing response signature"))
|
commonCmd.ExitOnErr(cmd, "", errors.New("missing response signature"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(@cthulhu-rider): #1387 use Signature message from NeoFS API to avoid conversion
|
// TODO(@cthulhu-rider): #1387 use Signature message from NeoFS API to avoid conversion
|
||||||
|
@ -47,10 +47,10 @@ func verifyResponse(cmd *cobra.Command,
|
||||||
sigV2.SetSign(sigControl.GetSign())
|
sigV2.SetSign(sigControl.GetSign())
|
||||||
|
|
||||||
var sig frostfscrypto.Signature
|
var sig frostfscrypto.Signature
|
||||||
common.ExitOnErr(cmd, "can't read signature: %w", sig.ReadFromV2(sigV2))
|
commonCmd.ExitOnErr(cmd, "can't read signature: %w", sig.ReadFromV2(sigV2))
|
||||||
|
|
||||||
if !sig.Verify(body.StableMarshal(nil)) {
|
if !sig.Verify(body.StableMarshal(nil)) {
|
||||||
common.ExitOnErr(cmd, "", errors.New("invalid response signature"))
|
commonCmd.ExitOnErr(cmd, "", errors.New("invalid response signature"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@ package netmap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ var getEpochCmd = &cobra.Command{
|
||||||
prm.SetClient(cli)
|
prm.SetClient(cli)
|
||||||
|
|
||||||
res, err := internalclient.NetworkInfo(prm)
|
res, err := internalclient.NetworkInfo(prm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
netInfo := res.NetworkInfo()
|
netInfo := res.NetworkInfo()
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -24,7 +24,7 @@ var netInfoCmd = &cobra.Command{
|
||||||
prm.SetClient(cli)
|
prm.SetClient(cli)
|
||||||
|
|
||||||
res, err := internalclient.NetworkInfo(prm)
|
res, err := internalclient.NetworkInfo(prm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
netInfo := res.NetworkInfo()
|
netInfo := res.NetworkInfo()
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/netmap"
|
"github.com/TrueCloudLab/frostfs-sdk-go/netmap"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -25,7 +26,7 @@ var nodeInfoCmd = &cobra.Command{
|
||||||
prm.SetClient(cli)
|
prm.SetClient(cli)
|
||||||
|
|
||||||
res, err := internalclient.NodeInfo(prm)
|
res, err := internalclient.NodeInfo(prm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
prettyPrintNodeInfo(cmd, res.NodeInfo())
|
prettyPrintNodeInfo(cmd, res.NodeInfo())
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,9 +2,9 @@ package netmap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,9 +20,9 @@ var snapshotCmd = &cobra.Command{
|
||||||
prm.SetClient(cli)
|
prm.SetClient(cli)
|
||||||
|
|
||||||
res, err := internalclient.NetMapSnapshot(prm)
|
res, err := internalclient.NetMapSnapshot(prm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
common.PrettyPrintNetMap(cmd, res.NetMap())
|
commonCmd.PrettyPrintNetMap(cmd, res.NetMap(), false)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -41,18 +41,18 @@ func deleteObject(cmd *cobra.Command, _ []string) {
|
||||||
if binary {
|
if binary {
|
||||||
filename, _ := cmd.Flags().GetString(fileFlag)
|
filename, _ := cmd.Flags().GetString(fileFlag)
|
||||||
if filename == "" {
|
if filename == "" {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("required flag \"%s\" not set", fileFlag))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("required flag \"%s\" not set", fileFlag))
|
||||||
}
|
}
|
||||||
objAddr = readObjectAddressBin(cmd, &cnr, &obj, filename)
|
objAddr = readObjectAddressBin(cmd, &cnr, &obj, filename)
|
||||||
} else {
|
} else {
|
||||||
cidVal, _ := cmd.Flags().GetString(commonflags.CIDFlag)
|
cidVal, _ := cmd.Flags().GetString(commonflags.CIDFlag)
|
||||||
if cidVal == "" {
|
if cidVal == "" {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("required flag \"%s\" not set", commonflags.CIDFlag))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("required flag \"%s\" not set", commonflags.CIDFlag))
|
||||||
}
|
}
|
||||||
|
|
||||||
oidVal, _ := cmd.Flags().GetString(commonflags.OIDFlag)
|
oidVal, _ := cmd.Flags().GetString(commonflags.OIDFlag)
|
||||||
if oidVal == "" {
|
if oidVal == "" {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("required flag \"%s\" not set", commonflags.OIDFlag))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("required flag \"%s\" not set", commonflags.OIDFlag))
|
||||||
}
|
}
|
||||||
|
|
||||||
objAddr = readObjectAddress(cmd, &cnr, &obj)
|
objAddr = readObjectAddress(cmd, &cnr, &obj)
|
||||||
|
@ -66,7 +66,7 @@ func deleteObject(cmd *cobra.Command, _ []string) {
|
||||||
prm.SetAddress(objAddr)
|
prm.SetAddress(objAddr)
|
||||||
|
|
||||||
res, err := internalclient.DeleteObject(prm)
|
res, err := internalclient.DeleteObject(prm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
tomb := res.Tombstone()
|
tomb := res.Tombstone()
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -55,7 +55,7 @@ func getObject(cmd *cobra.Command, _ []string) {
|
||||||
} else {
|
} else {
|
||||||
f, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
|
f, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("can't open file '%s': %w", filename, err))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("can't open file '%s': %w", filename, err))
|
||||||
}
|
}
|
||||||
|
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
@ -110,7 +110,7 @@ func getObject(cmd *cobra.Command, _ []string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if binary {
|
if binary {
|
||||||
|
@ -118,9 +118,9 @@ func getObject(cmd *cobra.Command, _ []string) {
|
||||||
// TODO(@acid-ant): #1932 Use streams to marshal/unmarshal payload
|
// TODO(@acid-ant): #1932 Use streams to marshal/unmarshal payload
|
||||||
objToStore.SetPayload(payloadBuffer.Bytes())
|
objToStore.SetPayload(payloadBuffer.Bytes())
|
||||||
objBytes, err := objToStore.Marshal()
|
objBytes, err := objToStore.Marshal()
|
||||||
common.ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
_, err = out.Write(objBytes)
|
_, err = out.Write(objBytes)
|
||||||
common.ExitOnErr(cmd, "unable to write binary object in out: %w ", err)
|
commonCmd.ExitOnErr(cmd, "unable to write binary object in out: %w ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if filename != "" && !strictOutput(cmd) {
|
if filename != "" && !strictOutput(cmd) {
|
||||||
|
@ -130,7 +130,7 @@ func getObject(cmd *cobra.Command, _ []string) {
|
||||||
// Print header only if file is not streamed to stdout.
|
// Print header only if file is not streamed to stdout.
|
||||||
if filename != "" {
|
if filename != "" {
|
||||||
err = printHeader(cmd, res.Header())
|
err = printHeader(cmd, res.Header())
|
||||||
common.ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/checksum"
|
"github.com/TrueCloudLab/frostfs-sdk-go/checksum"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -54,14 +54,14 @@ func getObjectHash(cmd *cobra.Command, _ []string) {
|
||||||
objAddr := readObjectAddress(cmd, &cnr, &obj)
|
objAddr := readObjectAddress(cmd, &cnr, &obj)
|
||||||
|
|
||||||
ranges, err := getRangeList(cmd)
|
ranges, err := getRangeList(cmd)
|
||||||
common.ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
typ, err := getHashType(cmd)
|
typ, err := getHashType(cmd)
|
||||||
common.ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
|
|
||||||
strSalt := strings.TrimPrefix(cmd.Flag(getRangeHashSaltFlag).Value.String(), "0x")
|
strSalt := strings.TrimPrefix(cmd.Flag(getRangeHashSaltFlag).Value.String(), "0x")
|
||||||
|
|
||||||
salt, err := hex.DecodeString(strSalt)
|
salt, err := hex.DecodeString(strSalt)
|
||||||
common.ExitOnErr(cmd, "could not decode salt: %w", err)
|
commonCmd.ExitOnErr(cmd, "could not decode salt: %w", err)
|
||||||
|
|
||||||
pk := key.GetOrGenerate(cmd)
|
pk := key.GetOrGenerate(cmd)
|
||||||
cli := internalclient.GetSDKClientByFlag(cmd, pk, commonflags.RPC)
|
cli := internalclient.GetSDKClientByFlag(cmd, pk, commonflags.RPC)
|
||||||
|
@ -76,7 +76,7 @@ func getObjectHash(cmd *cobra.Command, _ []string) {
|
||||||
|
|
||||||
// get hash of full payload through HEAD (may be user can do it through dedicated command?)
|
// get hash of full payload through HEAD (may be user can do it through dedicated command?)
|
||||||
res, err := internalclient.HeadObject(headPrm)
|
res, err := internalclient.HeadObject(headPrm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
var cs checksum.Checksum
|
var cs checksum.Checksum
|
||||||
var csSet bool
|
var csSet bool
|
||||||
|
@ -109,7 +109,7 @@ func getObjectHash(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := internalclient.HashPayloadRanges(hashPrm)
|
res, err := internalclient.HashPayloadRanges(hashPrm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
hs := res.HashList()
|
hs := res.HashList()
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -70,11 +71,11 @@ func getObjectHeader(cmd *cobra.Command, _ []string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = saveAndPrintHeader(cmd, res.Header(), cmd.Flag(fileFlag).Value.String())
|
err = saveAndPrintHeader(cmd, res.Header(), cmd.Flag(fileFlag).Value.String())
|
||||||
common.ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveAndPrintHeader(cmd *cobra.Command, obj *object.Object, filename string) error {
|
func saveAndPrintHeader(cmd *cobra.Command, obj *object.Object, filename string) error {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
objectSDK "github.com/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "github.com/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -29,7 +30,7 @@ var objectLockCmd = &cobra.Command{
|
||||||
|
|
||||||
var cnr cid.ID
|
var cnr cid.ID
|
||||||
err := cnr.DecodeString(cidRaw)
|
err := cnr.DecodeString(cidRaw)
|
||||||
common.ExitOnErr(cmd, "Incorrect container arg: %v", err)
|
commonCmd.ExitOnErr(cmd, "Incorrect container arg: %v", err)
|
||||||
|
|
||||||
oidsRaw, _ := cmd.Flags().GetStringSlice(commonflags.OIDFlag)
|
oidsRaw, _ := cmd.Flags().GetStringSlice(commonflags.OIDFlag)
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ var objectLockCmd = &cobra.Command{
|
||||||
|
|
||||||
for i := range oidsRaw {
|
for i := range oidsRaw {
|
||||||
err = lockList[i].DecodeString(oidsRaw[i])
|
err = lockList[i].DecodeString(oidsRaw[i])
|
||||||
common.ExitOnErr(cmd, fmt.Sprintf("Incorrect object arg #%d: %%v", i+1), err)
|
commonCmd.ExitOnErr(cmd, fmt.Sprintf("Incorrect object arg #%d: %%v", i+1), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
key := key.GetOrGenerate(cmd)
|
key := key.GetOrGenerate(cmd)
|
||||||
|
@ -51,7 +52,7 @@ var objectLockCmd = &cobra.Command{
|
||||||
exp, _ := cmd.Flags().GetUint64(commonflags.ExpireAt)
|
exp, _ := cmd.Flags().GetUint64(commonflags.ExpireAt)
|
||||||
lifetime, _ := cmd.Flags().GetUint64(commonflags.Lifetime)
|
lifetime, _ := cmd.Flags().GetUint64(commonflags.Lifetime)
|
||||||
if exp == 0 && lifetime == 0 { // mutual exclusion is ensured by cobra
|
if exp == 0 && lifetime == 0 { // mutual exclusion is ensured by cobra
|
||||||
common.ExitOnErr(cmd, "", errors.New("either expiration epoch of a lifetime is required"))
|
commonCmd.ExitOnErr(cmd, "", errors.New("either expiration epoch of a lifetime is required"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if lifetime != 0 {
|
if lifetime != 0 {
|
||||||
|
@ -61,7 +62,7 @@ var objectLockCmd = &cobra.Command{
|
||||||
endpoint, _ := cmd.Flags().GetString(commonflags.RPC)
|
endpoint, _ := cmd.Flags().GetString(commonflags.RPC)
|
||||||
|
|
||||||
currEpoch, err := internalclient.GetCurrentEpoch(ctx, cmd, endpoint)
|
currEpoch, err := internalclient.GetCurrentEpoch(ctx, cmd, endpoint)
|
||||||
common.ExitOnErr(cmd, "Request current epoch: %w", err)
|
commonCmd.ExitOnErr(cmd, "Request current epoch: %w", err)
|
||||||
|
|
||||||
exp = currEpoch + lifetime
|
exp = currEpoch + lifetime
|
||||||
}
|
}
|
||||||
|
@ -85,7 +86,7 @@ var objectLockCmd = &cobra.Command{
|
||||||
prm.SetHeader(obj)
|
prm.SetHeader(obj)
|
||||||
|
|
||||||
res, err := internalclient.PutObject(prm)
|
res, err := internalclient.PutObject(prm)
|
||||||
common.ExitOnErr(cmd, "Store lock object in NeoFS: %w", err)
|
commonCmd.ExitOnErr(cmd, "Store lock object in NeoFS: %w", err)
|
||||||
|
|
||||||
cmd.Printf("Lock object ID: %s\n", res.ID())
|
cmd.Printf("Lock object ID: %s\n", res.ID())
|
||||||
cmd.Println("Objects successfully locked.")
|
cmd.Println("Objects successfully locked.")
|
||||||
|
|
|
@ -12,9 +12,9 @@ import (
|
||||||
|
|
||||||
objectV2 "github.com/TrueCloudLab/frostfs-api-go/v2/object"
|
objectV2 "github.com/TrueCloudLab/frostfs-api-go/v2/object"
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/user"
|
"github.com/TrueCloudLab/frostfs-sdk-go/user"
|
||||||
|
@ -63,7 +63,7 @@ func putObject(cmd *cobra.Command, _ []string) {
|
||||||
cidVal, _ := cmd.Flags().GetString(commonflags.CIDFlag)
|
cidVal, _ := cmd.Flags().GetString(commonflags.CIDFlag)
|
||||||
|
|
||||||
if !binary && cidVal == "" {
|
if !binary && cidVal == "" {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("required flag \"%s\" not set", commonflags.CIDFlag))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("required flag \"%s\" not set", commonflags.CIDFlag))
|
||||||
}
|
}
|
||||||
pk := key.GetOrGenerate(cmd)
|
pk := key.GetOrGenerate(cmd)
|
||||||
|
|
||||||
|
@ -73,17 +73,17 @@ func putObject(cmd *cobra.Command, _ []string) {
|
||||||
filename, _ := cmd.Flags().GetString(fileFlag)
|
filename, _ := cmd.Flags().GetString(fileFlag)
|
||||||
f, err := os.OpenFile(filename, os.O_RDONLY, os.ModePerm)
|
f, err := os.OpenFile(filename, os.O_RDONLY, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("can't open file '%s': %w", filename, err))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("can't open file '%s': %w", filename, err))
|
||||||
}
|
}
|
||||||
var payloadReader io.Reader = f
|
var payloadReader io.Reader = f
|
||||||
obj := object.New()
|
obj := object.New()
|
||||||
|
|
||||||
if binary {
|
if binary {
|
||||||
buf, err := os.ReadFile(filename)
|
buf, err := os.ReadFile(filename)
|
||||||
common.ExitOnErr(cmd, "unable to read given file: %w", err)
|
commonCmd.ExitOnErr(cmd, "unable to read given file: %w", err)
|
||||||
objTemp := object.New()
|
objTemp := object.New()
|
||||||
// TODO(@acid-ant): #1932 Use streams to marshal/unmarshal payload
|
// TODO(@acid-ant): #1932 Use streams to marshal/unmarshal payload
|
||||||
common.ExitOnErr(cmd, "can't unmarshal object from given file: %w", objTemp.Unmarshal(buf))
|
commonCmd.ExitOnErr(cmd, "can't unmarshal object from given file: %w", objTemp.Unmarshal(buf))
|
||||||
payloadReader = bytes.NewReader(objTemp.Payload())
|
payloadReader = bytes.NewReader(objTemp.Payload())
|
||||||
cnr, _ = objTemp.ContainerID()
|
cnr, _ = objTemp.ContainerID()
|
||||||
ownerID = *objTemp.OwnerID()
|
ownerID = *objTemp.OwnerID()
|
||||||
|
@ -93,7 +93,7 @@ func putObject(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
attrs, err := parseObjectAttrs(cmd)
|
attrs, err := parseObjectAttrs(cmd)
|
||||||
common.ExitOnErr(cmd, "can't parse object attributes: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't parse object attributes: %w", err)
|
||||||
|
|
||||||
expiresOn, _ := cmd.Flags().GetUint64(commonflags.ExpireAt)
|
expiresOn, _ := cmd.Flags().GetUint64(commonflags.ExpireAt)
|
||||||
if expiresOn > 0 {
|
if expiresOn > 0 {
|
||||||
|
@ -121,7 +121,7 @@ func putObject(cmd *cobra.Command, _ []string) {
|
||||||
obj.SetAttributes(attrs...)
|
obj.SetAttributes(attrs...)
|
||||||
|
|
||||||
notificationInfo, err := parseObjectNotifications(cmd)
|
notificationInfo, err := parseObjectNotifications(cmd)
|
||||||
common.ExitOnErr(cmd, "can't parse object notification information: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't parse object notification information: %w", err)
|
||||||
|
|
||||||
if notificationInfo != nil {
|
if notificationInfo != nil {
|
||||||
obj.SetNotification(*notificationInfo)
|
obj.SetNotification(*notificationInfo)
|
||||||
|
@ -163,7 +163,7 @@ func putObject(cmd *cobra.Command, _ []string) {
|
||||||
if p != nil {
|
if p != nil {
|
||||||
p.Finish()
|
p.Finish()
|
||||||
}
|
}
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
cmd.Printf("[%s] Object successfully stored\n", filename)
|
cmd.Printf("[%s] Object successfully stored\n", filename)
|
||||||
cmd.Printf(" OID: %s\n CID: %s\n", res.ID(), cnr)
|
cmd.Printf(" OID: %s\n CID: %s\n", res.ID(), cnr)
|
||||||
|
|
|
@ -10,9 +10,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -50,10 +50,10 @@ func getObjectRange(cmd *cobra.Command, _ []string) {
|
||||||
objAddr := readObjectAddress(cmd, &cnr, &obj)
|
objAddr := readObjectAddress(cmd, &cnr, &obj)
|
||||||
|
|
||||||
ranges, err := getRangeList(cmd)
|
ranges, err := getRangeList(cmd)
|
||||||
common.ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
|
|
||||||
if len(ranges) != 1 {
|
if len(ranges) != 1 {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("exactly one range must be specified, got: %d", len(ranges)))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("exactly one range must be specified, got: %d", len(ranges)))
|
||||||
}
|
}
|
||||||
|
|
||||||
var out io.Writer
|
var out io.Writer
|
||||||
|
@ -64,7 +64,7 @@ func getObjectRange(cmd *cobra.Command, _ []string) {
|
||||||
} else {
|
} else {
|
||||||
f, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY, os.ModePerm)
|
f, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("can't open file '%s': %w", filename, err))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("can't open file '%s': %w", filename, err))
|
||||||
}
|
}
|
||||||
|
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
@ -93,7 +93,7 @@ func getObjectRange(cmd *cobra.Command, _ []string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
common.ExitOnErr(cmd, "can't get object payload range: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't get object payload range: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if filename != "" {
|
if filename != "" {
|
||||||
|
@ -116,7 +116,7 @@ func printSplitInfoErr(cmd *cobra.Command, err error) bool {
|
||||||
|
|
||||||
func printSplitInfo(cmd *cobra.Command, info *object.SplitInfo) {
|
func printSplitInfo(cmd *cobra.Command, info *object.SplitInfo) {
|
||||||
bs, err := marshalSplitInfo(cmd, info)
|
bs, err := marshalSplitInfo(cmd, info)
|
||||||
common.ExitOnErr(cmd, "can't marshal split info: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't marshal split info: %w", err)
|
||||||
|
|
||||||
cmd.Println(string(bs))
|
cmd.Println(string(bs))
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oidSDK "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
oidSDK "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -48,7 +48,7 @@ func searchObject(cmd *cobra.Command, _ []string) {
|
||||||
readCID(cmd, &cnr)
|
readCID(cmd, &cnr)
|
||||||
|
|
||||||
sf, err := parseSearchFilters(cmd)
|
sf, err := parseSearchFilters(cmd)
|
||||||
common.ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
|
|
||||||
pk := key.GetOrGenerate(cmd)
|
pk := key.GetOrGenerate(cmd)
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ func searchObject(cmd *cobra.Command, _ []string) {
|
||||||
prm.SetFilters(sf)
|
prm.SetFilters(sf)
|
||||||
|
|
||||||
res, err := internalclient.SearchObjects(prm)
|
res, err := internalclient.SearchObjects(prm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
ids := res.IDList()
|
ids := res.IDList()
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
sessionCli "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/session"
|
sessionCli "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/session"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/bearer"
|
"github.com/TrueCloudLab/frostfs-sdk-go/bearer"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/client"
|
"github.com/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
|
@ -85,9 +86,9 @@ func readObjectAddress(cmd *cobra.Command, cnr *cid.ID, obj *oid.ID) oid.Address
|
||||||
|
|
||||||
func readObjectAddressBin(cmd *cobra.Command, cnr *cid.ID, obj *oid.ID, filename string) oid.Address {
|
func readObjectAddressBin(cmd *cobra.Command, cnr *cid.ID, obj *oid.ID, filename string) oid.Address {
|
||||||
buf, err := os.ReadFile(filename)
|
buf, err := os.ReadFile(filename)
|
||||||
common.ExitOnErr(cmd, "unable to read given file: %w", err)
|
commonCmd.ExitOnErr(cmd, "unable to read given file: %w", err)
|
||||||
objTemp := object.New()
|
objTemp := object.New()
|
||||||
common.ExitOnErr(cmd, "can't unmarshal object from given file: %w", objTemp.Unmarshal(buf))
|
commonCmd.ExitOnErr(cmd, "can't unmarshal object from given file: %w", objTemp.Unmarshal(buf))
|
||||||
|
|
||||||
var addr oid.Address
|
var addr oid.Address
|
||||||
*cnr, _ = objTemp.ContainerID()
|
*cnr, _ = objTemp.ContainerID()
|
||||||
|
@ -99,12 +100,12 @@ func readObjectAddressBin(cmd *cobra.Command, cnr *cid.ID, obj *oid.ID, filename
|
||||||
|
|
||||||
func readCID(cmd *cobra.Command, id *cid.ID) {
|
func readCID(cmd *cobra.Command, id *cid.ID) {
|
||||||
err := id.DecodeString(cmd.Flag(commonflags.CIDFlag).Value.String())
|
err := id.DecodeString(cmd.Flag(commonflags.CIDFlag).Value.String())
|
||||||
common.ExitOnErr(cmd, "decode container ID string: %w", err)
|
commonCmd.ExitOnErr(cmd, "decode container ID string: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func readOID(cmd *cobra.Command, id *oid.ID) {
|
func readOID(cmd *cobra.Command, id *oid.ID) {
|
||||||
err := id.DecodeString(cmd.Flag(commonflags.OIDFlag).Value.String())
|
err := id.DecodeString(cmd.Flag(commonflags.OIDFlag).Value.String())
|
||||||
common.ExitOnErr(cmd, "decode object ID string: %w", err)
|
commonCmd.ExitOnErr(cmd, "decode object ID string: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SessionPrm is a common interface of object operation's input which supports
|
// SessionPrm is a common interface of object operation's input which supports
|
||||||
|
@ -140,7 +141,7 @@ func getSession(cmd *cobra.Command) *session.Object {
|
||||||
var tok session.Object
|
var tok session.Object
|
||||||
|
|
||||||
err := common.ReadBinaryOrJSON(cmd, &tok, path)
|
err := common.ReadBinaryOrJSON(cmd, &tok, path)
|
||||||
common.ExitOnErr(cmd, "read session: %v", err)
|
commonCmd.ExitOnErr(cmd, "read session: %v", err)
|
||||||
|
|
||||||
return &tok
|
return &tok
|
||||||
}
|
}
|
||||||
|
@ -189,15 +190,15 @@ func _readVerifiedSession(cmd *cobra.Command, dst SessionPrm, key *ecdsa.Private
|
||||||
|
|
||||||
switch false {
|
switch false {
|
||||||
case tok.AssertContainer(cnr):
|
case tok.AssertContainer(cnr):
|
||||||
common.ExitOnErr(cmd, "", errors.New("unrelated container in the session"))
|
commonCmd.ExitOnErr(cmd, "", errors.New("unrelated container in the session"))
|
||||||
case obj == nil || tok.AssertObject(*obj):
|
case obj == nil || tok.AssertObject(*obj):
|
||||||
common.ExitOnErr(cmd, "", errors.New("unrelated object in the session"))
|
commonCmd.ExitOnErr(cmd, "", errors.New("unrelated object in the session"))
|
||||||
case tok.AssertVerb(cmdVerb):
|
case tok.AssertVerb(cmdVerb):
|
||||||
common.ExitOnErr(cmd, "", errors.New("wrong verb of the session"))
|
commonCmd.ExitOnErr(cmd, "", errors.New("wrong verb of the session"))
|
||||||
case tok.AssertAuthKey((*frostfsecdsa.PublicKey)(&key.PublicKey)):
|
case tok.AssertAuthKey((*frostfsecdsa.PublicKey)(&key.PublicKey)):
|
||||||
common.ExitOnErr(cmd, "", errors.New("unrelated key in the session"))
|
commonCmd.ExitOnErr(cmd, "", errors.New("unrelated key in the session"))
|
||||||
case tok.VerifySignature():
|
case tok.VerifySignature():
|
||||||
common.ExitOnErr(cmd, "", errors.New("invalid signature of the session data"))
|
commonCmd.ExitOnErr(cmd, "", errors.New("invalid signature of the session data"))
|
||||||
}
|
}
|
||||||
|
|
||||||
common.PrintVerbose(cmd, "Session is correct.")
|
common.PrintVerbose(cmd, "Session is correct.")
|
||||||
|
@ -278,7 +279,7 @@ func OpenSessionViaClient(cmd *cobra.Command, dst SessionPrm, cli *client.Client
|
||||||
common.PrintVerbose(cmd, "Opening remote session with the node...")
|
common.PrintVerbose(cmd, "Opening remote session with the node...")
|
||||||
|
|
||||||
err := sessionCli.CreateSession(&tok, cli, sessionLifetime)
|
err := sessionCli.CreateSession(&tok, cli, sessionLifetime)
|
||||||
common.ExitOnErr(cmd, "open remote session: %w", err)
|
commonCmd.ExitOnErr(cmd, "open remote session: %w", err)
|
||||||
|
|
||||||
common.PrintVerbose(cmd, "Session successfully opened.")
|
common.PrintVerbose(cmd, "Session successfully opened.")
|
||||||
|
|
||||||
|
@ -321,7 +322,7 @@ func finalizeSession(cmd *cobra.Command, dst SessionPrm, tok *session.Object, ke
|
||||||
common.PrintVerbose(cmd, "Signing session...")
|
common.PrintVerbose(cmd, "Signing session...")
|
||||||
|
|
||||||
err := tok.Sign(*key)
|
err := tok.Sign(*key)
|
||||||
common.ExitOnErr(cmd, "sign session: %w", err)
|
commonCmd.ExitOnErr(cmd, "sign session: %w", err)
|
||||||
|
|
||||||
common.PrintVerbose(cmd, "Session token successfully formed and attached to the request.")
|
common.PrintVerbose(cmd, "Session token successfully formed and attached to the request.")
|
||||||
|
|
||||||
|
@ -359,7 +360,7 @@ func collectObjectRelatives(cmd *cobra.Command, cli *client.Client, cnr cid.ID,
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
default:
|
default:
|
||||||
common.ExitOnErr(cmd, "failed to get raw object header: %w", err)
|
commonCmd.ExitOnErr(cmd, "failed to get raw object header: %w", err)
|
||||||
case err == nil:
|
case err == nil:
|
||||||
common.PrintVerbose(cmd, "Raw header received - object is singular.")
|
common.PrintVerbose(cmd, "Raw header received - object is singular.")
|
||||||
return nil
|
return nil
|
||||||
|
@ -407,7 +408,7 @@ func collectObjectRelatives(cmd *cobra.Command, cli *client.Client, cnr cid.ID,
|
||||||
prm.SetFilters(query)
|
prm.SetFilters(query)
|
||||||
|
|
||||||
res, err := internal.SearchObjects(prm)
|
res, err := internal.SearchObjects(prm)
|
||||||
common.ExitOnErr(cmd, "failed to search objects by split ID: %w", err)
|
commonCmd.ExitOnErr(cmd, "failed to search objects by split ID: %w", err)
|
||||||
|
|
||||||
members := res.IDList()
|
members := res.IDList()
|
||||||
|
|
||||||
|
@ -418,7 +419,7 @@ func collectObjectRelatives(cmd *cobra.Command, cli *client.Client, cnr cid.ID,
|
||||||
|
|
||||||
idMember, ok := splitInfo.LastPart()
|
idMember, ok := splitInfo.LastPart()
|
||||||
if !ok {
|
if !ok {
|
||||||
common.ExitOnErr(cmd, "", errors.New("missing any data in received object split information"))
|
commonCmd.ExitOnErr(cmd, "", errors.New("missing any data in received object split information"))
|
||||||
}
|
}
|
||||||
|
|
||||||
common.PrintVerbose(cmd, "Traverse the object split chain in reverse...", idMember)
|
common.PrintVerbose(cmd, "Traverse the object split chain in reverse...", idMember)
|
||||||
|
@ -436,7 +437,7 @@ func collectObjectRelatives(cmd *cobra.Command, cli *client.Client, cnr cid.ID,
|
||||||
addrObj.SetObject(idMember)
|
addrObj.SetObject(idMember)
|
||||||
|
|
||||||
res, err = internal.HeadObject(prmHead)
|
res, err = internal.HeadObject(prmHead)
|
||||||
common.ExitOnErr(cmd, "failed to read split chain member's header: %w", err)
|
commonCmd.ExitOnErr(cmd, "failed to read split chain member's header: %w", err)
|
||||||
|
|
||||||
idMember, ok = res.Header().PreviousID()
|
idMember, ok = res.Header().PreviousID()
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -445,7 +446,7 @@ func collectObjectRelatives(cmd *cobra.Command, cli *client.Client, cnr cid.ID,
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok = chainSet[idMember]; ok {
|
if _, ok = chainSet[idMember]; ok {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("duplicated member in the split chain %s", idMember))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("duplicated member in the split chain %s", idMember))
|
||||||
}
|
}
|
||||||
|
|
||||||
chain = append(chain, idMember)
|
chain = append(chain, idMember)
|
||||||
|
@ -463,7 +464,7 @@ func collectObjectRelatives(cmd *cobra.Command, cli *client.Client, cnr cid.ID,
|
||||||
prmSearch.SetFilters(query)
|
prmSearch.SetFilters(query)
|
||||||
|
|
||||||
resSearch, err := internal.SearchObjects(prmSearch)
|
resSearch, err := internal.SearchObjects(prmSearch)
|
||||||
common.ExitOnErr(cmd, "failed to find object children: %w", err)
|
commonCmd.ExitOnErr(cmd, "failed to find object children: %w", err)
|
||||||
|
|
||||||
list := resSearch.IDList()
|
list := resSearch.IDList()
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import (
|
||||||
sgCli "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/storagegroup"
|
sgCli "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/storagegroup"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/tree"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/tree"
|
||||||
utilCli "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/util"
|
utilCli "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/util"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/misc"
|
"github.com/TrueCloudLab/frostfs-node/misc"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/util/gendoc"
|
"github.com/TrueCloudLab/frostfs-node/pkg/util/gendoc"
|
||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
|
@ -50,7 +51,7 @@ and much more!`,
|
||||||
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
||||||
func Execute() {
|
func Execute() {
|
||||||
err := rootCmd.Execute()
|
err := rootCmd.Execute()
|
||||||
common.ExitOnErr(rootCmd, "", err)
|
commonCmd.ExitOnErr(rootCmd, "", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -105,7 +106,7 @@ func initConfig() {
|
||||||
} else {
|
} else {
|
||||||
// Find home directory.
|
// Find home directory.
|
||||||
home, err := homedir.Dir()
|
home, err := homedir.Dir()
|
||||||
common.ExitOnErr(rootCmd, "", err)
|
commonCmd.ExitOnErr(rootCmd, "", err)
|
||||||
|
|
||||||
// Search config in `$HOME/.config/frostfs-cli/` with name "config.yaml"
|
// Search config in `$HOME/.config/frostfs-cli/` with name "config.yaml"
|
||||||
viper.AddConfigPath(filepath.Join(home, ".config", "frostfs-cli"))
|
viper.AddConfigPath(filepath.Join(home, ".config", "frostfs-cli"))
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/network"
|
"github.com/TrueCloudLab/frostfs-node/pkg/network"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/client"
|
"github.com/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
frostfsecdsa "github.com/TrueCloudLab/frostfs-sdk-go/crypto/ecdsa"
|
frostfsecdsa "github.com/TrueCloudLab/frostfs-sdk-go/crypto/ecdsa"
|
||||||
|
@ -52,10 +52,10 @@ func createSession(cmd *cobra.Command, _ []string) {
|
||||||
|
|
||||||
var netAddr network.Address
|
var netAddr network.Address
|
||||||
addrStr, _ := cmd.Flags().GetString(commonflags.RPC)
|
addrStr, _ := cmd.Flags().GetString(commonflags.RPC)
|
||||||
common.ExitOnErr(cmd, "can't parse endpoint: %w", netAddr.FromString(addrStr))
|
commonCmd.ExitOnErr(cmd, "can't parse endpoint: %w", netAddr.FromString(addrStr))
|
||||||
|
|
||||||
c, err := internalclient.GetSDKClient(cmd, privKey, netAddr)
|
c, err := internalclient.GetSDKClient(cmd, privKey, netAddr)
|
||||||
common.ExitOnErr(cmd, "can't create client: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't create client: %w", err)
|
||||||
|
|
||||||
lifetime := uint64(defaultLifetime)
|
lifetime := uint64(defaultLifetime)
|
||||||
if lfArg, _ := cmd.Flags().GetUint64(commonflags.Lifetime); lfArg != 0 {
|
if lfArg, _ := cmd.Flags().GetUint64(commonflags.Lifetime); lfArg != 0 {
|
||||||
|
@ -65,20 +65,20 @@ func createSession(cmd *cobra.Command, _ []string) {
|
||||||
var tok session.Object
|
var tok session.Object
|
||||||
|
|
||||||
err = CreateSession(&tok, c, lifetime)
|
err = CreateSession(&tok, c, lifetime)
|
||||||
common.ExitOnErr(cmd, "can't create session: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't create session: %w", err)
|
||||||
|
|
||||||
var data []byte
|
var data []byte
|
||||||
|
|
||||||
if toJSON, _ := cmd.Flags().GetBool(jsonFlag); toJSON {
|
if toJSON, _ := cmd.Flags().GetBool(jsonFlag); toJSON {
|
||||||
data, err = tok.MarshalJSON()
|
data, err = tok.MarshalJSON()
|
||||||
common.ExitOnErr(cmd, "can't decode session token JSON: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't decode session token JSON: %w", err)
|
||||||
} else {
|
} else {
|
||||||
data = tok.Marshal()
|
data = tok.Marshal()
|
||||||
}
|
}
|
||||||
|
|
||||||
filename, _ := cmd.Flags().GetString(outFlag)
|
filename, _ := cmd.Flags().GetString(outFlag)
|
||||||
err = os.WriteFile(filename, data, 0644)
|
err = os.WriteFile(filename, data, 0644)
|
||||||
common.ExitOnErr(cmd, "can't write token to file: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't write token to file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateSession opens a new communication with NeoFS storage node using client connection.
|
// CreateSession opens a new communication with NeoFS storage node using client connection.
|
||||||
|
|
|
@ -2,10 +2,10 @@ package storagegroup
|
||||||
|
|
||||||
import (
|
import (
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
objectCli "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/object"
|
objectCli "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/object"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -44,7 +44,7 @@ func delSG(cmd *cobra.Command, _ []string) {
|
||||||
prm.SetAddress(addr)
|
prm.SetAddress(addr)
|
||||||
|
|
||||||
res, err := internalclient.DeleteObject(prm)
|
res, err := internalclient.DeleteObject(prm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
tombstone := res.Tombstone()
|
tombstone := res.Tombstone()
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
objectCli "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/object"
|
objectCli "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/object"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
storagegroupSDK "github.com/TrueCloudLab/frostfs-sdk-go/storagegroup"
|
storagegroupSDK "github.com/TrueCloudLab/frostfs-sdk-go/storagegroup"
|
||||||
|
@ -57,7 +58,7 @@ func getSG(cmd *cobra.Command, _ []string) {
|
||||||
prm.SetPayloadWriter(buf)
|
prm.SetPayloadWriter(buf)
|
||||||
|
|
||||||
res, err := internalclient.GetObject(prm)
|
res, err := internalclient.GetObject(prm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
rawObj := res.Header()
|
rawObj := res.Header()
|
||||||
rawObj.SetPayload(buf.Bytes())
|
rawObj.SetPayload(buf.Bytes())
|
||||||
|
@ -65,7 +66,7 @@ func getSG(cmd *cobra.Command, _ []string) {
|
||||||
var sg storagegroupSDK.StorageGroup
|
var sg storagegroupSDK.StorageGroup
|
||||||
|
|
||||||
err = storagegroupSDK.ReadFromObject(&sg, *rawObj)
|
err = storagegroupSDK.ReadFromObject(&sg, *rawObj)
|
||||||
common.ExitOnErr(cmd, "could not read storage group from the obj: %w", err)
|
commonCmd.ExitOnErr(cmd, "could not read storage group from the obj: %w", err)
|
||||||
|
|
||||||
cmd.Printf("The last active epoch: %d\n", sg.ExpirationEpoch())
|
cmd.Printf("The last active epoch: %d\n", sg.ExpirationEpoch())
|
||||||
cmd.Printf("Group size: %d\n", sg.ValidationDataSize())
|
cmd.Printf("Group size: %d\n", sg.ValidationDataSize())
|
||||||
|
|
|
@ -2,10 +2,10 @@ package storagegroup
|
||||||
|
|
||||||
import (
|
import (
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
objectCli "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/object"
|
objectCli "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/object"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/object_manager/storagegroup"
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/object_manager/storagegroup"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -40,7 +40,7 @@ func listSG(cmd *cobra.Command, _ []string) {
|
||||||
prm.SetFilters(storagegroup.SearchQuery())
|
prm.SetFilters(storagegroup.SearchQuery())
|
||||||
|
|
||||||
res, err := internalclient.SearchObjects(prm)
|
res, err := internalclient.SearchObjects(prm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
ids := res.IDList()
|
ids := res.IDList()
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
objectCli "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/object"
|
objectCli "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/object"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/object_manager/storagegroup"
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/object_manager/storagegroup"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/container"
|
"github.com/TrueCloudLab/frostfs-sdk-go/container"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
|
@ -60,10 +60,10 @@ func putSG(cmd *cobra.Command, _ []string) {
|
||||||
|
|
||||||
for i := range sgMembers {
|
for i := range sgMembers {
|
||||||
err := members[i].DecodeString(sgMembers[i])
|
err := members[i].DecodeString(sgMembers[i])
|
||||||
common.ExitOnErr(cmd, "could not parse object ID: %w", err)
|
commonCmd.ExitOnErr(cmd, "could not parse object ID: %w", err)
|
||||||
|
|
||||||
if _, alreadyExists := uniqueFilter[members[i]]; alreadyExists {
|
if _, alreadyExists := uniqueFilter[members[i]]; alreadyExists {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("%s member in not unique", members[i]))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("%s member in not unique", members[i]))
|
||||||
}
|
}
|
||||||
|
|
||||||
uniqueFilter[members[i]] = struct{}{}
|
uniqueFilter[members[i]] = struct{}{}
|
||||||
|
@ -80,7 +80,7 @@ func putSG(cmd *cobra.Command, _ []string) {
|
||||||
getCnrPrm.SetContainer(cnr)
|
getCnrPrm.SetContainer(cnr)
|
||||||
|
|
||||||
resGetCnr, err := internalclient.GetContainer(getCnrPrm)
|
resGetCnr, err := internalclient.GetContainer(getCnrPrm)
|
||||||
common.ExitOnErr(cmd, "get container RPC call: %w", err)
|
commonCmd.ExitOnErr(cmd, "get container RPC call: %w", err)
|
||||||
|
|
||||||
objectCli.OpenSessionViaClient(cmd, &putPrm, cli, pk, cnr, nil)
|
objectCli.OpenSessionViaClient(cmd, &putPrm, cli, pk, cnr, nil)
|
||||||
objectCli.Prepare(cmd, &headPrm, &putPrm)
|
objectCli.Prepare(cmd, &headPrm, &putPrm)
|
||||||
|
@ -94,13 +94,13 @@ func putSG(cmd *cobra.Command, _ []string) {
|
||||||
ownerID: &ownerID,
|
ownerID: &ownerID,
|
||||||
prm: headPrm,
|
prm: headPrm,
|
||||||
}, cnr, members, !container.IsHomomorphicHashingDisabled(resGetCnr.Container()))
|
}, cnr, members, !container.IsHomomorphicHashingDisabled(resGetCnr.Container()))
|
||||||
common.ExitOnErr(cmd, "could not collect storage group members: %w", err)
|
commonCmd.ExitOnErr(cmd, "could not collect storage group members: %w", err)
|
||||||
|
|
||||||
var netInfoPrm internalclient.NetworkInfoPrm
|
var netInfoPrm internalclient.NetworkInfoPrm
|
||||||
netInfoPrm.SetClient(cli)
|
netInfoPrm.SetClient(cli)
|
||||||
|
|
||||||
ni, err := internalclient.NetworkInfo(netInfoPrm)
|
ni, err := internalclient.NetworkInfo(netInfoPrm)
|
||||||
common.ExitOnErr(cmd, "can't fetch network info: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't fetch network info: %w", err)
|
||||||
|
|
||||||
lifetime, _ := cmd.Flags().GetUint64(commonflags.Lifetime)
|
lifetime, _ := cmd.Flags().GetUint64(commonflags.Lifetime)
|
||||||
sg.SetExpirationEpoch(ni.NetworkInfo().CurrentEpoch() + lifetime)
|
sg.SetExpirationEpoch(ni.NetworkInfo().CurrentEpoch() + lifetime)
|
||||||
|
@ -114,7 +114,7 @@ func putSG(cmd *cobra.Command, _ []string) {
|
||||||
putPrm.SetHeader(obj)
|
putPrm.SetHeader(obj)
|
||||||
|
|
||||||
res, err := internalclient.PutObject(putPrm)
|
res, err := internalclient.PutObject(putPrm)
|
||||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
cmd.Println("Storage group successfully stored")
|
cmd.Println("Storage group successfully stored")
|
||||||
cmd.Printf(" ID: %s\n CID: %s\n", res.ID(), cnr)
|
cmd.Printf(" ID: %s\n CID: %s\n", res.ID(), cnr)
|
||||||
|
|
|
@ -3,8 +3,8 @@ package storagegroup
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -23,12 +23,12 @@ func readObjectAddress(cmd *cobra.Command, cnr *cid.ID, obj *oid.ID) oid.Address
|
||||||
func readCID(cmd *cobra.Command, id *cid.ID) {
|
func readCID(cmd *cobra.Command, id *cid.ID) {
|
||||||
f := cmd.Flag(commonflags.CIDFlag)
|
f := cmd.Flag(commonflags.CIDFlag)
|
||||||
if f == nil {
|
if f == nil {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("missing container flag (%s)", commonflags.CIDFlag))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("missing container flag (%s)", commonflags.CIDFlag))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := id.DecodeString(f.Value.String())
|
err := id.DecodeString(f.Value.String())
|
||||||
common.ExitOnErr(cmd, "decode container ID string: %w", err)
|
commonCmd.ExitOnErr(cmd, "decode container ID string: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func readSGID(cmd *cobra.Command, id *oid.ID) {
|
func readSGID(cmd *cobra.Command, id *oid.ID) {
|
||||||
|
@ -36,10 +36,10 @@ func readSGID(cmd *cobra.Command, id *oid.ID) {
|
||||||
|
|
||||||
f := cmd.Flag(flag)
|
f := cmd.Flag(flag)
|
||||||
if f == nil {
|
if f == nil {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("missing storage group flag (%s)", flag))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("missing storage group flag (%s)", flag))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := id.DecodeString(f.Value.String())
|
err := id.DecodeString(f.Value.String())
|
||||||
common.ExitOnErr(cmd, "decode storage group ID string: %w", err)
|
commonCmd.ExitOnErr(cmd, "decode storage group ID string: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/tree"
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/tree"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -38,18 +38,18 @@ func add(cmd *cobra.Command, _ []string) {
|
||||||
|
|
||||||
var cnr cid.ID
|
var cnr cid.ID
|
||||||
err := cnr.DecodeString(cmd.Flag(commonflags.CIDFlag).Value.String())
|
err := cnr.DecodeString(cmd.Flag(commonflags.CIDFlag).Value.String())
|
||||||
common.ExitOnErr(cmd, "decode container ID string: %w", err)
|
commonCmd.ExitOnErr(cmd, "decode container ID string: %w", err)
|
||||||
|
|
||||||
tid, _ := cmd.Flags().GetString(treeIDFlagKey)
|
tid, _ := cmd.Flags().GetString(treeIDFlagKey)
|
||||||
pid, _ := cmd.Flags().GetUint64(parentIDFlagKey)
|
pid, _ := cmd.Flags().GetUint64(parentIDFlagKey)
|
||||||
|
|
||||||
meta, err := parseMeta(cmd)
|
meta, err := parseMeta(cmd)
|
||||||
common.ExitOnErr(cmd, "meta data parsing: %w", err)
|
commonCmd.ExitOnErr(cmd, "meta data parsing: %w", err)
|
||||||
|
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
|
|
||||||
cli, err := _client(ctx)
|
cli, err := _client(ctx)
|
||||||
common.ExitOnErr(cmd, "client: %w", err)
|
commonCmd.ExitOnErr(cmd, "client: %w", err)
|
||||||
|
|
||||||
rawCID := make([]byte, sha256.Size)
|
rawCID := make([]byte, sha256.Size)
|
||||||
cnr.Encode(rawCID)
|
cnr.Encode(rawCID)
|
||||||
|
@ -63,10 +63,10 @@ func add(cmd *cobra.Command, _ []string) {
|
||||||
BearerToken: nil, // TODO: #1891 add token handling
|
BearerToken: nil, // TODO: #1891 add token handling
|
||||||
}
|
}
|
||||||
|
|
||||||
common.ExitOnErr(cmd, "message signing: %w", tree.SignMessage(req, pk))
|
commonCmd.ExitOnErr(cmd, "message signing: %w", tree.SignMessage(req, pk))
|
||||||
|
|
||||||
resp, err := cli.Add(ctx, req)
|
resp, err := cli.Add(ctx, req)
|
||||||
common.ExitOnErr(cmd, "rpc call: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc call: %w", err)
|
||||||
|
|
||||||
cmd.Println("Node ID: ", resp.Body.NodeId)
|
cmd.Println("Node ID: ", resp.Body.NodeId)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/tree"
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/tree"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
|
@ -46,19 +47,19 @@ func addByPath(cmd *cobra.Command, _ []string) {
|
||||||
|
|
||||||
var cnr cid.ID
|
var cnr cid.ID
|
||||||
err := cnr.DecodeString(cidRaw)
|
err := cnr.DecodeString(cidRaw)
|
||||||
common.ExitOnErr(cmd, "decode container ID string: %w", err)
|
commonCmd.ExitOnErr(cmd, "decode container ID string: %w", err)
|
||||||
|
|
||||||
tid, _ := cmd.Flags().GetString(treeIDFlagKey)
|
tid, _ := cmd.Flags().GetString(treeIDFlagKey)
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
|
|
||||||
cli, err := _client(ctx)
|
cli, err := _client(ctx)
|
||||||
common.ExitOnErr(cmd, "client: %w", err)
|
commonCmd.ExitOnErr(cmd, "client: %w", err)
|
||||||
|
|
||||||
rawCID := make([]byte, sha256.Size)
|
rawCID := make([]byte, sha256.Size)
|
||||||
cnr.Encode(rawCID)
|
cnr.Encode(rawCID)
|
||||||
|
|
||||||
meta, err := parseMeta(cmd)
|
meta, err := parseMeta(cmd)
|
||||||
common.ExitOnErr(cmd, "meta data parsing: %w", err)
|
commonCmd.ExitOnErr(cmd, "meta data parsing: %w", err)
|
||||||
|
|
||||||
path, _ := cmd.Flags().GetString(pathFlagKey)
|
path, _ := cmd.Flags().GetString(pathFlagKey)
|
||||||
//pAttr, _ := cmd.Flags().GetString(pathAttributeFlagKey)
|
//pAttr, _ := cmd.Flags().GetString(pathAttributeFlagKey)
|
||||||
|
@ -74,10 +75,10 @@ func addByPath(cmd *cobra.Command, _ []string) {
|
||||||
BearerToken: nil, // TODO: #1891 add token handling
|
BearerToken: nil, // TODO: #1891 add token handling
|
||||||
}
|
}
|
||||||
|
|
||||||
common.ExitOnErr(cmd, "message signing: %w", tree.SignMessage(req, pk))
|
commonCmd.ExitOnErr(cmd, "message signing: %w", tree.SignMessage(req, pk))
|
||||||
|
|
||||||
resp, err := cli.AddByPath(ctx, req)
|
resp, err := cli.AddByPath(ctx, req)
|
||||||
common.ExitOnErr(cmd, "rpc call: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc call: %w", err)
|
||||||
|
|
||||||
cmd.Printf("Parent ID: %d\n", resp.GetBody().GetParentId())
|
cmd.Printf("Parent ID: %d\n", resp.GetBody().GetParentId())
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/tree"
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/tree"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
|
@ -46,13 +47,13 @@ func getByPath(cmd *cobra.Command, _ []string) {
|
||||||
|
|
||||||
var cnr cid.ID
|
var cnr cid.ID
|
||||||
err := cnr.DecodeString(cidRaw)
|
err := cnr.DecodeString(cidRaw)
|
||||||
common.ExitOnErr(cmd, "decode container ID string: %w", err)
|
commonCmd.ExitOnErr(cmd, "decode container ID string: %w", err)
|
||||||
|
|
||||||
tid, _ := cmd.Flags().GetString(treeIDFlagKey)
|
tid, _ := cmd.Flags().GetString(treeIDFlagKey)
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
|
|
||||||
cli, err := _client(ctx)
|
cli, err := _client(ctx)
|
||||||
common.ExitOnErr(cmd, "client: %w", err)
|
commonCmd.ExitOnErr(cmd, "client: %w", err)
|
||||||
|
|
||||||
rawCID := make([]byte, sha256.Size)
|
rawCID := make([]byte, sha256.Size)
|
||||||
cnr.Encode(rawCID)
|
cnr.Encode(rawCID)
|
||||||
|
@ -73,10 +74,10 @@ func getByPath(cmd *cobra.Command, _ []string) {
|
||||||
BearerToken: nil, // TODO: #1891 add token handling
|
BearerToken: nil, // TODO: #1891 add token handling
|
||||||
}
|
}
|
||||||
|
|
||||||
common.ExitOnErr(cmd, "message signing: %w", tree.SignMessage(req, pk))
|
commonCmd.ExitOnErr(cmd, "message signing: %w", tree.SignMessage(req, pk))
|
||||||
|
|
||||||
resp, err := cli.GetNodeByPath(ctx, req)
|
resp, err := cli.GetNodeByPath(ctx, req)
|
||||||
common.ExitOnErr(cmd, "rpc call: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc call: %w", err)
|
||||||
|
|
||||||
nn := resp.GetBody().GetNodes()
|
nn := resp.GetBody().GetNodes()
|
||||||
if len(nn) == 0 {
|
if len(nn) == 0 {
|
||||||
|
|
|
@ -3,9 +3,9 @@ package tree
|
||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/tree"
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/tree"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -36,12 +36,12 @@ func list(cmd *cobra.Command, _ []string) {
|
||||||
|
|
||||||
var cnr cid.ID
|
var cnr cid.ID
|
||||||
err := cnr.DecodeString(cidString)
|
err := cnr.DecodeString(cidString)
|
||||||
common.ExitOnErr(cmd, "decode container ID string: %w", err)
|
commonCmd.ExitOnErr(cmd, "decode container ID string: %w", err)
|
||||||
|
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
|
|
||||||
cli, err := _client(ctx)
|
cli, err := _client(ctx)
|
||||||
common.ExitOnErr(cmd, "client: %w", err)
|
commonCmd.ExitOnErr(cmd, "client: %w", err)
|
||||||
|
|
||||||
rawCID := make([]byte, sha256.Size)
|
rawCID := make([]byte, sha256.Size)
|
||||||
cnr.Encode(rawCID)
|
cnr.Encode(rawCID)
|
||||||
|
@ -52,10 +52,10 @@ func list(cmd *cobra.Command, _ []string) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
common.ExitOnErr(cmd, "message signing: %w", tree.SignMessage(req, pk))
|
commonCmd.ExitOnErr(cmd, "message signing: %w", tree.SignMessage(req, pk))
|
||||||
|
|
||||||
resp, err := cli.TreeList(ctx, req)
|
resp, err := cli.TreeList(ctx, req)
|
||||||
common.ExitOnErr(cmd, "rpc call: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc call: %w", err)
|
||||||
|
|
||||||
for _, treeID := range resp.GetBody().GetIds() {
|
for _, treeID := range resp.GetBody().GetIds() {
|
||||||
cmd.Println(treeID)
|
cmd.Println(treeID)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -36,10 +37,10 @@ func convertEACLTable(cmd *cobra.Command, _ []string) {
|
||||||
var err error
|
var err error
|
||||||
if jsonFlag || len(to) == 0 {
|
if jsonFlag || len(to) == 0 {
|
||||||
data, err = table.MarshalJSON()
|
data, err = table.MarshalJSON()
|
||||||
common.ExitOnErr(cmd, "can't JSON encode extended ACL table: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't JSON encode extended ACL table: %w", err)
|
||||||
} else {
|
} else {
|
||||||
data, err = table.Marshal()
|
data, err = table.Marshal()
|
||||||
common.ExitOnErr(cmd, "can't binary encode extended ACL table: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't binary encode extended ACL table: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(to) == 0 {
|
if len(to) == 0 {
|
||||||
|
@ -48,7 +49,7 @@ func convertEACLTable(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.WriteFile(to, data, 0644)
|
err = os.WriteFile(to, data, 0644)
|
||||||
common.ExitOnErr(cmd, "can't write exteded ACL table to file: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't write exteded ACL table to file: %w", err)
|
||||||
|
|
||||||
cmd.Printf("extended ACL table was successfully dumped to %s\n", to)
|
cmd.Printf("extended ACL table was successfully dumped to %s\n", to)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/util/keyer"
|
"github.com/TrueCloudLab/frostfs-node/pkg/util/keyer"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -41,7 +41,7 @@ func processKeyer(cmd *cobra.Command, args []string) {
|
||||||
err = result.ParseMultiSig(args)
|
err = result.ParseMultiSig(args)
|
||||||
} else {
|
} else {
|
||||||
if len(args) > 1 {
|
if len(args) > 1 {
|
||||||
common.ExitOnErr(cmd, "", errKeyerSingleArgument)
|
commonCmd.ExitOnErr(cmd, "", errKeyerSingleArgument)
|
||||||
}
|
}
|
||||||
|
|
||||||
var argument string
|
var argument string
|
||||||
|
@ -59,7 +59,7 @@ func processKeyer(cmd *cobra.Command, args []string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common.ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
|
|
||||||
result.PrettyPrint(uncompressed, useHex)
|
result.PrettyPrint(uncompressed, useHex)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
locodedb "github.com/TrueCloudLab/frostfs-node/pkg/util/locode/db"
|
locodedb "github.com/TrueCloudLab/frostfs-node/pkg/util/locode/db"
|
||||||
airportsdb "github.com/TrueCloudLab/frostfs-node/pkg/util/locode/db/airports"
|
airportsdb "github.com/TrueCloudLab/frostfs-node/pkg/util/locode/db/airports"
|
||||||
locodebolt "github.com/TrueCloudLab/frostfs-node/pkg/util/locode/db/boltdb"
|
locodebolt "github.com/TrueCloudLab/frostfs-node/pkg/util/locode/db/boltdb"
|
||||||
|
@ -58,7 +58,7 @@ var (
|
||||||
})
|
})
|
||||||
|
|
||||||
err := targetDB.Open()
|
err := targetDB.Open()
|
||||||
common.ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
|
|
||||||
defer targetDB.Close()
|
defer targetDB.Close()
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ var (
|
||||||
}
|
}
|
||||||
|
|
||||||
err = locodedb.FillDatabase(locodeDB, airportDB, continentsDB, names, targetDB)
|
err = locodedb.FillDatabase(locodeDB, airportDB, continentsDB, names, targetDB)
|
||||||
common.ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
locodedb "github.com/TrueCloudLab/frostfs-node/pkg/util/locode/db"
|
locodedb "github.com/TrueCloudLab/frostfs-node/pkg/util/locode/db"
|
||||||
locodebolt "github.com/TrueCloudLab/frostfs-node/pkg/util/locode/db/boltdb"
|
locodebolt "github.com/TrueCloudLab/frostfs-node/pkg/util/locode/db/boltdb"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -25,12 +25,12 @@ var (
|
||||||
}, locodebolt.ReadOnly())
|
}, locodebolt.ReadOnly())
|
||||||
|
|
||||||
err := targetDB.Open()
|
err := targetDB.Open()
|
||||||
common.ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
|
|
||||||
defer targetDB.Close()
|
defer targetDB.Close()
|
||||||
|
|
||||||
record, err := locodedb.LocodeRecord(targetDB, locodeInfoCode)
|
record, err := locodedb.LocodeRecord(targetDB, locodeInfoCode)
|
||||||
common.ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
|
|
||||||
cmd.Printf("Country: %s\n", record.CountryName())
|
cmd.Printf("Country: %s\n", record.CountryName())
|
||||||
cmd.Printf("Location: %s\n", record.LocationName())
|
cmd.Printf("Location: %s\n", record.LocationName())
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ func signBearerToken(cmd *cobra.Command, _ []string) {
|
||||||
pk := key.GetOrGenerate(cmd)
|
pk := key.GetOrGenerate(cmd)
|
||||||
|
|
||||||
err := btok.Sign(*pk)
|
err := btok.Sign(*pk)
|
||||||
common.ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
|
|
||||||
to := cmd.Flag(signToFlag).Value.String()
|
to := cmd.Flag(signToFlag).Value.String()
|
||||||
jsonFlag, _ := cmd.Flags().GetBool(signBearerJSONFlag)
|
jsonFlag, _ := cmd.Flags().GetBool(signBearerJSONFlag)
|
||||||
|
@ -45,7 +46,7 @@ func signBearerToken(cmd *cobra.Command, _ []string) {
|
||||||
var data []byte
|
var data []byte
|
||||||
if jsonFlag || len(to) == 0 {
|
if jsonFlag || len(to) == 0 {
|
||||||
data, err = btok.MarshalJSON()
|
data, err = btok.MarshalJSON()
|
||||||
common.ExitOnErr(cmd, "can't JSON encode bearer token: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't JSON encode bearer token: %w", err)
|
||||||
} else {
|
} else {
|
||||||
data = btok.Marshal()
|
data = btok.Marshal()
|
||||||
}
|
}
|
||||||
|
@ -56,7 +57,7 @@ func signBearerToken(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.WriteFile(to, data, 0644)
|
err = os.WriteFile(to, data, 0644)
|
||||||
common.ExitOnErr(cmd, "can't write signed bearer token to file: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't write signed bearer token to file: %w", err)
|
||||||
|
|
||||||
cmd.Printf("signed bearer token was successfully dumped to %s\n", to)
|
cmd.Printf("signed bearer token was successfully dumped to %s\n", to)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/session"
|
"github.com/TrueCloudLab/frostfs-sdk-go/session"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -34,10 +35,10 @@ func initSignSessionCmd() {
|
||||||
|
|
||||||
func signSessionToken(cmd *cobra.Command, _ []string) {
|
func signSessionToken(cmd *cobra.Command, _ []string) {
|
||||||
fPath, err := cmd.Flags().GetString(signFromFlag)
|
fPath, err := cmd.Flags().GetString(signFromFlag)
|
||||||
common.ExitOnErr(cmd, "", err)
|
commonCmd.ExitOnErr(cmd, "", err)
|
||||||
|
|
||||||
if fPath == "" {
|
if fPath == "" {
|
||||||
common.ExitOnErr(cmd, "", errors.New("missing session token flag"))
|
commonCmd.ExitOnErr(cmd, "", errors.New("missing session token flag"))
|
||||||
}
|
}
|
||||||
|
|
||||||
type iTokenSession interface {
|
type iTokenSession interface {
|
||||||
|
@ -59,15 +60,15 @@ func signSessionToken(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common.ExitOnErr(cmd, "decode session: %v", errLast)
|
commonCmd.ExitOnErr(cmd, "decode session: %v", errLast)
|
||||||
|
|
||||||
pk := key.GetOrGenerate(cmd)
|
pk := key.GetOrGenerate(cmd)
|
||||||
|
|
||||||
err = stok.Sign(*pk)
|
err = stok.Sign(*pk)
|
||||||
common.ExitOnErr(cmd, "can't sign token: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't sign token: %w", err)
|
||||||
|
|
||||||
data, err := stok.MarshalJSON()
|
data, err := stok.MarshalJSON()
|
||||||
common.ExitOnErr(cmd, "can't encode session token: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't encode session token: %w", err)
|
||||||
|
|
||||||
to := cmd.Flag(signToFlag).Value.String()
|
to := cmd.Flag(signToFlag).Value.String()
|
||||||
if len(to) == 0 {
|
if len(to) == 0 {
|
||||||
|
@ -77,7 +78,7 @@ func signSessionToken(cmd *cobra.Command, _ []string) {
|
||||||
|
|
||||||
err = os.WriteFile(to, data, 0644)
|
err = os.WriteFile(to, data, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.ExitOnErr(cmd, "", fmt.Errorf("can't write signed session token to %s: %w", to, err))
|
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("can't write signed session token to %s: %w", to, err))
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Printf("signed session token saved in %s\n", to)
|
cmd.Printf("signed session token saved in %s\n", to)
|
||||||
|
|
|
@ -39,11 +39,11 @@ func PrettyPrintNodeInfo(cmd *cobra.Command, node netmap.NodeInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrettyPrintNetMap print information about network map.
|
// PrettyPrintNetMap print information about network map.
|
||||||
func PrettyPrintNetMap(cmd *cobra.Command, nm netmap.NetMap) {
|
func PrettyPrintNetMap(cmd *cobra.Command, nm netmap.NetMap, short bool) {
|
||||||
cmd.Println("Epoch:", nm.Epoch())
|
cmd.Println("Epoch:", nm.Epoch())
|
||||||
|
|
||||||
nodes := nm.Nodes()
|
nodes := nm.Nodes()
|
||||||
for i := range nodes {
|
for i := range nodes {
|
||||||
PrettyPrintNodeInfo(cmd, nodes[i], i, "", false)
|
PrettyPrintNodeInfo(cmd, nodes[i], i, "", short)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue