From 03985f2eda5874b4caaf1e4e061c99155162718a Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 2 Mar 2022 13:46:11 +0300 Subject: [PATCH] [#126] Upgrade NeoFS SDK Go to 2nd release candidate v1.0.0 Avoid using the deprecated elements. Signed-off-by: Leonard Lyubich --- go.mod | 4 ++-- go.sum | 8 ++++---- integration_test.go | 10 +++++----- uploader/upload.go | 14 +++++++------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index f838189..7de7306 100644 --- a/go.mod +++ b/go.mod @@ -11,8 +11,8 @@ require ( github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect github.com/klauspost/compress v1.13.1 // indirect github.com/nspcc-dev/neo-go v0.98.0 - github.com/nspcc-dev/neofs-api-go/v2 v2.12.0 - github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.1.0.20220228071935-07817fb4032d + github.com/nspcc-dev/neofs-api-go/v2 v2.11.2-0.20220302134950-d065453bd0a7 + github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.2 github.com/prometheus/client_golang v1.11.0 github.com/prometheus/common v0.29.0 github.com/prometheus/procfs v0.7.1 // indirect diff --git a/go.sum b/go.sum index 051c241..dd4124f 100644 --- a/go.sum +++ b/go.sum @@ -589,15 +589,15 @@ github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1: github.com/nspcc-dev/neo-go v0.98.0 h1:yyW4sgY88/pLf0949qmgfkQXzRKC3CI/WyhqXNnwMd8= github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM= github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= -github.com/nspcc-dev/neofs-api-go/v2 v2.12.0 h1:xWqXzorDk9WFMTtWP7cwwlyJDL1X6Z4HT1e5zqkq7xY= -github.com/nspcc-dev/neofs-api-go/v2 v2.12.0/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= +github.com/nspcc-dev/neofs-api-go/v2 v2.11.2-0.20220302134950-d065453bd0a7 h1:hLMvj4K9djzBg+TaeDGQWGuohzXvcThi0r0LSLhhi3M= +github.com/nspcc-dev/neofs-api-go/v2 v2.11.2-0.20220302134950-d065453bd0a7/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= 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= github.com/nspcc-dev/neofs-crypto v0.3.0/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw= github.com/nspcc-dev/neofs-sdk-go v0.0.0-20211201182451-a5b61c4f6477/go.mod h1:dfMtQWmBHYpl9Dez23TGtIUKiFvCIxUZq/CkSIhEpz4= -github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.1.0.20220228071935-07817fb4032d h1:ku9s0XJ2LoWbB6nUjkyP7M8ki2nLOlMIvi4fAocf+iY= -github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.1.0.20220228071935-07817fb4032d/go.mod h1:/WV31AQHs6YLTjMgMjMZw8Z3/Q7b6kMjNgJVsRab5AU= +github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.2 h1:m+em1eyrYFIGUdzs2asDCJH0GVWH+9rYdjLTO42mxSY= +github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.2/go.mod h1:bkVH6yZXH5/F2Sut20SDOlQbveBlaVJ0vOX20tLGnZw= github.com/nspcc-dev/rfc6979 v0.1.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso= github.com/nspcc-dev/rfc6979 v0.2.0 h1:3e1WNxrN60/6N0DW7+UYisLeZJyfqZTNOjeV/toYvOE= github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso= diff --git a/integration_test.go b/integration_test.go index bac23bf..8c124e4 100644 --- a/integration_test.go +++ b/integration_test.go @@ -311,9 +311,9 @@ func createContainer(ctx context.Context, t *testing.T, clientPool pool.Pool) (* } func putObject(ctx context.Context, t *testing.T, clientPool pool.Pool, CID *cid.ID, content string, attributes map[string]string) *oid.ID { - rawObject := object.NewRaw() - rawObject.SetContainerID(CID) - rawObject.SetOwnerID(clientPool.OwnerID()) + obj := object.New() + obj.SetContainerID(CID) + obj.SetOwnerID(clientPool.OwnerID()) var attrs []*object.Attribute for key, val := range attributes { @@ -322,9 +322,9 @@ func putObject(ctx context.Context, t *testing.T, clientPool pool.Pool, CID *cid attr.SetValue(val) attrs = append(attrs, attr) } - rawObject.SetAttributes(attrs...) + obj.SetAttributes(attrs...) - id, err := clientPool.PutObject(ctx, *rawObject.Object(), bytes.NewBufferString(content)) + id, err := clientPool.PutObject(ctx, *obj, bytes.NewBufferString(content)) require.NoError(t, err) return id diff --git a/uploader/upload.go b/uploader/upload.go index f6ed91e..c3ca85b 100644 --- a/uploader/upload.go +++ b/uploader/upload.go @@ -55,7 +55,7 @@ func (u *Uploader) Upload(c *fasthttp.RequestCtx) { var ( err error file MultipartFile - obj *oid.ID + idObj *oid.ID addr = address.NewAddress() idCnr = cid.New() scid, _ = c.UserValue("cid").(string) @@ -131,18 +131,18 @@ func (u *Uploader) Upload(c *fasthttp.RequestCtx) { } id, bt := u.fetchOwnerAndBearerToken(c) - rawObject := object.NewRaw() - rawObject.SetContainerID(idCnr) - rawObject.SetOwnerID(id) - rawObject.SetAttributes(attributes...) + obj := object.New() + obj.SetContainerID(idCnr) + obj.SetOwnerID(id) + obj.SetAttributes(attributes...) - if obj, err = u.pool.PutObject(c, *rawObject.Object(), file, pool.WithBearer(bt)); err != nil { + if idObj, err = u.pool.PutObject(c, *obj, file, pool.WithBearer(bt)); err != nil { log.Error("could not store file in neofs", zap.Error(err)) response.Error(c, "could not store file in neofs", fasthttp.StatusBadRequest) return } - addr.SetObjectID(obj) + addr.SetObjectID(idObj) addr.SetContainerID(idCnr) // Try to return the response, otherwise, if something went wrong, throw an error.