Fix linter remarks

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-02-25 10:36:46 +03:00 committed by LeL
parent 99370889d1
commit fd3bf4a56b
10 changed files with 67 additions and 54 deletions

View file

@ -432,7 +432,7 @@ func (r *GetResponseBody) FromGRPCMessage(m grpc.Message) error {
r.token = nil r.token = nil
} else { } else {
if r.token == nil { if r.token == nil {
r.token = new(session.SessionToken) r.token = new(session.Token)
} }
err = r.token.FromGRPCMessage(token) err = r.token.FromGRPCMessage(token)
@ -1026,7 +1026,7 @@ func (r *GetExtendedACLResponseBody) FromGRPCMessage(m grpc.Message) error {
r.token = nil r.token = nil
} else { } else {
if r.token == nil { if r.token == nil {
r.token = new(session.SessionToken) r.token = new(session.Token)
} }
err = r.token.FromGRPCMessage(token) err = r.token.FromGRPCMessage(token)

View file

@ -59,7 +59,7 @@ type GetRequest struct {
type GetResponseBody struct { type GetResponseBody struct {
cnr *Container cnr *Container
token *session.SessionToken token *session.Token
sig *refs.Signature sig *refs.Signature
} }
@ -145,7 +145,7 @@ type GetExtendedACLResponseBody struct {
sig *refs.Signature sig *refs.Signature
token *session.SessionToken token *session.Token
} }
type GetExtendedACLResponse struct { type GetExtendedACLResponse struct {
@ -406,7 +406,7 @@ func (r *GetResponseBody) SetContainer(v *Container) {
// GetSessionToken returns token of the session within which requested // GetSessionToken returns token of the session within which requested
// container was created. // container was created.
func (r *GetResponseBody) GetSessionToken() *session.SessionToken { func (r *GetResponseBody) GetSessionToken() *session.Token {
if r != nil { if r != nil {
return r.token return r.token
} }
@ -416,7 +416,7 @@ func (r *GetResponseBody) GetSessionToken() *session.SessionToken {
// SetSessionToken sets token of the session within which requested // SetSessionToken sets token of the session within which requested
// container was created. // container was created.
func (r *GetResponseBody) SetSessionToken(v *session.SessionToken) { func (r *GetResponseBody) SetSessionToken(v *session.Token) {
if r != nil { if r != nil {
r.token = v r.token = v
} }
@ -678,7 +678,7 @@ func (r *GetExtendedACLResponseBody) SetSignature(v *refs.Signature) {
// GetSessionToken returns token of the session within which requested // GetSessionToken returns token of the session within which requested
// eACL table was set. // eACL table was set.
func (r *GetExtendedACLResponseBody) GetSessionToken() *session.SessionToken { func (r *GetExtendedACLResponseBody) GetSessionToken() *session.Token {
if r != nil { if r != nil {
return r.token return r.token
} }
@ -688,7 +688,7 @@ func (r *GetExtendedACLResponseBody) GetSessionToken() *session.SessionToken {
// SetSessionToken sets token of the session within which requested // SetSessionToken sets token of the session within which requested
// eACL table was set. // eACL table was set.
func (r *GetExtendedACLResponseBody) SetSessionToken(v *session.SessionToken) { func (r *GetExtendedACLResponseBody) SetSessionToken(v *session.Token) {
if r != nil { if r != nil {
r.token = v r.token = v
} }

View file

@ -373,7 +373,7 @@ func (h *Header) FromGRPCMessage(m grpc.Message) error {
h.sessionToken = nil h.sessionToken = nil
} else { } else {
if h.sessionToken == nil { if h.sessionToken == nil {
h.sessionToken = new(session.SessionToken) h.sessionToken = new(session.Token)
} }
err = h.sessionToken.FromGRPCMessage(sessionToken) err = h.sessionToken.FromGRPCMessage(sessionToken)

View file

@ -54,7 +54,7 @@ type Header struct {
typ Type typ Type
sessionToken *session.SessionToken sessionToken *session.Token
attr []*Attribute attr []*Attribute
@ -640,7 +640,7 @@ func (h *Header) SetHomomorphicHash(v *refs.Checksum) {
} }
} }
func (h *Header) GetSessionToken() *session.SessionToken { func (h *Header) GetSessionToken() *session.Token {
if h != nil { if h != nil {
return h.sessionToken return h.sessionToken
} }
@ -648,7 +648,7 @@ func (h *Header) GetSessionToken() *session.SessionToken {
return nil return nil
} }
func (h *Header) SetSessionToken(v *session.SessionToken) { func (h *Header) SetSessionToken(v *session.Token) {
if h != nil { if h != nil {
h.sessionToken = v h.sessionToken = v
} }

View file

@ -33,6 +33,7 @@ type ChecksumType uint32
type SignatureScheme uint32 type SignatureScheme uint32
//nolint:revive
const ( const (
UnspecifiedScheme SignatureScheme = iota UnspecifiedScheme SignatureScheme = iota
ECDSA_SHA512 ECDSA_SHA512

View file

@ -242,7 +242,7 @@ func XHeadersFromGRPC(xs []*session.XHeader) (res []*XHeader, err error) {
return return
} }
func (t *SessionToken) ToGRPCMessage() grpc.Message { func (t *Token) ToGRPCMessage() grpc.Message {
var m *session.SessionToken var m *session.SessionToken
if t != nil { if t != nil {
@ -255,7 +255,7 @@ func (t *SessionToken) ToGRPCMessage() grpc.Message {
return m return m
} }
func (t *SessionToken) FromGRPCMessage(m grpc.Message) error { func (t *Token) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*session.SessionToken) v, ok := m.(*session.SessionToken)
if !ok { if !ok {
return message.NewUnexpectedMessageType(m, v) return message.NewUnexpectedMessageType(m, v)
@ -268,7 +268,7 @@ func (t *SessionToken) FromGRPCMessage(m grpc.Message) error {
t.body = nil t.body = nil
} else { } else {
if t.body == nil { if t.body == nil {
t.body = new(SessionTokenBody) t.body = new(TokenBody)
} }
err = t.body.FromGRPCMessage(body) err = t.body.FromGRPCMessage(body)
@ -422,7 +422,7 @@ func (r *RequestMetaHeader) FromGRPCMessage(m grpc.Message) error {
r.sessionToken = nil r.sessionToken = nil
} else { } else {
if r.sessionToken == nil { if r.sessionToken == nil {
r.sessionToken = new(SessionToken) r.sessionToken = new(Token)
} }
err = r.sessionToken.FromGRPCMessage(sessionToken) err = r.sessionToken.FromGRPCMessage(sessionToken)
@ -713,7 +713,7 @@ func (c *ObjectSessionContext) FromGRPCMessage(m grpc.Message) error {
return nil return nil
} }
func (t *SessionTokenBody) ToGRPCMessage() grpc.Message { func (t *TokenBody) ToGRPCMessage() grpc.Message {
var m *session.SessionToken_Body var m *session.SessionToken_Body
if t != nil { if t != nil {
@ -739,7 +739,7 @@ func (t *SessionTokenBody) ToGRPCMessage() grpc.Message {
return m return m
} }
func (t *SessionTokenBody) FromGRPCMessage(m grpc.Message) error { func (t *TokenBody) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*session.SessionToken_Body) v, ok := m.(*session.SessionToken_Body)
if !ok { if !ok {
return message.NewUnexpectedMessageType(m, v) return message.NewUnexpectedMessageType(m, v)

View file

@ -22,11 +22,11 @@ func (l *TokenLifetime) UnmarshalJSON(data []byte) error {
return message.UnmarshalJSON(l, data, new(session.SessionToken_Body_TokenLifetime)) return message.UnmarshalJSON(l, data, new(session.SessionToken_Body_TokenLifetime))
} }
func (t *SessionTokenBody) MarshalJSON() ([]byte, error) { func (t *TokenBody) MarshalJSON() ([]byte, error) {
return message.MarshalJSON(t) return message.MarshalJSON(t)
} }
func (t *SessionTokenBody) UnmarshalJSON(data []byte) error { func (t *TokenBody) UnmarshalJSON(data []byte) error {
msg := new(session.SessionToken_Body) msg := new(session.SessionToken_Body)
if err := protojson.Unmarshal(data, msg); err != nil { if err := protojson.Unmarshal(data, msg); err != nil {
@ -36,11 +36,11 @@ func (t *SessionTokenBody) UnmarshalJSON(data []byte) error {
return t.FromGRPCMessage(msg) return t.FromGRPCMessage(msg)
} }
func (t *SessionToken) MarshalJSON() ([]byte, error) { func (t *Token) MarshalJSON() ([]byte, error) {
return message.MarshalJSON(t) return message.MarshalJSON(t)
} }
func (t *SessionToken) UnmarshalJSON(data []byte) error { func (t *Token) UnmarshalJSON(data []byte) error {
msg := new(session.SessionToken) msg := new(session.SessionToken)
if err := protojson.Unmarshal(data, msg); err != nil { if err := protojson.Unmarshal(data, msg); err != nil {

View file

@ -363,7 +363,7 @@ func (x *ContainerSessionContext) Unmarshal(data []byte) error {
return message.Unmarshal(x, data, new(session.ContainerSessionContext)) return message.Unmarshal(x, data, new(session.ContainerSessionContext))
} }
func (t *SessionTokenBody) StableMarshal(buf []byte) ([]byte, error) { func (t *TokenBody) StableMarshal(buf []byte) ([]byte, error) {
if t == nil { if t == nil {
return []byte{}, nil return []byte{}, nil
} }
@ -425,7 +425,7 @@ func (t *SessionTokenBody) StableMarshal(buf []byte) ([]byte, error) {
return buf, nil return buf, nil
} }
func (t *SessionTokenBody) StableSize() (size int) { func (t *TokenBody) StableSize() (size int) {
if t == nil { if t == nil {
return 0 return 0
} }
@ -449,7 +449,7 @@ func (t *SessionTokenBody) StableSize() (size int) {
return size return size
} }
func (t *SessionTokenBody) Unmarshal(data []byte) error { func (t *TokenBody) Unmarshal(data []byte) error {
m := new(session.SessionToken_Body) m := new(session.SessionToken_Body)
if err := goproto.Unmarshal(data, m); err != nil { if err := goproto.Unmarshal(data, m); err != nil {
return err return err
@ -458,7 +458,7 @@ func (t *SessionTokenBody) Unmarshal(data []byte) error {
return t.FromGRPCMessage(m) return t.FromGRPCMessage(m)
} }
func (t *SessionToken) StableMarshal(buf []byte) ([]byte, error) { func (t *Token) StableMarshal(buf []byte) ([]byte, error) {
if t == nil { if t == nil {
return []byte{}, nil return []byte{}, nil
} }
@ -487,7 +487,7 @@ func (t *SessionToken) StableMarshal(buf []byte) ([]byte, error) {
return buf, nil return buf, nil
} }
func (t *SessionToken) StableSize() (size int) { func (t *Token) StableSize() (size int) {
if t == nil { if t == nil {
return 0 return 0
} }
@ -498,7 +498,7 @@ func (t *SessionToken) StableSize() (size int) {
return size return size
} }
func (t *SessionToken) Unmarshal(data []byte) error { func (t *Token) Unmarshal(data []byte) error {
m := new(session.SessionToken) m := new(session.SessionToken)
if err := goproto.Unmarshal(data, m); err != nil { if err := goproto.Unmarshal(data, m); err != nil {
return err return err

View file

@ -145,8 +145,8 @@ func generateRequestMetaHeader(empty, withOrigin bool) *session.RequestMetaHeade
return m return m
} }
func GenerateSessionToken(empty bool) *session.SessionToken { func GenerateSessionToken(empty bool) *session.Token {
m := new(session.SessionToken) m := new(session.Token)
if !empty { if !empty {
m.SetBody(GenerateSessionTokenBody(false)) m.SetBody(GenerateSessionTokenBody(false))
@ -157,8 +157,8 @@ func GenerateSessionToken(empty bool) *session.SessionToken {
return m return m
} }
func GenerateSessionTokenBody(empty bool) *session.SessionTokenBody { func GenerateSessionTokenBody(empty bool) *session.TokenBody {
m := new(session.SessionTokenBody) m := new(session.TokenBody)
if !empty { if !empty {
m.SetID([]byte{1}) m.SetID([]byte{1})

View file

@ -46,11 +46,15 @@ type ObjectSessionContext struct {
addr *refs.Address addr *refs.Address
} }
type SessionTokenContext interface { type TokenContext interface {
sessionTokenContext() sessionTokenContext()
} }
type SessionTokenBody struct { // Deprecated: use TokenContext instead.
//nolint:revive
type SessionTokenContext = TokenContext
type TokenBody struct {
id []byte id []byte
ownerID *refs.OwnerID ownerID *refs.OwnerID
@ -59,15 +63,23 @@ type SessionTokenBody struct {
sessionKey []byte sessionKey []byte
ctx SessionTokenContext ctx TokenContext
} }
type SessionToken struct { // Deprecated: use TokenBody instead.
body *SessionTokenBody //nolint:revive
type SessionTokenBody = TokenBody
type Token struct {
body *TokenBody
sig *refs.Signature sig *refs.Signature
} }
// Deprecated: use Token instead.
//nolint:revive
type SessionToken = Token
type RequestVerificationHeader struct { type RequestVerificationHeader struct {
bodySig, metaSig, originSig *refs.Signature bodySig, metaSig, originSig *refs.Signature
@ -83,7 +95,7 @@ type RequestMetaHeader struct {
xHeaders []*XHeader xHeaders []*XHeader
sessionToken *SessionToken sessionToken *Token
bearerToken *acl.BearerToken bearerToken *acl.BearerToken
@ -403,7 +415,7 @@ func (r *RequestMetaHeader) SetXHeaders(v []*XHeader) {
} }
} }
func (r *RequestMetaHeader) GetSessionToken() *SessionToken { func (r *RequestMetaHeader) GetSessionToken() *Token {
if r != nil { if r != nil {
return r.sessionToken return r.sessionToken
} }
@ -411,7 +423,7 @@ func (r *RequestMetaHeader) GetSessionToken() *SessionToken {
return nil return nil
} }
func (r *RequestMetaHeader) SetSessionToken(v *SessionToken) { func (r *RequestMetaHeader) SetSessionToken(v *Token) {
if r != nil { if r != nil {
r.sessionToken = v r.sessionToken = v
} }
@ -692,7 +704,7 @@ func (c *ObjectSessionContext) SetAddress(v *refs.Address) {
} }
} }
func (t *SessionTokenBody) GetID() []byte { func (t *TokenBody) GetID() []byte {
if t != nil { if t != nil {
return t.id return t.id
} }
@ -700,13 +712,13 @@ func (t *SessionTokenBody) GetID() []byte {
return nil return nil
} }
func (t *SessionTokenBody) SetID(v []byte) { func (t *TokenBody) SetID(v []byte) {
if t != nil { if t != nil {
t.id = v t.id = v
} }
} }
func (t *SessionTokenBody) GetOwnerID() *refs.OwnerID { func (t *TokenBody) GetOwnerID() *refs.OwnerID {
if t != nil { if t != nil {
return t.ownerID return t.ownerID
} }
@ -714,13 +726,13 @@ func (t *SessionTokenBody) GetOwnerID() *refs.OwnerID {
return nil return nil
} }
func (t *SessionTokenBody) SetOwnerID(v *refs.OwnerID) { func (t *TokenBody) SetOwnerID(v *refs.OwnerID) {
if t != nil { if t != nil {
t.ownerID = v t.ownerID = v
} }
} }
func (t *SessionTokenBody) GetLifetime() *TokenLifetime { func (t *TokenBody) GetLifetime() *TokenLifetime {
if t != nil { if t != nil {
return t.lifetime return t.lifetime
} }
@ -728,13 +740,13 @@ func (t *SessionTokenBody) GetLifetime() *TokenLifetime {
return nil return nil
} }
func (t *SessionTokenBody) SetLifetime(v *TokenLifetime) { func (t *TokenBody) SetLifetime(v *TokenLifetime) {
if t != nil { if t != nil {
t.lifetime = v t.lifetime = v
} }
} }
func (t *SessionTokenBody) GetSessionKey() []byte { func (t *TokenBody) GetSessionKey() []byte {
if t != nil { if t != nil {
return t.sessionKey return t.sessionKey
} }
@ -742,13 +754,13 @@ func (t *SessionTokenBody) GetSessionKey() []byte {
return nil return nil
} }
func (t *SessionTokenBody) SetSessionKey(v []byte) { func (t *TokenBody) SetSessionKey(v []byte) {
if t != nil { if t != nil {
t.sessionKey = v t.sessionKey = v
} }
} }
func (t *SessionTokenBody) GetContext() SessionTokenContext { func (t *TokenBody) GetContext() TokenContext {
if t != nil { if t != nil {
return t.ctx return t.ctx
} }
@ -756,13 +768,13 @@ func (t *SessionTokenBody) GetContext() SessionTokenContext {
return nil return nil
} }
func (t *SessionTokenBody) SetContext(v SessionTokenContext) { func (t *TokenBody) SetContext(v TokenContext) {
if t != nil { if t != nil {
t.ctx = v t.ctx = v
} }
} }
func (t *SessionToken) GetBody() *SessionTokenBody { func (t *Token) GetBody() *TokenBody {
if t != nil { if t != nil {
return t.body return t.body
} }
@ -770,13 +782,13 @@ func (t *SessionToken) GetBody() *SessionTokenBody {
return nil return nil
} }
func (t *SessionToken) SetBody(v *SessionTokenBody) { func (t *Token) SetBody(v *TokenBody) {
if t != nil { if t != nil {
t.body = v t.body = v
} }
} }
func (t *SessionToken) GetSignature() *refs.Signature { func (t *Token) GetSignature() *refs.Signature {
if t != nil { if t != nil {
return t.sig return t.sig
} }
@ -784,7 +796,7 @@ func (t *SessionToken) GetSignature() *refs.Signature {
return nil return nil
} }
func (t *SessionToken) SetSignature(v *refs.Signature) { func (t *Token) SetSignature(v *refs.Signature) {
if t != nil { if t != nil {
t.sig = v t.sig = v
} }