forked from TrueCloudLab/frostfs-node
[#302] Fix golint else/return linter errors
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
0f3570bdeb
commit
e88c1f750d
9 changed files with 57 additions and 52 deletions
|
@ -32,9 +32,9 @@ func readAttributes(v *viper.Viper) (attrs []string) {
|
||||||
attr := v.GetString(cfgNodeAttributePrefix + "_" + strconv.Itoa(i))
|
attr := v.GetString(cfgNodeAttributePrefix + "_" + strconv.Itoa(i))
|
||||||
if attr == "" {
|
if attr == "" {
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
attrs = append(attrs, attr)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
attrs = append(attrs, attr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return attrs
|
return attrs
|
||||||
|
|
|
@ -42,7 +42,8 @@ func (b *BlobStor) Put(prm *PutPrm) (*PutRes, error) {
|
||||||
if big {
|
if big {
|
||||||
// save object in shallow dir
|
// save object in shallow dir
|
||||||
return new(PutRes), b.fsTree.put(prm.obj.Address(), data)
|
return new(PutRes), b.fsTree.put(prm.obj.Address(), data)
|
||||||
} else {
|
}
|
||||||
|
|
||||||
// save object in blobovnicza
|
// save object in blobovnicza
|
||||||
res, err := b.blobovniczas.put(prm.obj.Address(), data)
|
res, err := b.blobovniczas.put(prm.obj.Address(), data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -55,7 +56,6 @@ func (b *BlobStor) Put(prm *PutPrm) (*PutRes, error) {
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func (t *fsTree) put(addr *objectSDK.Address, data []byte) error {
|
func (t *fsTree) put(addr *objectSDK.Address, data []byte) error {
|
||||||
p := t.treePath(addr)
|
p := t.treePath(addr)
|
||||||
|
|
|
@ -62,12 +62,13 @@ func (w *ClientWrapper) ListAuditResultIDByCID(epoch uint64, cid *container.ID)
|
||||||
args := audit.ListResultsByCIDArgs{}
|
args := audit.ListResultsByCIDArgs{}
|
||||||
args.SetEpoch(int64(epoch))
|
args.SetEpoch(int64(epoch))
|
||||||
|
|
||||||
if v2 := cid.ToV2(); v2 == nil {
|
v2 := cid.ToV2()
|
||||||
|
if v2 == nil {
|
||||||
return nil, errUnsupported // use other major version if there any
|
return nil, errUnsupported // use other major version if there any
|
||||||
} else {
|
|
||||||
args.SetCID(v2.GetValue())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
args.SetCID(v2.GetValue())
|
||||||
|
|
||||||
values, err := (*audit.Client)(w).ListAuditResultsByCID(args)
|
values, err := (*audit.Client)(w).ListAuditResultsByCID(args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -83,12 +84,13 @@ func (w *ClientWrapper) ListAuditResultIDByNode(epoch uint64, cid *container.ID,
|
||||||
args.SetEpoch(int64(epoch))
|
args.SetEpoch(int64(epoch))
|
||||||
args.SetNodeKey(key)
|
args.SetNodeKey(key)
|
||||||
|
|
||||||
if v2 := cid.ToV2(); v2 == nil {
|
v2 := cid.ToV2()
|
||||||
|
if v2 == nil {
|
||||||
return nil, errUnsupported // use other major version if there any
|
return nil, errUnsupported // use other major version if there any
|
||||||
} else {
|
|
||||||
args.SetCID(v2.GetValue())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
args.SetCID(v2.GetValue())
|
||||||
|
|
||||||
values, err := (*audit.Client)(w).ListAuditResultsByNode(args)
|
values, err := (*audit.Client)(w).ListAuditResultsByNode(args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -55,12 +55,13 @@ func (w *Wrapper) Get(cid *container.ID) (*container.Container, error) {
|
||||||
|
|
||||||
args := client.GetArgs{}
|
args := client.GetArgs{}
|
||||||
|
|
||||||
if v2 := cid.ToV2(); v2 == nil {
|
v2 := cid.ToV2()
|
||||||
|
if v2 == nil {
|
||||||
return nil, errUnsupported // use other major version if there any
|
return nil, errUnsupported // use other major version if there any
|
||||||
} else {
|
|
||||||
args.SetCID(v2.GetValue())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
args.SetCID(v2.GetValue())
|
||||||
|
|
||||||
// ask RPC neo node to get serialized container
|
// ask RPC neo node to get serialized container
|
||||||
rpcAnswer, err := w.client.Get(args)
|
rpcAnswer, err := w.client.Get(args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -97,12 +98,13 @@ func (w *Wrapper) Delete(cid *container.ID, signature []byte) error {
|
||||||
args := client.DeleteArgs{}
|
args := client.DeleteArgs{}
|
||||||
args.SetSignature(signature)
|
args.SetSignature(signature)
|
||||||
|
|
||||||
if v2 := cid.ToV2(); v2 == nil {
|
v2 := cid.ToV2()
|
||||||
|
if v2 == nil {
|
||||||
return errUnsupported // use other major version if there any
|
return errUnsupported // use other major version if there any
|
||||||
} else {
|
|
||||||
args.SetCID(v2.GetValue())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
args.SetCID(v2.GetValue())
|
||||||
|
|
||||||
return w.client.Delete(args)
|
return w.client.Delete(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,13 @@ func (w *Wrapper) GetEACL(cid *containerSDK.ID) (*eacl.Table, []byte, error) {
|
||||||
|
|
||||||
args := client.EACLArgs{}
|
args := client.EACLArgs{}
|
||||||
|
|
||||||
if v2 := cid.ToV2(); v2 == nil {
|
v2 := cid.ToV2()
|
||||||
|
if v2 == nil {
|
||||||
return nil, nil, errUnsupported // use other major version if there any
|
return nil, nil, errUnsupported // use other major version if there any
|
||||||
} else {
|
|
||||||
args.SetCID(v2.GetValue())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
args.SetCID(v2.GetValue())
|
||||||
|
|
||||||
rpcAnswer, err := w.client.EACL(args)
|
rpcAnswer, err := w.client.EACL(args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
|
|
@ -489,9 +489,9 @@ func getContainerIDFromRequest(req interface{}) (id *container.ID, err error) {
|
||||||
objPart := v.GetBody().GetObjectPart()
|
objPart := v.GetBody().GetObjectPart()
|
||||||
if part, ok := objPart.(*object.PutObjectPartInit); ok {
|
if part, ok := objPart.(*object.PutObjectPartInit); ok {
|
||||||
return container.NewIDFromV2(part.GetHeader().GetContainerID()), nil
|
return container.NewIDFromV2(part.GetHeader().GetContainerID()), nil
|
||||||
} else {
|
|
||||||
return nil, errors.New("can't get cid in chunk")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nil, errors.New("can't get cid in chunk")
|
||||||
case *object.HeadRequest:
|
case *object.HeadRequest:
|
||||||
return container.NewIDFromV2(v.GetBody().GetAddress().GetContainerID()), nil
|
return container.NewIDFromV2(v.GetBody().GetAddress().GetContainerID()), nil
|
||||||
case *object.SearchRequest:
|
case *object.SearchRequest:
|
||||||
|
@ -543,16 +543,16 @@ func getObjectOwnerFromMessage(req interface{}) (id *owner.ID, err error) {
|
||||||
objPart := v.GetBody().GetObjectPart()
|
objPart := v.GetBody().GetObjectPart()
|
||||||
if part, ok := objPart.(*object.PutObjectPartInit); ok {
|
if part, ok := objPart.(*object.PutObjectPartInit); ok {
|
||||||
return owner.NewIDFromV2(part.GetHeader().GetOwnerID()), nil
|
return owner.NewIDFromV2(part.GetHeader().GetOwnerID()), nil
|
||||||
} else {
|
|
||||||
return nil, errors.New("can't get cid in chunk")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nil, errors.New("can't get cid in chunk")
|
||||||
case *object.GetResponse:
|
case *object.GetResponse:
|
||||||
objPart := v.GetBody().GetObjectPart()
|
objPart := v.GetBody().GetObjectPart()
|
||||||
if part, ok := objPart.(*object.GetObjectPartInit); ok {
|
if part, ok := objPart.(*object.GetObjectPartInit); ok {
|
||||||
return owner.NewIDFromV2(part.GetHeader().GetOwnerID()), nil
|
return owner.NewIDFromV2(part.GetHeader().GetOwnerID()), nil
|
||||||
} else {
|
|
||||||
return nil, errors.New("can't get cid in chunk")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nil, errors.New("can't get cid in chunk")
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("unsupported request type")
|
return nil, errors.New("unsupported request type")
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,13 +102,13 @@ func (c *clientWrapper) getObject(exec *execCtx) (*objectSDK.Object, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return payloadOnlyObject(data), nil
|
return payloadOnlyObject(data), nil
|
||||||
} else {
|
}
|
||||||
|
|
||||||
return c.client.GetObject(exec.context(),
|
return c.client.GetObject(exec.context(),
|
||||||
exec.remotePrm(),
|
exec.remotePrm(),
|
||||||
exec.callOptions()...,
|
exec.callOptions()...,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func (e *storageEngineWrapper) get(exec *execCtx) (*object.Object, error) {
|
func (e *storageEngineWrapper) get(exec *execCtx) (*object.Object, error) {
|
||||||
if exec.headOnly() {
|
if exec.headOnly() {
|
||||||
|
|
|
@ -136,7 +136,8 @@ func (p *Streamer) newCommonTarget(prm *PutInitPrm) transformer.ObjectTarget {
|
||||||
return &localTarget{
|
return &localTarget{
|
||||||
storage: p.localStore,
|
storage: p.localStore,
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
return &remoteTarget{
|
return &remoteTarget{
|
||||||
ctx: p.ctx,
|
ctx: p.ctx,
|
||||||
keyStorage: p.keyStorage,
|
keyStorage: p.keyStorage,
|
||||||
|
@ -145,7 +146,6 @@ func (p *Streamer) newCommonTarget(prm *PutInitPrm) transformer.ObjectTarget {
|
||||||
clientCache: p.clientCache,
|
clientCache: p.clientCache,
|
||||||
clientOpts: p.clientOpts,
|
clientOpts: p.clientOpts,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
fmt: p.fmtValidator,
|
fmt: p.fmtValidator,
|
||||||
log: p.log,
|
log: p.log,
|
||||||
|
|
|
@ -119,10 +119,10 @@ func traverseSplitChain(r HeadReceiver, addr *objectSDK.Address, h SplitMemberHa
|
||||||
if stop, err := traverseSplitChain(r, addr, func(member *object.Object, reverseDirection bool) (stop bool) {
|
if stop, err := traverseSplitChain(r, addr, func(member *object.Object, reverseDirection bool) (stop bool) {
|
||||||
if !reverseDirection {
|
if !reverseDirection {
|
||||||
return h(member, false)
|
return h(member, false)
|
||||||
} else {
|
}
|
||||||
|
|
||||||
reverseChain = append(reverseChain, member)
|
reverseChain = append(reverseChain, member)
|
||||||
return false
|
return false
|
||||||
}
|
|
||||||
}); err != nil || stop {
|
}); err != nil || stop {
|
||||||
return stop, err
|
return stop, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue