forked from TrueCloudLab/frostfs-sdk-go
client: Remove MissingContext panic
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
This commit is contained in:
parent
cfdd870755
commit
cb4acec6a2
12 changed files with 0 additions and 70 deletions
|
@ -45,8 +45,6 @@ func (x ResBalanceGet) Amount() accounting.Decimal {
|
|||
// Context is required and must not be nil. It is used for network communication.
|
||||
func (c *Client) BalanceGet(ctx context.Context, prm PrmBalanceGet) (*ResBalanceGet, error) {
|
||||
switch {
|
||||
case ctx == nil:
|
||||
panic(panicMsgMissingContext)
|
||||
case !prm.accountSet:
|
||||
panic("account not set")
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ func writeXHeadersToMeta(xHeaders []string, h *v2session.RequestMetaHeader) {
|
|||
|
||||
// panic messages.
|
||||
const (
|
||||
panicMsgMissingContext = "missing context"
|
||||
panicMsgMissingContainer = "missing container"
|
||||
panicMsgMissingObject = "missing object"
|
||||
panicMsgOwnerExtract = "extract owner failed"
|
||||
|
|
|
@ -89,8 +89,6 @@ func (c *Client) defaultSigner() neofscrypto.Signer {
|
|||
func (c *Client) ContainerPut(ctx context.Context, prm PrmContainerPut) (*ResContainerPut, error) {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
panic(panicMsgMissingContext)
|
||||
case !prm.cnrSet:
|
||||
panic(panicMsgMissingContainer)
|
||||
}
|
||||
|
@ -210,8 +208,6 @@ func (x ResContainerGet) Container() container.Container {
|
|||
// Context is required and must not be nil. It is used for network communication.
|
||||
func (c *Client) ContainerGet(ctx context.Context, prm PrmContainerGet) (*ResContainerGet, error) {
|
||||
switch {
|
||||
case ctx == nil:
|
||||
panic(panicMsgMissingContext)
|
||||
case !prm.idSet:
|
||||
panic(panicMsgMissingContainer)
|
||||
}
|
||||
|
@ -301,8 +297,6 @@ func (x ResContainerList) Containers() []cid.ID {
|
|||
func (c *Client) ContainerList(ctx context.Context, prm PrmContainerList) (*ResContainerList, error) {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
panic(panicMsgMissingContext)
|
||||
case !prm.ownerSet:
|
||||
panic("account not set")
|
||||
}
|
||||
|
@ -409,8 +403,6 @@ func (x *PrmContainerDelete) WithinSession(tok session.Container) {
|
|||
func (c *Client) ContainerDelete(ctx context.Context, prm PrmContainerDelete) error {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
panic(panicMsgMissingContext)
|
||||
case !prm.idSet:
|
||||
panic(panicMsgMissingContainer)
|
||||
}
|
||||
|
@ -515,8 +507,6 @@ func (x ResContainerEACL) Table() eacl.Table {
|
|||
func (c *Client) ContainerEACL(ctx context.Context, prm PrmContainerEACL) (*ResContainerEACL, error) {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
panic(panicMsgMissingContext)
|
||||
case !prm.idSet:
|
||||
panic(panicMsgMissingContainer)
|
||||
}
|
||||
|
@ -624,8 +614,6 @@ func (x *PrmContainerSetEACL) WithinSession(s session.Container) {
|
|||
func (c *Client) ContainerSetEACL(ctx context.Context, prm PrmContainerSetEACL) error {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
panic(panicMsgMissingContext)
|
||||
case !prm.tableSet:
|
||||
panic("eACL table not set")
|
||||
}
|
||||
|
@ -725,8 +713,6 @@ func (x *PrmAnnounceSpace) SetValues(vs []container.SizeEstimation) {
|
|||
func (c *Client) ContainerAnnounceUsedSpace(ctx context.Context, prm PrmAnnounceSpace) error {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
panic(panicMsgMissingContext)
|
||||
case len(prm.announcements) == 0:
|
||||
panic("missing announcements")
|
||||
}
|
||||
|
|
|
@ -41,17 +41,9 @@ func (x ResEndpointInfo) NodeInfo() netmap.NodeInfo {
|
|||
// Any client's internal or transport errors are returned as `error`,
|
||||
// see [apistatus] package for NeoFS-specific error types.
|
||||
//
|
||||
// Immediately panics if parameters are set incorrectly (see PrmEndpointInfo docs).
|
||||
// Context is required and must not be nil. It is used for network communication.
|
||||
//
|
||||
// Exactly one return value is non-nil. Server status return is returned in ResEndpointInfo.
|
||||
// Reflects all internal errors in second return value (transport problems, response processing, etc.).
|
||||
func (c *Client) EndpointInfo(ctx context.Context, prm PrmEndpointInfo) (*ResEndpointInfo, error) {
|
||||
// check context
|
||||
if ctx == nil {
|
||||
panic(panicMsgMissingContext)
|
||||
}
|
||||
|
||||
// form request
|
||||
var req v2netmap.LocalNodeInfoRequest
|
||||
|
||||
|
@ -130,17 +122,9 @@ func (x ResNetworkInfo) Info() netmap.NetworkInfo {
|
|||
// Any client's internal or transport errors are returned as `error`,
|
||||
// see [apistatus] package for NeoFS-specific error types.
|
||||
//
|
||||
// Immediately panics if parameters are set incorrectly (see PrmNetworkInfo docs).
|
||||
// Context is required and must not be nil. It is used for network communication.
|
||||
//
|
||||
// Exactly one return value is non-nil. Server status return is returned in ResNetworkInfo.
|
||||
// Reflects all internal errors in second return value (transport problems, response processing, etc.).
|
||||
func (c *Client) NetworkInfo(ctx context.Context, prm PrmNetworkInfo) (*ResNetworkInfo, error) {
|
||||
// check context
|
||||
if ctx == nil {
|
||||
panic(panicMsgMissingContext)
|
||||
}
|
||||
|
||||
// form request
|
||||
var req v2netmap.NetworkInfoRequest
|
||||
|
||||
|
@ -207,11 +191,6 @@ func (x ResNetMapSnapshot) NetMap() netmap.NetMap {
|
|||
// Exactly one return value is non-nil. Server status return is returned in ResNetMapSnapshot.
|
||||
// Reflects all internal errors in second return value (transport problems, response processing, etc.).
|
||||
func (c *Client) NetMapSnapshot(ctx context.Context, _ PrmNetMapSnapshot) (*ResNetMapSnapshot, error) {
|
||||
// check context
|
||||
if ctx == nil {
|
||||
panic(panicMsgMissingContext)
|
||||
}
|
||||
|
||||
// form request body
|
||||
var body v2netmap.SnapshotRequestBody
|
||||
|
||||
|
|
|
@ -82,12 +82,6 @@ func TestClient_NetMapSnapshot(t *testing.T) {
|
|||
c := newClient(signer, &srv)
|
||||
ctx := context.Background()
|
||||
|
||||
// missing context
|
||||
require.PanicsWithValue(t, panicMsgMissingContext, func() {
|
||||
//nolint:staticcheck
|
||||
_, _ = c.NetMapSnapshot(nil, prm)
|
||||
})
|
||||
|
||||
// request signature
|
||||
srv.errTransport = errors.New("any error")
|
||||
|
||||
|
|
|
@ -125,8 +125,6 @@ func (x ResObjectDelete) Tombstone() oid.ID {
|
|||
// - [apistatus.ErrSessionTokenExpired].
|
||||
func (c *Client) ObjectDelete(ctx context.Context, prm PrmObjectDelete) (*ResObjectDelete, error) {
|
||||
switch {
|
||||
case ctx == nil:
|
||||
panic(panicMsgMissingContext)
|
||||
case prm.addr.GetContainerID() == nil:
|
||||
panic(panicMsgMissingContainer)
|
||||
case prm.addr.GetObjectID() == nil:
|
||||
|
|
|
@ -294,8 +294,6 @@ func (x *ObjectReader) Read(p []byte) (int, error) {
|
|||
func (c *Client) ObjectGetInit(ctx context.Context, prm PrmObjectGet) (*ObjectReader, error) {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
panic(panicMsgMissingContext)
|
||||
case prm.addr.GetContainerID() == nil:
|
||||
panic(panicMsgMissingContainer)
|
||||
case prm.addr.GetObjectID() == nil:
|
||||
|
@ -400,8 +398,6 @@ func (x *ResObjectHead) ReadHeader(dst *object.Object) bool {
|
|||
// - [apistatus.ErrSessionTokenExpired].
|
||||
func (c *Client) ObjectHead(ctx context.Context, prm PrmObjectHead) (*ResObjectHead, error) {
|
||||
switch {
|
||||
case ctx == nil:
|
||||
panic(panicMsgMissingContext)
|
||||
case prm.addr.GetContainerID() == nil:
|
||||
panic(panicMsgMissingContainer)
|
||||
case prm.addr.GetObjectID() == nil:
|
||||
|
@ -644,8 +640,6 @@ func (x *ObjectRangeReader) Read(p []byte) (int, error) {
|
|||
func (c *Client) ObjectRangeInit(ctx context.Context, prm PrmObjectRange) (*ObjectRangeReader, error) {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
panic(panicMsgMissingContext)
|
||||
case prm.addr.GetContainerID() == nil:
|
||||
panic(panicMsgMissingContainer)
|
||||
case prm.addr.GetObjectID() == nil:
|
||||
|
|
|
@ -156,8 +156,6 @@ func (x ResObjectHash) Checksums() [][]byte {
|
|||
// Context is required and must not be nil. It is used for network communication.
|
||||
func (c *Client) ObjectHash(ctx context.Context, prm PrmObjectHash) (*ResObjectHash, error) {
|
||||
switch {
|
||||
case ctx == nil:
|
||||
panic(panicMsgMissingContext)
|
||||
case prm.addr.GetContainerID() == nil:
|
||||
panic(panicMsgMissingContainer)
|
||||
case prm.addr.GetObjectID() == nil:
|
||||
|
|
|
@ -233,11 +233,6 @@ func (x *ObjectWriter) Close() (*ResObjectPut, error) {
|
|||
//
|
||||
// Context is required and must not be nil. It is used for network communication.
|
||||
func (c *Client) ObjectPutInit(ctx context.Context, prm PrmObjectPutInit) (*ObjectWriter, error) {
|
||||
// check parameters
|
||||
if ctx == nil {
|
||||
panic(panicMsgMissingContext)
|
||||
}
|
||||
|
||||
var w ObjectWriter
|
||||
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
|
|
|
@ -210,8 +210,6 @@ func (x *ObjectListReader) Close() error {
|
|||
func (c *Client) ObjectSearchInit(ctx context.Context, prm PrmObjectSearch) (*ObjectListReader, error) {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
panic(panicMsgMissingContext)
|
||||
case !prm.cnrSet:
|
||||
panic(panicMsgMissingContainer)
|
||||
}
|
||||
|
|
|
@ -42,8 +42,6 @@ func (x *PrmAnnounceLocalTrust) SetValues(trusts []reputation.Trust) {
|
|||
func (c *Client) AnnounceLocalTrust(ctx context.Context, prm PrmAnnounceLocalTrust) error {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
panic(panicMsgMissingContext)
|
||||
case prm.epoch == 0:
|
||||
panic("zero epoch")
|
||||
case len(prm.trusts) == 0:
|
||||
|
@ -130,8 +128,6 @@ func (x *PrmAnnounceIntermediateTrust) SetCurrentValue(trust reputation.PeerToPe
|
|||
func (c *Client) AnnounceIntermediateTrust(ctx context.Context, prm PrmAnnounceIntermediateTrust) error {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
panic(panicMsgMissingContext)
|
||||
case prm.epoch == 0:
|
||||
panic("zero epoch")
|
||||
case !prm.trustSet:
|
||||
|
|
|
@ -67,11 +67,6 @@ func (x ResSessionCreate) PublicKey() []byte {
|
|||
// Immediately panics if parameters are set incorrectly (see PrmSessionCreate docs).
|
||||
// Context is required and must not be nil. It is used for network communication.
|
||||
func (c *Client) SessionCreate(ctx context.Context, prm PrmSessionCreate) (*ResSessionCreate, error) {
|
||||
// check context
|
||||
if ctx == nil {
|
||||
panic(panicMsgMissingContext)
|
||||
}
|
||||
|
||||
var ownerID user.ID
|
||||
if err := user.IDFromSigner(&ownerID, prm.signer); err != nil {
|
||||
panic(panicMsgOwnerExtract)
|
||||
|
|
Loading…
Reference in a new issue