Skip to content

Commit

Permalink
go.mod: Upgrade to latest github.com/nspcc-dev/neofs-sdk-go (#2489)
Browse files Browse the repository at this point in the history
Upgrade to RC11
  • Loading branch information
roman-khimov authored Sep 8, 2023
2 parents 875cd54 + 9c35320 commit 9bdb06c
Show file tree
Hide file tree
Showing 50 changed files with 277 additions and 388 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ minor release, the component will be purged, so be prepared (see `Updating` sect
- CLI `neofs-cli container set-eacl` checks container's ownership (#2436)

### Updated
- `neofs-sdk-go` to `v1.0.0-rc.10`
- `neofs-sdk-go` to `v1.0.0-rc.11`

### Updating from v0.37.0
CLI command timeouts (flag `--timeout`) now limit the total command execution
Expand Down
30 changes: 7 additions & 23 deletions cmd/neofs-cli/internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,19 +617,13 @@ func HeadObject(ctx context.Context, prm HeadObjectPrm) (*HeadObjectRes, error)

cliPrm.WithXHeaders(prm.xHeaders...)

res, err := prm.cli.ObjectHead(ctx, prm.objAddr.Container(), prm.objAddr.Object(), prm.signer, cliPrm)
hdr, err := prm.cli.ObjectHead(ctx, prm.objAddr.Container(), prm.objAddr.Object(), prm.signer, cliPrm)
if err != nil {
return nil, fmt.Errorf("read object header via client: %w", err)
}

var hdr object.Object

if !res.ReadHeader(&hdr) {
return nil, fmt.Errorf("missing header in response")
}

return &HeadObjectRes{
hdr: &hdr,
hdr: hdr,
}, nil
}

Expand Down Expand Up @@ -682,24 +676,14 @@ func SearchObjects(ctx context.Context, prm SearchObjectsPrm) (*SearchObjectsRes
return nil, fmt.Errorf("init object search: %w", err)
}

buf := make([]oid.ID, 10)
var list []oid.ID
var n int
var ok bool

for {
n, ok = rdr.Read(buf)
for i := 0; i < n; i++ {
list = append(list, buf[i])
}
if !ok {
break
}
}

err = rdr.Close()
err = rdr.Iterate(func(id oid.ID) bool {
list = append(list, id)
return false
})
if err != nil {
return nil, fmt.Errorf("read object list: %w", err)
return nil, fmt.Errorf("search objects using NeoFS API: %w", err)
}

return &SearchObjectsRes{
Expand Down
10 changes: 2 additions & 8 deletions cmd/neofs-cli/modules/container/list.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package container

import (
"strings"

"github.com/nspcc-dev/neofs-api-go/v2/container"
internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
Expand Down Expand Up @@ -65,11 +62,8 @@ var listContainersCmd = &cobra.Command{

res, err := internalclient.GetContainer(ctx, prmGet)
if err == nil {
res.Container().IterateAttributes(func(key, val string) {
if !strings.HasPrefix(key, container.SysAttributePrefix) {
// FIXME(@cthulhu-rider): neofs-sdk-go#314 use dedicated method to skip system attributes
cmd.Printf(" %s: %s\n", key, val)
}
res.Container().IterateUserAttributes(func(key, val string) {
cmd.Printf(" %s: %s\n", key, val)
})
} else {
cmd.Printf(" failed to read attributes: %v\n", err)
Expand Down
11 changes: 2 additions & 9 deletions cmd/neofs-cli/modules/container/list_objects.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package container

import (
"strings"

v2object "github.com/nspcc-dev/neofs-api-go/v2/object"
internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
Expand Down Expand Up @@ -74,13 +71,9 @@ var listContainerObjectsCmd = &cobra.Command{

resHead, err := internalclient.HeadObject(ctx, prmHead)
if err == nil {
attrs := resHead.Header().Attributes()
attrs := resHead.Header().UserAttributes()
for i := range attrs {
attrKey := attrs[i].Key()
if !strings.HasPrefix(attrKey, v2object.SysAttributePrefix) {
// FIXME(@cthulhu-rider): neofs-sdk-go#226 use dedicated method to skip system attributes
cmd.Printf(" %s: %s\n", attrKey, attrs[i].Value())
}
cmd.Printf(" %s: %s\n", attrs[i].Key(), attrs[i].Value())
}
} else {
cmd.Printf(" failed to read attributes: %v\n", err)
Expand Down
12 changes: 4 additions & 8 deletions cmd/neofs-cli/modules/control/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"crypto/ecdsa"
"errors"

"github.com/nspcc-dev/neofs-api-go/v2/refs"
internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
controlSvc "github.com/nspcc-dev/neofs-node/pkg/services/control/server"
"github.com/nspcc-dev/neofs-sdk-go/client"
neofscrypto "github.com/nspcc-dev/neofs-sdk-go/crypto"
neofsecdsa "github.com/nspcc-dev/neofs-sdk-go/crypto/ecdsa"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -41,14 +41,10 @@ func verifyResponse(cmd *cobra.Command,
common.ExitOnErr(cmd, "", errors.New("missing response signature"))
}

// TODO(@cthulhu-rider): #1387 use Signature message from NeoFS API to avoid conversion
var sigV2 refs.Signature
sigV2.SetScheme(refs.ECDSA_SHA512)
sigV2.SetKey(sigControl.GetKey())
sigV2.SetSign(sigControl.GetSign())
var pubKey neofsecdsa.PublicKey
common.ExitOnErr(cmd, "decode public key from signature: %w", pubKey.Decode(sigControl.GetKey()))

var sig neofscrypto.Signature
common.ExitOnErr(cmd, "can't read signature: %w", sig.ReadFromV2(sigV2))
sig := neofscrypto.NewSignature(neofscrypto.ECDSA_SHA512, &pubKey, sigControl.GetSign())

if !sig.Verify(body.StableMarshal(nil)) {
common.ExitOnErr(cmd, "", errors.New("invalid response signature"))
Expand Down
3 changes: 1 addition & 2 deletions cmd/neofs-cli/modules/object/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"strconv"
"time"

objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
Expand Down Expand Up @@ -72,7 +71,7 @@ var objectLockCmd = &cobra.Command{
common.PrintVerbose(cmd, "Lock object will expire after %d epoch", exp)

var expirationAttr objectSDK.Attribute
expirationAttr.SetKey(objectV2.SysAttributeExpEpoch)
expirationAttr.SetKey(objectSDK.AttributeExpirationEpoch)
expirationAttr.SetValue(strconv.FormatUint(exp, 10))

obj := objectSDK.New()
Expand Down
5 changes: 2 additions & 3 deletions cmd/neofs-cli/modules/object/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"time"

"github.com/cheggaaa/pb"
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
Expand Down Expand Up @@ -116,7 +115,7 @@ func putObject(cmd *cobra.Command, _ []string) {
expAttrValue := strconv.FormatUint(expiresOn, 10)

for i := range attrs {
if attrs[i].Key() == objectV2.SysAttributeExpEpoch {
if attrs[i].Key() == object.AttributeExpirationEpoch {
attrs[i].SetValue(expAttrValue)
expAttrFound = true
break
Expand All @@ -126,7 +125,7 @@ func putObject(cmd *cobra.Command, _ []string) {
if !expAttrFound {
index := len(attrs)
attrs = append(attrs, object.Attribute{})
attrs[index].SetKey(objectV2.SysAttributeExpEpoch)
attrs[index].SetKey(object.AttributeExpirationEpoch)
attrs[index].SetValue(expAttrValue)
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/object/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func collectObjectRelatives(ctx context.Context, cmd *cobra.Command, cli *client
common.PrintVerbose(cmd, "Collecting split members by split ID...")

var query object.SearchFilters
query.AddSplitIDFilter(object.MatchStringEqual, idSplit)
query.AddSplitIDFilter(object.MatchStringEqual, *idSplit)

var prm internal.SearchObjectsPrm
prm.SetContainerID(cnr)
Expand Down
5 changes: 2 additions & 3 deletions cmd/neofs-node/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
truststorage "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/storage"
"github.com/nspcc-dev/neofs-sdk-go/client"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
neofscrypto "github.com/nspcc-dev/neofs-sdk-go/crypto"
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
Expand Down Expand Up @@ -460,15 +459,15 @@ func (c *reputationClient) GetObjectInit(ctx context.Context, containerID cid.ID
return hdr, rdr, err
}

func (c *reputationClient) ObjectHead(ctx context.Context, containerID cid.ID, objectID oid.ID, signer user.Signer, prm client.PrmObjectHead) (*client.ResObjectHead, error) {
func (c *reputationClient) ObjectHead(ctx context.Context, containerID cid.ID, objectID oid.ID, signer user.Signer, prm client.PrmObjectHead) (*objectSDK.Object, error) {
res, err := c.MultiAddressClient.ObjectHead(ctx, containerID, objectID, signer, prm)

c.submitResult(err)

return res, err
}

func (c *reputationClient) ObjectHash(ctx context.Context, containerID cid.ID, objectID oid.ID, signer neofscrypto.Signer, prm client.PrmObjectHash) ([][]byte, error) {
func (c *reputationClient) ObjectHash(ctx context.Context, containerID cid.ID, objectID oid.ID, signer user.Signer, prm client.PrmObjectHash) ([][]byte, error) {
res, err := c.MultiAddressClient.ObjectHash(ctx, containerID, objectID, signer, prm)

c.submitResult(err)
Expand Down
36 changes: 18 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/google/go-github/v39 v39.2.0
github.com/google/uuid v1.3.0
github.com/hashicorp/golang-lru/v2 v2.0.2
github.com/klauspost/compress v1.15.13
github.com/klauspost/compress v1.16.7
github.com/mitchellh/go-homedir v1.1.0
github.com/mr-tron/base58 v1.2.0
github.com/multiformats/go-multiaddr v0.8.0
Expand All @@ -18,7 +18,7 @@ require (
github.com/nspcc-dev/neo-go v0.101.1
github.com/nspcc-dev/neofs-api-go/v2 v2.14.0
github.com/nspcc-dev/neofs-contract v0.16.0
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.10
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.11
github.com/nspcc-dev/tzhash v1.7.0
github.com/olekukonko/tablewriter v0.0.5
github.com/panjf2000/ants/v2 v2.4.0
Expand All @@ -28,27 +28,27 @@ require (
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.14.0
github.com/stretchr/testify v1.8.1
github.com/stretchr/testify v1.8.4
go.etcd.io/bbolt v1.3.7
go.uber.org/atomic v1.10.0
go.uber.org/zap v1.24.0
golang.org/x/sys v0.8.0
golang.org/x/term v0.5.0
google.golang.org/grpc v1.51.0
google.golang.org/protobuf v1.28.1
golang.org/x/sys v0.11.0
golang.org/x/term v0.11.0
google.golang.org/grpc v1.57.0
google.golang.org/protobuf v1.31.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20221202181307-76fa05c21b12 // indirect
github.com/benbjohnson/clock v1.1.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
Expand All @@ -58,7 +58,7 @@ require (
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/ipfs/go-cid v0.3.2 // indirect
github.com/klauspost/cpuid/v2 v2.2.2 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
Expand Down Expand Up @@ -93,15 +93,15 @@ require (
github.com/twmb/murmur3 v1.1.5 // indirect
github.com/urfave/cli v1.22.5 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.4.0 // indirect
golang.org/x/exp v0.0.0-20221227203929-1b447090c38c // indirect
golang.org/x/mod v0.6.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/time v0.1.0 // indirect
golang.org/x/tools v0.2.0 // indirect
google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef // indirect
golang.org/x/tools v0.11.1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
lukechampine.com/blake3 v1.1.7 // indirect
Expand Down
Loading

0 comments on commit 9bdb06c

Please sign in to comment.