[#139] v2/acl: Rename TargetInfo to Target
Corresponds with proto definition. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
3c7c363002
commit
182a3af9b8
6 changed files with 24 additions and 24 deletions
|
@ -194,7 +194,7 @@ func HeaderFilterFromGRPCMessage(m *acl.EACLRecord_Filter) *HeaderFilter {
|
|||
}
|
||||
|
||||
// TargetToGRPCMessage converts unified role info struct into grpc struct.
|
||||
func TargetToGRPCMessage(t *TargetInfo) *acl.EACLRecord_Target {
|
||||
func TargetToGRPCMessage(t *Target) *acl.EACLRecord_Target {
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -211,12 +211,12 @@ func TargetToGRPCMessage(t *TargetInfo) *acl.EACLRecord_Target {
|
|||
}
|
||||
|
||||
// TargetInfoFromGRPCMessage converts grpc struct into unified role info struct.
|
||||
func TargetInfoFromGRPCMessage(m *acl.EACLRecord_Target) *TargetInfo {
|
||||
func TargetInfoFromGRPCMessage(m *acl.EACLRecord_Target) *Target {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
t := new(TargetInfo)
|
||||
t := new(Target)
|
||||
|
||||
t.SetRole(
|
||||
RoleFromGRPCField(m.GetRole()),
|
||||
|
@ -290,7 +290,7 @@ func RecordFromGRPCMessage(m *acl.EACLRecord) *Record {
|
|||
r.SetFilters(filters)
|
||||
|
||||
targetMsg := m.GetTargets()
|
||||
targets := make([]*TargetInfo, 0, len(targetMsg))
|
||||
targets := make([]*Target, 0, len(targetMsg))
|
||||
|
||||
for i := range targetMsg {
|
||||
targets = append(targets, TargetInfoFromGRPCMessage(targetMsg[i]))
|
||||
|
|
|
@ -224,7 +224,7 @@ func (f *HeaderFilter) StableSize() (size int) {
|
|||
|
||||
// StableMarshal marshals unified role info structure in a protobuf
|
||||
// compatible way without field order shuffle.
|
||||
func (t *TargetInfo) StableMarshal(buf []byte) ([]byte, error) {
|
||||
func (t *Target) StableMarshal(buf []byte) ([]byte, error) {
|
||||
if t == nil {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ func (t *TargetInfo) StableMarshal(buf []byte) ([]byte, error) {
|
|||
}
|
||||
|
||||
// StableSize of role info structure marshalled by StableMarshal function.
|
||||
func (t *TargetInfo) StableSize() (size int) {
|
||||
func (t *Target) StableSize() (size int) {
|
||||
if t == nil {
|
||||
return 0
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func generateTarget(u acl.Role, k int) *acl.TargetInfo {
|
||||
target := new(acl.TargetInfo)
|
||||
func generateTarget(u acl.Role, k int) *acl.Target {
|
||||
target := new(acl.Target)
|
||||
target.SetRole(u)
|
||||
|
||||
keys := make([][]byte, k)
|
||||
|
@ -44,7 +44,7 @@ func generateRecord(another bool) *acl.Record {
|
|||
|
||||
record.SetOperation(acl.OperationHead)
|
||||
record.SetAction(acl.ActionDeny)
|
||||
record.SetTargets([]*acl.TargetInfo{t1})
|
||||
record.SetTargets([]*acl.Target{t1})
|
||||
record.SetFilters([]*acl.HeaderFilter{f1})
|
||||
default:
|
||||
t1 := generateTarget(acl.RoleUser, 2)
|
||||
|
@ -54,7 +54,7 @@ func generateRecord(another bool) *acl.Record {
|
|||
|
||||
record.SetOperation(acl.OperationPut)
|
||||
record.SetAction(acl.ActionAllow)
|
||||
record.SetTargets([]*acl.TargetInfo{t1, t2})
|
||||
record.SetTargets([]*acl.Target{t1, t2})
|
||||
record.SetFilters([]*acl.HeaderFilter{f1, f2})
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ type HeaderFilter struct {
|
|||
name, value string
|
||||
}
|
||||
|
||||
// TargetInfo is a unified structure of TargetInfo
|
||||
// Target is a unified structure of Target
|
||||
// message from proto definition.
|
||||
type TargetInfo struct {
|
||||
type Target struct {
|
||||
role Role
|
||||
|
||||
keys [][]byte
|
||||
|
@ -29,7 +29,7 @@ type Record struct {
|
|||
|
||||
filters []*HeaderFilter
|
||||
|
||||
targets []*TargetInfo
|
||||
targets []*Target
|
||||
}
|
||||
|
||||
// Table is a unified structure of EACLTable
|
||||
|
@ -60,7 +60,7 @@ type BearerToken struct {
|
|||
sig *refs.Signature
|
||||
}
|
||||
|
||||
// TargetInfo is a unified enum of MatchType enum from proto definition.
|
||||
// Target is a unified enum of MatchType enum from proto definition.
|
||||
type MatchType uint32
|
||||
|
||||
// HeaderType is a unified enum of HeaderType enum from proto definition.
|
||||
|
@ -167,7 +167,7 @@ func (f *HeaderFilter) SetValue(v string) {
|
|||
}
|
||||
}
|
||||
|
||||
func (t *TargetInfo) GetRole() Role {
|
||||
func (t *Target) GetRole() Role {
|
||||
if t != nil {
|
||||
return t.role
|
||||
}
|
||||
|
@ -175,13 +175,13 @@ func (t *TargetInfo) GetRole() Role {
|
|||
return RoleUnknown
|
||||
}
|
||||
|
||||
func (t *TargetInfo) SetRole(v Role) {
|
||||
func (t *Target) SetRole(v Role) {
|
||||
if t != nil {
|
||||
t.role = v
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TargetInfo) GetKeyList() [][]byte {
|
||||
func (t *Target) GetKeyList() [][]byte {
|
||||
if t != nil {
|
||||
return t.keys
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ func (t *TargetInfo) GetKeyList() [][]byte {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (t *TargetInfo) SetKeyList(v [][]byte) {
|
||||
func (t *Target) SetKeyList(v [][]byte) {
|
||||
if t != nil {
|
||||
t.keys = v
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ func (r *Record) SetFilters(v []*HeaderFilter) {
|
|||
}
|
||||
}
|
||||
|
||||
func (r *Record) GetTargets() []*TargetInfo {
|
||||
func (r *Record) GetTargets() []*Target {
|
||||
if r != nil {
|
||||
return r.targets
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ func (r *Record) GetTargets() []*TargetInfo {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r *Record) SetTargets(v []*TargetInfo) {
|
||||
func (r *Record) SetTargets(v []*Target) {
|
||||
if r != nil {
|
||||
r.targets = v
|
||||
}
|
||||
|
|
|
@ -350,7 +350,7 @@ func generateListResponseBody(n int) *container.ListResponseBody {
|
|||
}
|
||||
|
||||
func generateEACL(n int, k, v string) *acl.Table {
|
||||
target := new(acl.TargetInfo)
|
||||
target := new(acl.Target)
|
||||
target.SetRole(acl.RoleUser)
|
||||
|
||||
keys := make([][]byte, n)
|
||||
|
@ -369,7 +369,7 @@ func generateEACL(n int, k, v string) *acl.Table {
|
|||
record := new(acl.Record)
|
||||
record.SetOperation(acl.OperationHead)
|
||||
record.SetAction(acl.ActionDeny)
|
||||
record.SetTargets([]*acl.TargetInfo{target})
|
||||
record.SetTargets([]*acl.Target{target})
|
||||
record.SetFilters([]*acl.HeaderFilter{filter})
|
||||
|
||||
table := new(acl.Table)
|
||||
|
|
|
@ -281,7 +281,7 @@ func generateObjectCtx(id string) *session.ObjectSessionContext {
|
|||
}
|
||||
|
||||
func generateEACL(n int, k, v string) *acl.Table {
|
||||
target := new(acl.TargetInfo)
|
||||
target := new(acl.Target)
|
||||
target.SetRole(acl.RoleUser)
|
||||
|
||||
keys := make([][]byte, n)
|
||||
|
@ -300,7 +300,7 @@ func generateEACL(n int, k, v string) *acl.Table {
|
|||
record := new(acl.Record)
|
||||
record.SetOperation(acl.OperationHead)
|
||||
record.SetAction(acl.ActionDeny)
|
||||
record.SetTargets([]*acl.TargetInfo{target})
|
||||
record.SetTargets([]*acl.Target{target})
|
||||
record.SetFilters([]*acl.HeaderFilter{filter})
|
||||
|
||||
table := new(acl.Table)
|
||||
|
|
Loading…
Reference in a new issue