[#27] object: Resolve funlen linter warnings

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-05-03 13:58:42 +03:00
parent 63915bb7a5
commit 1cab39337e

View file

@ -292,103 +292,27 @@ func (h *Header) FromGRPCMessage(m grpc.Message) error {
var err error var err error
version := v.GetVersion() if err := h.fillVersion(v); err != nil {
if version == nil {
h.version = nil
} else {
if h.version == nil {
h.version = new(refs.Version)
}
err = h.version.FromGRPCMessage(version)
if err != nil {
return err return err
} }
} if err := h.fillPayloadHash(v); err != nil {
payloadHash := v.GetPayloadHash()
if payloadHash == nil {
h.payloadHash = nil
} else {
if h.payloadHash == nil {
h.payloadHash = new(refs.Checksum)
}
err = h.payloadHash.FromGRPCMessage(payloadHash)
if err != nil {
return err return err
} }
} if err := h.fillOwnerID(v); err != nil {
ownerID := v.GetOwnerId()
if ownerID == nil {
h.ownerID = nil
} else {
if h.ownerID == nil {
h.ownerID = new(refs.OwnerID)
}
err = h.ownerID.FromGRPCMessage(ownerID)
if err != nil {
return err return err
} }
} if err := h.fillHomomorphicHash(v); err != nil {
homoHash := v.GetHomomorphicHash()
if homoHash == nil {
h.homoHash = nil
} else {
if h.homoHash == nil {
h.homoHash = new(refs.Checksum)
}
err = h.homoHash.FromGRPCMessage(homoHash)
if err != nil {
return err return err
} }
} if err := h.fillContainerID(v); err != nil {
cid := v.GetContainerId()
if cid == nil {
h.cid = nil
} else {
if h.cid == nil {
h.cid = new(refs.ContainerID)
}
err = h.cid.FromGRPCMessage(cid)
if err != nil {
return err return err
} }
} if err := h.fillSessionToken(v); err != nil {
sessionToken := v.GetSessionToken()
if sessionToken == nil {
h.sessionToken = nil
} else {
if h.sessionToken == nil {
h.sessionToken = new(session.Token)
}
err = h.sessionToken.FromGRPCMessage(sessionToken)
if err != nil {
return err return err
} }
} if err := h.fillSplitHeader(v); err != nil {
split := v.GetSplit()
if split == nil {
h.split = nil
} else {
if h.split == nil {
h.split = new(SplitHeader)
}
err = h.split.FromGRPCMessage(split)
if err != nil {
return err return err
} }
}
h.attr, err = AttributesFromGRPC(v.GetAttributes()) h.attr, err = AttributesFromGRPC(v.GetAttributes())
if err != nil { if err != nil {
@ -402,6 +326,97 @@ func (h *Header) FromGRPCMessage(m grpc.Message) error {
return nil return nil
} }
func (h *Header) fillVersion(v *object.Header) error {
version := v.GetVersion()
if version == nil {
h.version = nil
return nil
}
if h.version == nil {
h.version = new(refs.Version)
}
return h.version.FromGRPCMessage(version)
}
func (h *Header) fillPayloadHash(v *object.Header) error {
payloadHash := v.GetPayloadHash()
if payloadHash == nil {
h.payloadHash = nil
return nil
}
if h.payloadHash == nil {
h.payloadHash = new(refs.Checksum)
}
return h.payloadHash.FromGRPCMessage(payloadHash)
}
func (h *Header) fillOwnerID(v *object.Header) error {
ownerID := v.GetOwnerId()
if ownerID == nil {
h.ownerID = nil
return nil
}
if h.ownerID == nil {
h.ownerID = new(refs.OwnerID)
}
return h.ownerID.FromGRPCMessage(ownerID)
}
func (h *Header) fillHomomorphicHash(v *object.Header) error {
homoHash := v.GetHomomorphicHash()
if homoHash == nil {
h.homoHash = nil
return nil
}
if h.homoHash == nil {
h.homoHash = new(refs.Checksum)
}
return h.homoHash.FromGRPCMessage(homoHash)
}
func (h *Header) fillContainerID(v *object.Header) error {
cid := v.GetContainerId()
if cid == nil {
h.cid = nil
return nil
}
if h.cid == nil {
h.cid = new(refs.ContainerID)
}
return h.cid.FromGRPCMessage(cid)
}
func (h *Header) fillSessionToken(v *object.Header) error {
sessionToken := v.GetSessionToken()
if sessionToken == nil {
h.sessionToken = nil
return nil
}
if h.sessionToken == nil {
h.sessionToken = new(session.Token)
}
return h.sessionToken.FromGRPCMessage(sessionToken)
}
func (h *Header) fillSplitHeader(v *object.Header) error {
split := v.GetSplit()
if split == nil {
h.split = nil
return nil
}
if h.split == nil {
h.split = new(SplitHeader)
}
return h.split.FromGRPCMessage(split)
}
func (h *HeaderWithSignature) ToGRPCMessage() grpc.Message { func (h *HeaderWithSignature) ToGRPCMessage() grpc.Message {
var m *object.HeaderWithSignature var m *object.HeaderWithSignature