forked from TrueCloudLab/frostfs-node
[#104] Update neofs-api-go with new protobuf API
Also update contains JSON converters for neofs-cli and fixes bug in container.set-acl command of SDK. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
9e08b41a6f
commit
e6f04f7785
7 changed files with 19 additions and 11 deletions
|
@ -22,6 +22,7 @@ import (
|
|||
grpccontainer "github.com/nspcc-dev/neofs-api-go/v2/container/grpc"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/policy"
|
||||
"github.com/spf13/cobra"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -265,7 +266,7 @@ var getContainerInfoCmd = &cobra.Command{
|
|||
|
||||
// todo: make more user friendly way to parse raw data
|
||||
msg := new(grpccontainer.Container)
|
||||
if msg.Unmarshal(data) != nil {
|
||||
if proto.Unmarshal(data, msg) != nil {
|
||||
return errors.New("can't unmarshal container")
|
||||
}
|
||||
|
||||
|
|
5
go.mod
5
go.mod
|
@ -5,7 +5,7 @@ go 1.14
|
|||
require (
|
||||
bou.ke/monkey v1.0.2
|
||||
github.com/alecthomas/participle v0.6.0
|
||||
github.com/golang/protobuf v1.4.2
|
||||
github.com/golang/protobuf v1.4.3
|
||||
github.com/google/uuid v1.1.1
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/mr-tron/base58 v1.1.3
|
||||
|
@ -13,7 +13,7 @@ require (
|
|||
github.com/multiformats/go-multiaddr-net v0.1.2 // v0.1.1 => v0.1.2
|
||||
github.com/multiformats/go-multihash v0.0.13 // indirect
|
||||
github.com/nspcc-dev/neo-go v0.91.1-pre.0.20200827184617-7560aa345a78
|
||||
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20201015080537-4e6350f6d438
|
||||
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20201020123541-2aa40b0dd3a5
|
||||
github.com/nspcc-dev/neofs-crypto v0.3.0
|
||||
github.com/nspcc-dev/tzhash v1.4.0
|
||||
github.com/panjf2000/ants/v2 v2.3.0
|
||||
|
@ -33,6 +33,7 @@ require (
|
|||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect
|
||||
golang.org/x/tools v0.0.0-20200123022218-593de606220b // indirect
|
||||
google.golang.org/grpc v1.29.1
|
||||
google.golang.org/protobuf v1.23.0
|
||||
)
|
||||
|
||||
// Used for debug reasons
|
||||
|
|
10
go.sum
10
go.sum
|
@ -130,8 +130,8 @@ github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:x
|
|||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
|
||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
|
@ -270,8 +270,10 @@ github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:
|
|||
github.com/nspcc-dev/neo-go v0.91.0/go.mod h1:G6HdOWvzQ6tlvFdvFSN/PgCzLPN/X/X4d5hTjFRUDcc=
|
||||
github.com/nspcc-dev/neo-go v0.91.1-pre.0.20200827184617-7560aa345a78 h1:stIa+nBXK8uDY/JZaxIZzAUfkzfaotVw2FbnHxO4aZI=
|
||||
github.com/nspcc-dev/neo-go v0.91.1-pre.0.20200827184617-7560aa345a78/go.mod h1:G6HdOWvzQ6tlvFdvFSN/PgCzLPN/X/X4d5hTjFRUDcc=
|
||||
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20201015080537-4e6350f6d438 h1:Rw3h9BnYzGiDtZX7YPb/7NCFtykE+PqTX7mRL9pqNv0=
|
||||
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20201015080537-4e6350f6d438/go.mod h1:FsFd1z4YzoEgPlltsUgnqna9qhcF87RHYjot0pby2L4=
|
||||
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20201020104514-e6035a324901 h1:cqwg8QItXzVkvbR7hkxdqWARTY3Y5nRjQPLk3CZ8H78=
|
||||
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20201020104514-e6035a324901/go.mod h1:G7dqincfdjBrAbL5nxVp82emF05fSVEqe59ICsoRDI8=
|
||||
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20201020123541-2aa40b0dd3a5 h1:6ZsBrLnG0BASIDZ+/mv1Q/Ht6wANCcKlbNpboE7K+yc=
|
||||
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20201020123541-2aa40b0dd3a5/go.mod h1:G7dqincfdjBrAbL5nxVp82emF05fSVEqe59ICsoRDI8=
|
||||
github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA=
|
||||
github.com/nspcc-dev/neofs-crypto v0.2.3/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw=
|
||||
github.com/nspcc-dev/neofs-crypto v0.3.0 h1:zlr3pgoxuzrmGCxc5W8dGVfA9Rro8diFvVnBg0L4ifM=
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/pkg/innerring/invoke"
|
||||
netmapEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap"
|
||||
"go.uber.org/zap"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// Process add peer notification by sanity check of new node
|
||||
|
@ -20,7 +21,7 @@ func (np *Processor) processAddPeer(node []byte) {
|
|||
// unmarshal grpc (any transport) version of node info from API v2
|
||||
nodeInfo := new(netmap.NodeInfo)
|
||||
|
||||
err := nodeInfo.Unmarshal(node)
|
||||
err := proto.Unmarshal(node, nodeInfo)
|
||||
if err != nil {
|
||||
// it will be nice to have tx id at event structure to log it
|
||||
np.log.Warn("can't parse network map candidate")
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
core "github.com/nspcc-dev/neofs-node/pkg/core/container"
|
||||
client "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -82,7 +83,7 @@ func (w *Wrapper) Get(cid *container.ID) (*container.Container, error) {
|
|||
|
||||
// convert serialized bytes into GRPC structure
|
||||
grpcMsg := new(msgContainer.Container)
|
||||
err = grpcMsg.Unmarshal(rpcAnswer.Container())
|
||||
err = proto.Unmarshal(rpcAnswer.Container(), grpcMsg)
|
||||
if err != nil {
|
||||
// use other major version if there any
|
||||
return nil, errors.Wrap(err, "can't unmarshal container")
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
msgACL "github.com/nspcc-dev/neofs-api-go/v2/acl/grpc"
|
||||
client "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// GetEACL reads the extended ACL table from NeoFS system
|
||||
|
@ -30,7 +31,7 @@ func (w *Wrapper) GetEACL(cid *container.ID) (*eacl.Table, []byte, error) {
|
|||
}
|
||||
|
||||
grpcMsg := new(msgACL.EACLTable)
|
||||
err = grpcMsg.Unmarshal(rpcAnswer.EACL())
|
||||
err = proto.Unmarshal(rpcAnswer.EACL(), grpcMsg)
|
||||
if err != nil {
|
||||
// use other major version if there any
|
||||
return nil, nil, err
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
grpcNetmap "github.com/nspcc-dev/neofs-api-go/v2/netmap/grpc"
|
||||
client "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// GetNetMap receives information list about storage nodes
|
||||
|
@ -26,7 +27,7 @@ func (w Wrapper) GetNetMap(diff uint64) (*netmap.Netmap, error) {
|
|||
|
||||
for _, peer := range rawPeers {
|
||||
grpcNodeInfo := new(grpcNetmap.NodeInfo) // transport representation of struct
|
||||
err = grpcNodeInfo.Unmarshal(peer)
|
||||
err = proto.Unmarshal(peer, grpcNodeInfo)
|
||||
if err != nil {
|
||||
// consider unmarshalling into different major versions
|
||||
// of NodeInfo structure, if there any
|
||||
|
|
Loading…
Reference in a new issue