Skip to content

Commit

Permalink
[#376] Update NeoFS SDK to v1.0.0-rc.3
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Kirillov <[email protected]>
  • Loading branch information
KirillovDenis committed Mar 16, 2022
1 parent 52f0af0 commit 94406b0
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 26 deletions.
2 changes: 1 addition & 1 deletion api/handler/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ func formRecords(operations []*astOperation, resource *astResource) ([]*eacl.Rec
return res, nil
}

func addToList(operations []*astOperation, rec *eacl.Record, target *eacl.Target) []*astOperation {
func addToList(operations []*astOperation, rec eacl.Record, target eacl.Target) []*astOperation {
var found *astOperation
for _, astOp := range operations {
if astOp.Op == rec.Operation() && astOp.Role == target.Role() {
Expand Down
2 changes: 1 addition & 1 deletion api/layer/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type (
// PathSeparator is a path components separator string.
const PathSeparator = string(os.PathSeparator)

func userHeaders(attrs []*object.Attribute) map[string]string {
func userHeaders(attrs []object.Attribute) map[string]string {
result := make(map[string]string, len(attrs))

for _, attr := range attrs {
Expand Down
2 changes: 1 addition & 1 deletion api/layer/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func newTestObject(id *oid.ID, bkt *data.BucketInfo, name string) *object.Object
obj.SetOwnerID(bkt.Owner)
obj.SetContainerID(bkt.CID)
obj.SetPayload(defaultTestPayload)
obj.SetAttributes(filename, created, contentType)
obj.SetAttributes(*filename, *created, *contentType)
obj.SetPayloadSize(uint64(defaultTestPayloadLength))

return obj
Expand Down
8 changes: 4 additions & 4 deletions api/layer/versioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,20 @@ func (t *testNeoFS) ReadObject(_ context.Context, prm PrmObjectRead) (*ObjectPar
func (t *testNeoFS) CreateObject(_ context.Context, prm PrmObjectCreate) (*oid.ID, error) {
id := test.ID()

attrs := make([]*object.Attribute, 0)
attrs := make([]object.Attribute, 0)

if prm.Filename != "" {
a := object.NewAttribute()
a.SetKey(object.AttributeFileName)
a.SetValue(prm.Filename)
attrs = append(attrs, a)
attrs = append(attrs, *a)
}

for i := range prm.Attributes {
a := object.NewAttribute()
a.SetKey(prm.Attributes[i][0])
a.SetValue(prm.Attributes[i][1])
attrs = append(attrs, a)
attrs = append(attrs, *a)
}

obj := object.New()
Expand Down Expand Up @@ -205,7 +205,7 @@ func newTestPool() *testNeoFS {
}
}

func isMatched(attributes []*object.Attribute, filter object.SearchFilter) bool {
func isMatched(attributes []object.Attribute, filter object.SearchFilter) bool {
for _, attr := range attributes {
if attr.Key() == filter.Header() && attr.Value() == filter.Value() {
return true
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ require (
github.com/nats-io/nats-server/v2 v2.7.1 // indirect
github.com/nats-io/nats.go v1.13.1-0.20220121202836-972a071d373d
github.com/nspcc-dev/neo-go v0.98.0
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/nspcc-dev/neofs-api-go/v2 v2.12.1
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.3
github.com/prometheus/client_golang v1.11.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.7.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,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.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-api-go/v2 v2.12.1 h1:PVU2rLlG9S0jDe5eKyaUs4nKo/la+mN5pvz32Gib3qM=
github.com/nspcc-dev/neofs-api-go/v2 v2.12.1/go.mod h1:73j09Xa7I2zQbM3HCvAHnDHPYiiWnEHa1d6Z6RDMBLU=
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.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/neofs-sdk-go v1.0.0-rc.3 h1:ofaiKPYY67a0cQMF+YSChDO48SBQtWlpZnK++cAeqQM=
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.3/go.mod h1:0hTXmyJnbw8j4BR1oltN7mFIIrVp1IFLdh8qBzAR464=
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=
Expand Down
21 changes: 8 additions & 13 deletions internal/neofs/neofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ import (
// It is used to provide an interface to dependent packages
// which work with NeoFS.
type NeoFS struct {
pool pool.Pool
pool *pool.Pool
}

// SetConnectionPool binds underlying pool.Pool. Must be
// called on initialization stage before any usage.
func (x *NeoFS) SetConnectionPool(p pool.Pool) {
func (x *NeoFS) SetConnectionPool(p *pool.Pool) {
x.pool = p
}

Expand Down Expand Up @@ -180,12 +180,7 @@ func (x *NeoFS) UserContainers(ctx context.Context, id owner.ID) ([]cid.ID, erro
return nil, fmt.Errorf("list user containers via connection pool: %w", err)
}

res := make([]cid.ID, len(r))
for i := range r {
res[i] = *r[i]
}

return res, nil
return r, nil
}

// SetContainerEACL saves eACL table of the container in NeoFS using connection pool.
Expand Down Expand Up @@ -269,33 +264,33 @@ func (x *NeoFS) CreateObject(ctx context.Context, prm PrmObjectCreate) (*oid.ID,
attrNum++
}

attrs := make([]*object.Attribute, 0, attrNum)
attrs := make([]object.Attribute, 0, attrNum)
var a *object.Attribute

a = object.NewAttribute()
a.SetKey(object.AttributeTimestamp)
a.SetValue(strconv.FormatInt(prm.Time.Unix(), 10))
attrs = append(attrs, a)
attrs = append(attrs, *a)

for i := range prm.Attributes {
a = object.NewAttribute()
a.SetKey(prm.Attributes[i][0])
a.SetValue(prm.Attributes[i][1])
attrs = append(attrs, a)
attrs = append(attrs, *a)
}

if prm.Filename != "" {
a = object.NewAttribute()
a.SetKey(object.AttributeFileName)
a.SetValue(prm.Filename)
attrs = append(attrs, a)
attrs = append(attrs, *a)
}

if prm.ExpirationEpoch > 0 {
a = object.NewAttribute()
a.SetKey("__NEOFS__EXPIRATION_EPOCH")
a.SetValue(strconv.FormatUint(prm.ExpirationEpoch, 10))
attrs = append(attrs, a)
attrs = append(attrs, *a)
}

raw := object.New()
Expand Down

0 comments on commit 94406b0

Please sign in to comment.