forked from TrueCloudLab/frostfs-node
[#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
|
@ -5,9 +5,9 @@ import (
|
|||
"fmt"
|
||||
"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/key"
|
||||
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/tree"
|
||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -38,18 +38,18 @@ func add(cmd *cobra.Command, _ []string) {
|
|||
|
||||
var cnr cid.ID
|
||||
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)
|
||||
pid, _ := cmd.Flags().GetUint64(parentIDFlagKey)
|
||||
|
||||
meta, err := parseMeta(cmd)
|
||||
common.ExitOnErr(cmd, "meta data parsing: %w", err)
|
||||
commonCmd.ExitOnErr(cmd, "meta data parsing: %w", err)
|
||||
|
||||
ctx := cmd.Context()
|
||||
|
||||
cli, err := _client(ctx)
|
||||
common.ExitOnErr(cmd, "client: %w", err)
|
||||
commonCmd.ExitOnErr(cmd, "client: %w", err)
|
||||
|
||||
rawCID := make([]byte, sha256.Size)
|
||||
cnr.Encode(rawCID)
|
||||
|
@ -63,10 +63,10 @@ func add(cmd *cobra.Command, _ []string) {
|
|||
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)
|
||||
common.ExitOnErr(cmd, "rpc call: %w", err)
|
||||
commonCmd.ExitOnErr(cmd, "rpc call: %w", err)
|
||||
|
||||
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/commonflags"
|
||||
"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"
|
||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
||||
|
@ -46,19 +47,19 @@ func addByPath(cmd *cobra.Command, _ []string) {
|
|||
|
||||
var cnr cid.ID
|
||||
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)
|
||||
ctx := cmd.Context()
|
||||
|
||||
cli, err := _client(ctx)
|
||||
common.ExitOnErr(cmd, "client: %w", err)
|
||||
commonCmd.ExitOnErr(cmd, "client: %w", err)
|
||||
|
||||
rawCID := make([]byte, sha256.Size)
|
||||
cnr.Encode(rawCID)
|
||||
|
||||
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)
|
||||
//pAttr, _ := cmd.Flags().GetString(pathAttributeFlagKey)
|
||||
|
@ -74,10 +75,10 @@ func addByPath(cmd *cobra.Command, _ []string) {
|
|||
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)
|
||||
common.ExitOnErr(cmd, "rpc call: %w", err)
|
||||
commonCmd.ExitOnErr(cmd, "rpc call: %w", err)
|
||||
|
||||
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/commonflags"
|
||||
"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"
|
||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
||||
|
@ -46,13 +47,13 @@ func getByPath(cmd *cobra.Command, _ []string) {
|
|||
|
||||
var cnr cid.ID
|
||||
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)
|
||||
ctx := cmd.Context()
|
||||
|
||||
cli, err := _client(ctx)
|
||||
common.ExitOnErr(cmd, "client: %w", err)
|
||||
commonCmd.ExitOnErr(cmd, "client: %w", err)
|
||||
|
||||
rawCID := make([]byte, sha256.Size)
|
||||
cnr.Encode(rawCID)
|
||||
|
@ -73,10 +74,10 @@ func getByPath(cmd *cobra.Command, _ []string) {
|
|||
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)
|
||||
common.ExitOnErr(cmd, "rpc call: %w", err)
|
||||
commonCmd.ExitOnErr(cmd, "rpc call: %w", err)
|
||||
|
||||
nn := resp.GetBody().GetNodes()
|
||||
if len(nn) == 0 {
|
||||
|
|
|
@ -3,9 +3,9 @@ package tree
|
|||
import (
|
||||
"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/key"
|
||||
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/tree"
|
||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -36,12 +36,12 @@ func list(cmd *cobra.Command, _ []string) {
|
|||
|
||||
var cnr cid.ID
|
||||
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()
|
||||
|
||||
cli, err := _client(ctx)
|
||||
common.ExitOnErr(cmd, "client: %w", err)
|
||||
commonCmd.ExitOnErr(cmd, "client: %w", err)
|
||||
|
||||
rawCID := make([]byte, sha256.Size)
|
||||
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)
|
||||
common.ExitOnErr(cmd, "rpc call: %w", err)
|
||||
commonCmd.ExitOnErr(cmd, "rpc call: %w", err)
|
||||
|
||||
for _, treeID := range resp.GetBody().GetIds() {
|
||||
cmd.Println(treeID)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue