[#283] pkg/container: Define ID in a separate package

In order to prevent potential cross imports, container ID should be defined
in a separate package as a base type. A similar approach was used in the
NeoFS API design.

Create `pkg/container/id` package and replace container ID implementation to
it. Related API in `container` package is deprecated from now.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-24 19:31:58 +03:00 committed by Alex Vanin
parent 9eb567a53a
commit 7314038069
6 changed files with 206 additions and 207 deletions

View file

@ -2,6 +2,7 @@ package client
import (
"context"
"errors"
"fmt"
"github.com/nspcc-dev/neofs-api-go/pkg"
@ -170,7 +171,7 @@ func (c *clientImpl) GetContainer(ctx context.Context, id *container.ID, opts ..
// GetVerifiedContainerStructure is a wrapper over Client.GetContainer method
// which checks if the structure of the resulting container matches its identifier.
//
// Returns container.ErrIDMismatch if container does not match the identifier.
// Returns an error if container does not match the identifier.
func GetVerifiedContainerStructure(ctx context.Context, c Client, id *container.ID, opts ...CallOption) (*container.Container, error) {
cnr, err := c.GetContainer(ctx, id, opts...)
if err != nil {
@ -178,7 +179,7 @@ func GetVerifiedContainerStructure(ctx context.Context, c Client, id *container.
}
if !container.CalculateID(cnr).Equal(id) {
return nil, container.ErrIDMismatch
return nil, errors.New("container structure does not match the identifier")
}
return cnr, nil