From b3b190adc0e54f787b5ff9c3a334624f60d71d05 Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Fri, 4 Jun 2021 16:01:42 +0300 Subject: [PATCH] [#68] *: Replace deprecated Signed-off-by: Angira Kekteeva --- api/layer/container.go | 7 ++++--- api/layer/layer.go | 4 ++-- api/layer/object.go | 4 ++-- api/layer/util_test.go | 6 +++--- authmate/authmate.go | 9 +++++---- cmd/authmate/main.go | 10 +++++----- creds/bearer/credentials.go | 6 +++--- 7 files changed, 24 insertions(+), 22 deletions(-) diff --git a/api/layer/container.go b/api/layer/container.go index d6c720c0..55b5912e 100644 --- a/api/layer/container.go +++ b/api/layer/container.go @@ -6,6 +6,7 @@ import ( "time" "github.com/nspcc-dev/neofs-api-go/pkg/container" + cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id" "github.com/nspcc-dev/neofs-api-go/pkg/owner" "github.com/nspcc-dev/neofs-s3-gw/api" "go.uber.org/zap" @@ -15,7 +16,7 @@ type ( // BucketInfo stores basic bucket data. BucketInfo struct { Name string - CID *container.ID + CID *cid.ID Owner *owner.ID Created time.Time } @@ -30,7 +31,7 @@ type ( } ) -func (n *layer) containerInfo(ctx context.Context, cid *container.ID) (*BucketInfo, error) { +func (n *layer) containerInfo(ctx context.Context, cid *cid.ID) (*BucketInfo, error) { var ( err error res *container.Container @@ -88,7 +89,7 @@ func (n *layer) containerList(ctx context.Context) ([]*BucketInfo, error) { var ( err error own = n.Owner(ctx) - res []*container.ID + res []*cid.ID rid = api.GetRequestID(ctx) ) diff --git a/api/layer/layer.go b/api/layer/layer.go index ec41bafe..e238b426 100644 --- a/api/layer/layer.go +++ b/api/layer/layer.go @@ -10,7 +10,7 @@ import ( "time" "github.com/nspcc-dev/neofs-api-go/pkg/client" - "github.com/nspcc-dev/neofs-api-go/pkg/container" + cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id" "github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/owner" "github.com/nspcc-dev/neofs-api-go/pkg/token" @@ -259,7 +259,7 @@ func (n *layer) GetObject(ctx context.Context, p *GetObjectParams) error { return nil } -func (n *layer) checkObject(ctx context.Context, cid *container.ID, filename string) error { +func (n *layer) checkObject(ctx context.Context, cid *cid.ID, filename string) error { var err error if _, err = n.objectFindID(ctx, &findParams{cid: cid, val: filename}); err == nil { diff --git a/api/layer/object.go b/api/layer/object.go index 8957ea9e..b13fb43b 100644 --- a/api/layer/object.go +++ b/api/layer/object.go @@ -9,7 +9,7 @@ import ( "time" "github.com/nspcc-dev/neofs-api-go/pkg/client" - "github.com/nspcc-dev/neofs-api-go/pkg/container" + cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id" "github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-s3-gw/api" "google.golang.org/grpc/codes" @@ -19,7 +19,7 @@ import ( type ( findParams struct { val string - cid *container.ID + cid *cid.ID } getParams struct { diff --git a/api/layer/util_test.go b/api/layer/util_test.go index 07491558..151b8f7c 100644 --- a/api/layer/util_test.go +++ b/api/layer/util_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/nspcc-dev/neofs-api-go/pkg/container" + cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id" "github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/owner" "github.com/stretchr/testify/require" @@ -83,11 +83,11 @@ func testNameFromObjectName(name string) (string, string) { func Test_objectInfoFromMeta(t *testing.T) { uid := owner.NewID() oid := object.NewID() - cid := container.NewID() + containerID := cid.New() bkt := &BucketInfo{ Name: "test-container", - CID: cid, + CID: containerID, Owner: uid, Created: time.Now(), } diff --git a/authmate/authmate.go b/authmate/authmate.go index 52ce854c..b994c3f5 100644 --- a/authmate/authmate.go +++ b/authmate/authmate.go @@ -14,6 +14,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl" "github.com/nspcc-dev/neofs-api-go/pkg/container" + cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id" "github.com/nspcc-dev/neofs-api-go/pkg/netmap" "github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/owner" @@ -45,7 +46,7 @@ func New(log *zap.Logger, conns pool.Pool) *Agent { type ( // IssueSecretOptions contains options for passing to Agent.IssueSecret method. IssueSecretOptions struct { - ContainerID *container.ID + ContainerID *cid.ID ContainerFriendlyName string NeoFSKey *ecdsa.PrivateKey OwnerPrivateKey hcs.PrivateKey @@ -73,7 +74,7 @@ type ( } ) -func (a *Agent) checkContainer(ctx context.Context, cid *container.ID, friendlyName string) (*container.ID, error) { +func (a *Agent) checkContainer(ctx context.Context, cid *cid.ID, friendlyName string) (*cid.ID, error) { conn, _, err := a.pool.Connection() if err != nil { return nil, err @@ -127,7 +128,7 @@ func (a *Agent) checkContainer(ctx context.Context, cid *container.ID, friendlyN func (a *Agent) IssueSecret(ctx context.Context, w io.Writer, options *IssueSecretOptions) error { var ( err error - cid *container.ID + cid *cid.ID ) a.log.Info("check container", zap.Stringer("cid", options.ContainerID)) @@ -238,7 +239,7 @@ func newReplica(name string, count uint32) (r *netmap.Replica) { return } -func buildEACLTable(cid *container.ID, eaclTable []byte) (*eacl.Table, error) { +func buildEACLTable(cid *cid.ID, eaclTable []byte) (*eacl.Table, error) { table := eacl.NewTable() if len(eaclTable) != 0 { return table, table.UnmarshalJSON(eaclTable) diff --git a/cmd/authmate/main.go b/cmd/authmate/main.go index 1cef2d92..37318df8 100644 --- a/cmd/authmate/main.go +++ b/cmd/authmate/main.go @@ -12,7 +12,7 @@ import ( "syscall" "time" - "github.com/nspcc-dev/neofs-api-go/pkg/container" + cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id" crypto "github.com/nspcc-dev/neofs-crypto" "github.com/nspcc-dev/neofs-s3-gw/authmate" "github.com/nspcc-dev/neofs-s3-gw/creds/hcs" @@ -246,10 +246,10 @@ func issueSecret() *cli.Command { } agent := authmate.New(log, client) - var cid *container.ID + var containerID *cid.ID if len(containerIDFlag) > 0 { - cid = container.NewID() - if err := cid.Parse(containerIDFlag); err != nil { + containerID = cid.New() + if err := containerID.Parse(containerIDFlag); err != nil { return cli.Exit(fmt.Sprintf("failed to parse auth container id: %s", err), 3) } } @@ -269,7 +269,7 @@ func issueSecret() *cli.Command { } issueSecretOptions := &authmate.IssueSecretOptions{ - ContainerID: cid, + ContainerID: containerID, ContainerFriendlyName: containerFriendlyName, NeoFSKey: key, OwnerPrivateKey: owner.PrivateKey(), diff --git a/creds/bearer/credentials.go b/creds/bearer/credentials.go index 1d6cf60d..ffaf5509 100644 --- a/creds/bearer/credentials.go +++ b/creds/bearer/credentials.go @@ -9,7 +9,7 @@ import ( "time" "github.com/nspcc-dev/neofs-api-go/pkg/client" - "github.com/nspcc-dev/neofs-api-go/pkg/container" + cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id" "github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/token" "github.com/nspcc-dev/neofs-s3-gw/creds/accessbox" @@ -21,7 +21,7 @@ type ( // Credentials is a bearer token get/put interface. Credentials interface { Get(context.Context, *object.Address) (*token.BearerToken, error) - Put(context.Context, *container.ID, *token.BearerToken, ...hcs.PublicKey) (*object.Address, error) + Put(context.Context, *cid.ID, *token.BearerToken, ...hcs.PublicKey) (*object.Address, error) } cred struct { @@ -88,7 +88,7 @@ func (c *cred) Get(ctx context.Context, address *object.Address) (*token.BearerT return box.Token(), nil } -func (c *cred) Put(ctx context.Context, cid *container.ID, tkn *token.BearerToken, keys ...hcs.PublicKey) (*object.Address, error) { +func (c *cred) Put(ctx context.Context, cid *cid.ID, tkn *token.BearerToken, keys ...hcs.PublicKey) (*object.Address, error) { var ( err error buf = c.acquireBuffer()