2022-06-02 12:07:30 +00:00
|
|
|
package storagegroup
|
|
|
|
|
|
|
|
import (
|
2022-06-16 21:40:21 +00:00
|
|
|
"fmt"
|
|
|
|
|
2022-06-02 12:07:30 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common"
|
|
|
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
|
|
|
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func readObjectAddress(cmd *cobra.Command, cnr *cid.ID, obj *oid.ID) oid.Address {
|
|
|
|
readCID(cmd, cnr)
|
|
|
|
readSGID(cmd, obj)
|
|
|
|
|
|
|
|
var addr oid.Address
|
|
|
|
addr.SetContainer(*cnr)
|
|
|
|
addr.SetObject(*obj)
|
|
|
|
return addr
|
|
|
|
}
|
|
|
|
|
|
|
|
func readCID(cmd *cobra.Command, id *cid.ID) {
|
2022-06-16 21:40:21 +00:00
|
|
|
const flag = "cid"
|
|
|
|
|
|
|
|
f := cmd.Flag(flag)
|
|
|
|
if f == nil {
|
|
|
|
common.ExitOnErr(cmd, "", fmt.Errorf("missing container flag (%s)", flag))
|
2022-06-17 09:05:00 +00:00
|
|
|
return
|
2022-06-16 21:40:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err := id.DecodeString(f.Value.String())
|
2022-06-02 12:07:30 +00:00
|
|
|
common.ExitOnErr(cmd, "decode container ID string: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func readSGID(cmd *cobra.Command, id *oid.ID) {
|
2022-06-16 21:40:21 +00:00
|
|
|
const flag = "id"
|
|
|
|
|
|
|
|
f := cmd.Flag(flag)
|
|
|
|
if f == nil {
|
|
|
|
common.ExitOnErr(cmd, "", fmt.Errorf("missing storage group flag (%s)", flag))
|
2022-06-17 09:05:00 +00:00
|
|
|
return
|
2022-06-16 21:40:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err := id.DecodeString(f.Value.String())
|
2022-06-02 12:07:30 +00:00
|
|
|
common.ExitOnErr(cmd, "decode storage group ID string: %w", err)
|
|
|
|
}
|