forked from TrueCloudLab/frostfs-api-go
[#194] pkg/client: Verify container format in GetContainer method
Make Client.GetContainer method to return an error if received container structure does not meet NeoFS API specification. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
7988405753
commit
c4f7be19ea
1 changed files with 4 additions and 1 deletions
|
@ -55,6 +55,9 @@ func (c Client) PutContainer(ctx context.Context, cnr *container.Container, opts
|
|||
}
|
||||
}
|
||||
|
||||
// GetContainer receives container structure through NeoFS API call.
|
||||
//
|
||||
// Returns error if container structure is received but does not meet NeoFS API specification.
|
||||
func (c Client) GetContainer(ctx context.Context, id *container.ID, opts ...CallOption) (*container.Container, error) {
|
||||
switch c.remoteNode.Version.Major() {
|
||||
case 2:
|
||||
|
@ -259,7 +262,7 @@ func (c Client) getContainerV2(ctx context.Context, id *container.ID, opts ...Ca
|
|||
return nil, errors.Wrap(err, "can't verify response message")
|
||||
}
|
||||
|
||||
return container.NewContainerFromV2(resp.GetBody().GetContainer()), nil
|
||||
return container.NewVerifiedFromV2(resp.GetBody().GetContainer())
|
||||
default:
|
||||
return nil, errUnsupportedProtocol
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue