From 182a3af9b8e665f4f33d6ef67f4525c7becf3f88 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Thu, 10 Sep 2020 13:01:31 +0300 Subject: [PATCH] [#139] v2/acl: Rename TargetInfo to Target Corresponds with proto definition. Signed-off-by: Alex Vanin --- v2/acl/convert.go | 8 ++++---- v2/acl/marshal.go | 4 ++-- v2/acl/marshal_test.go | 8 ++++---- v2/acl/types.go | 20 ++++++++++---------- v2/container/marshal_test.go | 4 ++-- v2/session/marshal_test.go | 4 ++-- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/v2/acl/convert.go b/v2/acl/convert.go index 79ebe5f..b28eba2 100644 --- a/v2/acl/convert.go +++ b/v2/acl/convert.go @@ -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])) diff --git a/v2/acl/marshal.go b/v2/acl/marshal.go index 3478b42..95b2e7d 100644 --- a/v2/acl/marshal.go +++ b/v2/acl/marshal.go @@ -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 } diff --git a/v2/acl/marshal_test.go b/v2/acl/marshal_test.go index 79b187b..ecaecc8 100644 --- a/v2/acl/marshal_test.go +++ b/v2/acl/marshal_test.go @@ -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}) } diff --git a/v2/acl/types.go b/v2/acl/types.go index 38a7044..83b7fd2 100644 --- a/v2/acl/types.go +++ b/v2/acl/types.go @@ -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 } diff --git a/v2/container/marshal_test.go b/v2/container/marshal_test.go index fba58f5..51eb5e7 100644 --- a/v2/container/marshal_test.go +++ b/v2/container/marshal_test.go @@ -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) diff --git a/v2/session/marshal_test.go b/v2/session/marshal_test.go index c2f4415..0f48735 100644 --- a/v2/session/marshal_test.go +++ b/v2/session/marshal_test.go @@ -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)