diff --git a/pkg/acl/eacl/filter.go b/pkg/acl/eacl/filter.go index 8ea8537b..29e8128d 100644 --- a/pkg/acl/eacl/filter.go +++ b/pkg/acl/eacl/filter.go @@ -8,7 +8,7 @@ import ( // header means that request should be processed according to EACL action. type Filter struct { from FilterHeaderType - name string + key string matcher Match value string } @@ -21,8 +21,8 @@ func (a Filter) Matcher() Match { return a.matcher } -func (a Filter) Name() string { - return a.name +func (a Filter) Key() string { + return a.key } func (a Filter) From() FilterHeaderType { @@ -32,7 +32,7 @@ func (a Filter) From() FilterHeaderType { func (a *Filter) ToV2() *v2acl.HeaderFilter { filter := new(v2acl.HeaderFilter) filter.SetValue(a.value) - filter.SetName(a.name) + filter.SetKey(a.key) filter.SetMatchType(a.matcher.ToV2()) filter.SetHeaderType(a.from.ToV2()) @@ -48,7 +48,7 @@ func NewFilterFromV2(filter *v2acl.HeaderFilter) *Filter { f.from = FilterHeaderTypeFromV2(filter.GetHeaderType()) f.matcher = MatchFromV2(filter.GetMatchType()) - f.name = filter.GetName() + f.key = filter.GetKey() f.value = filter.GetValue() return f diff --git a/pkg/acl/eacl/filter_test.go b/pkg/acl/eacl/filter_test.go index a38d392d..0fa874d1 100644 --- a/pkg/acl/eacl/filter_test.go +++ b/pkg/acl/eacl/filter_test.go @@ -10,7 +10,7 @@ import ( func TestFilter(t *testing.T) { filter := &Filter{ from: HeaderFromObject, - name: "some name", + key: "some name", matcher: MatchStringEqual, value: "200", } @@ -19,7 +19,7 @@ func TestFilter(t *testing.T) { require.NotNil(t, v2) require.Equal(t, v2acl.HeaderTypeObject, v2.GetHeaderType()) require.EqualValues(t, v2acl.MatchTypeStringEqual, v2.GetMatchType()) - require.Equal(t, filter.Name(), v2.GetName()) + require.Equal(t, filter.Key(), v2.GetKey()) require.Equal(t, filter.Value(), v2.GetValue()) newFilter := NewFilterFromV2(v2) diff --git a/pkg/acl/eacl/record.go b/pkg/acl/eacl/record.go index 9c46d2f5..f0792b70 100644 --- a/pkg/acl/eacl/record.go +++ b/pkg/acl/eacl/record.go @@ -57,7 +57,7 @@ func (r *Record) AddTarget(role Role, keys ...ecdsa.PublicKey) { func (r *Record) AddFilter(from FilterHeaderType, matcher Match, name, value string) { filter := Filter{ from: from, - name: name, + key: name, matcher: matcher, value: value, } diff --git a/pkg/acl/eacl/record_test.go b/pkg/acl/eacl/record_test.go index c91042c7..428794a1 100644 --- a/pkg/acl/eacl/record_test.go +++ b/pkg/acl/eacl/record_test.go @@ -62,13 +62,13 @@ func TestRecord_AddFilter(t *testing.T) { filters := []Filter{ { from: HeaderFromObject, - name: "some name", + key: "some name", matcher: MatchStringEqual, value: "ContainerID", }, { from: HeaderFromRequest, - name: "X-Header-Name", + key: "X-Header-Name", matcher: MatchStringNotEqual, value: "X-Header-Value", }, @@ -76,7 +76,7 @@ func TestRecord_AddFilter(t *testing.T) { r := NewRecord() for _, filter := range filters { - r.AddFilter(filter.From(), filter.Matcher(), filter.Name(), filter.Value()) + r.AddFilter(filter.From(), filter.Matcher(), filter.Key(), filter.Value()) } require.Equal(t, filters, r.Filters()) diff --git a/pkg/object/search.go b/pkg/object/search.go index e17d35b8..2f1571da 100644 --- a/pkg/object/search.go +++ b/pkg/object/search.go @@ -64,7 +64,7 @@ func NewSearchFiltersFromV2(v2 []*v2object.SearchFilter) SearchFilters { } filters = append(filters, SearchFilter{ - header: v2[i].GetName(), + header: v2[i].GetKey(), value: v2[i].GetValue(), op: SearchMatchFromV2(v2[i].GetMatchType()), }) @@ -89,7 +89,7 @@ func (f SearchFilters) ToV2() []*v2object.SearchFilter { result := make([]*v2object.SearchFilter, 0, len(f)) for i := range f { v2 := new(v2object.SearchFilter) - v2.SetName(f[i].header) + v2.SetKey(f[i].header) v2.SetValue(f[i].value) v2.SetMatchType(f[i].op.ToV2()) diff --git a/v2/acl/convert.go b/v2/acl/convert.go index 0a005fe5..462baa78 100644 --- a/v2/acl/convert.go +++ b/v2/acl/convert.go @@ -165,8 +165,8 @@ func HeaderFilterToGRPCMessage(f *HeaderFilter) *acl.EACLRecord_Filter { MatchTypeToGRPCField(f.GetMatchType()), ) - m.SetHeaderName(f.GetName()) - m.SetHeaderVal(f.GetValue()) + m.SetKey(f.GetKey()) + m.SetValue(f.GetValue()) return m } @@ -187,8 +187,8 @@ func HeaderFilterFromGRPCMessage(m *acl.EACLRecord_Filter) *HeaderFilter { MatchTypeFromGRPCField(m.GetMatchType()), ) - f.SetName(m.GetHeaderName()) - f.SetValue(m.GetHeaderVal()) + f.SetKey(m.GetKey()) + f.SetValue(m.GetValue()) return f } diff --git a/v2/acl/grpc/types.go b/v2/acl/grpc/types.go index 341b760b..bfb28ed5 100644 --- a/v2/acl/grpc/types.go +++ b/v2/acl/grpc/types.go @@ -67,17 +67,17 @@ func (m *EACLRecord_Filter) SetMatchType(v MatchType) { } } -// SetHeaderName sets header name of the eACL filter. -func (m *EACLRecord_Filter) SetHeaderName(v string) { +// SetKey sets key of the eACL filter. +func (m *EACLRecord_Filter) SetKey(v string) { if m != nil { - m.HeaderName = v + m.Key = v } } -// SetHeaderVal sets header value of the eACL filter. -func (m *EACLRecord_Filter) SetHeaderVal(v string) { +// SetValue sets value of the eACL filter. +func (m *EACLRecord_Filter) SetValue(v string) { if m != nil { - m.HeaderVal = v + m.Value = v } } diff --git a/v2/acl/marshal.go b/v2/acl/marshal.go index 95b2e7d1..a87bfc8e 100644 --- a/v2/acl/marshal.go +++ b/v2/acl/marshal.go @@ -193,7 +193,7 @@ func (f *HeaderFilter) StableMarshal(buf []byte) ([]byte, error) { offset += n - n, err = proto.StringMarshal(filterNameField, buf[offset:], f.name) + n, err = proto.StringMarshal(filterNameField, buf[offset:], f.key) if err != nil { return nil, err } @@ -216,7 +216,7 @@ func (f *HeaderFilter) StableSize() (size int) { size += proto.EnumSize(filterHeaderTypeField, int32(f.hdrType)) size += proto.EnumSize(filterMatchTypeField, int32(f.matchType)) - size += proto.StringSize(filterNameField, f.name) + size += proto.StringSize(filterNameField, f.key) size += proto.StringSize(filterValueField, f.value) return size diff --git a/v2/acl/marshal_test.go b/v2/acl/marshal_test.go index 70f3a818..4727a2fe 100644 --- a/v2/acl/marshal_test.go +++ b/v2/acl/marshal_test.go @@ -29,7 +29,7 @@ func generateFilter(t acl.HeaderType, k, v string) *acl.HeaderFilter { filter := new(acl.HeaderFilter) filter.SetHeaderType(t) filter.SetMatchType(acl.MatchTypeStringEqual) - filter.SetName(k) + filter.SetKey(k) filter.SetValue(v) return filter @@ -122,7 +122,7 @@ func TestHeaderFilter_StableMarshal(t *testing.T) { t.Run("non empty", func(t *testing.T) { filterFrom.SetHeaderType(acl.HeaderTypeObject) filterFrom.SetMatchType(acl.MatchTypeStringEqual) - filterFrom.SetName("Hello") + filterFrom.SetKey("Hello") filterFrom.SetValue("World") wire, err := filterFrom.StableMarshal(nil) diff --git a/v2/acl/types.go b/v2/acl/types.go index e5ed3a20..f7775319 100644 --- a/v2/acl/types.go +++ b/v2/acl/types.go @@ -9,7 +9,7 @@ type HeaderFilter struct { matchType MatchType - name, value string + key, value string } // Target is a unified structure of Target @@ -139,17 +139,17 @@ func (f *HeaderFilter) SetMatchType(v MatchType) { } } -func (f *HeaderFilter) GetName() string { +func (f *HeaderFilter) GetKey() string { if f != nil { - return f.name + return f.key } return "" } -func (f *HeaderFilter) SetName(v string) { +func (f *HeaderFilter) SetKey(v string) { if f != nil { - f.name = v + f.key = v } } diff --git a/v2/container/marshal_test.go b/v2/container/marshal_test.go index 5a2668cd..6bbab9c2 100644 --- a/v2/container/marshal_test.go +++ b/v2/container/marshal_test.go @@ -364,7 +364,7 @@ func generateEACL(n int, k, v string) *acl.Table { filter := new(acl.HeaderFilter) filter.SetHeaderType(acl.HeaderTypeObject) filter.SetMatchType(acl.MatchTypeStringEqual) - filter.SetName(k) + filter.SetKey(k) filter.SetValue(v) record := new(acl.Record) diff --git a/v2/object/convert.go b/v2/object/convert.go index a18d43f4..51a2cd83 100644 --- a/v2/object/convert.go +++ b/v2/object/convert.go @@ -1118,7 +1118,7 @@ func SearchFilterToGRPCMessage(f *SearchFilter) *object.SearchRequest_Body_Filte MatchTypeToGRPCField(f.GetMatchType()), ) - m.SetName(f.GetName()) + m.SetKey(f.GetKey()) m.SetValue(f.GetValue()) @@ -1136,7 +1136,7 @@ func SearchFilterFromGRPCMessage(m *object.SearchRequest_Body_Filter) *SearchFil MatchTypeFromGRPCField(m.GetMatchType()), ) - f.SetName(m.GetName()) + f.SetKey(m.GetKey()) f.SetValue(m.GetValue()) diff --git a/v2/object/grpc/service.go b/v2/object/grpc/service.go index 025af1c9..aefa5b4c 100644 --- a/v2/object/grpc/service.go +++ b/v2/object/grpc/service.go @@ -402,10 +402,10 @@ func (m *SearchRequest_Body_Filter) SetMatchType(v MatchType) { } } -// SetName sets name of the filtering header. -func (m *SearchRequest_Body_Filter) SetName(v string) { +// SetKey sets key to the filtering header. +func (m *SearchRequest_Body_Filter) SetKey(v string) { if m != nil { - m.Name = v + m.Key = v } } diff --git a/v2/object/marshal.go b/v2/object/marshal.go index a79e454f..43d4749b 100644 --- a/v2/object/marshal.go +++ b/v2/object/marshal.go @@ -937,7 +937,7 @@ func (f *SearchFilter) StableMarshal(buf []byte) ([]byte, error) { offset += n - n, err = proto.StringMarshal(searchFilterNameField, buf[offset:], f.name) + n, err = proto.StringMarshal(searchFilterNameField, buf[offset:], f.key) if err != nil { return nil, err } @@ -958,7 +958,7 @@ func (f *SearchFilter) StableSize() (size int) { } size += proto.EnumSize(searchFilterMatchField, int32(f.matchType)) - size += proto.StringSize(searchFilterNameField, f.name) + size += proto.StringSize(searchFilterNameField, f.key) size += proto.StringSize(searchFilterValueField, f.val) return size diff --git a/v2/object/marshal_test.go b/v2/object/marshal_test.go index c3315f5f..616c3c1b 100644 --- a/v2/object/marshal_test.go +++ b/v2/object/marshal_test.go @@ -608,7 +608,7 @@ func generateHeadResponseBody(flag bool) *object.HeadResponseBody { func generateFilter(k, v string) *object.SearchFilter { f := new(object.SearchFilter) - f.SetName(k) + f.SetKey(k) f.SetValue(v) f.SetMatchType(object.MatchStringEqual) diff --git a/v2/object/types.go b/v2/object/types.go index 5c6c9ac4..d5b37ef2 100644 --- a/v2/object/types.go +++ b/v2/object/types.go @@ -156,7 +156,7 @@ type HeadResponseBody struct { type SearchFilter struct { matchType MatchType - name, val string + key, val string } type SearchRequestBody struct { @@ -1274,17 +1274,17 @@ func (f *SearchFilter) SetMatchType(v MatchType) { } } -func (f *SearchFilter) GetName() string { +func (f *SearchFilter) GetKey() string { if f != nil { - return f.name + return f.key } return "" } -func (f *SearchFilter) SetName(v string) { +func (f *SearchFilter) SetKey(v string) { if f != nil { - f.name = v + f.key = v } } diff --git a/v2/session/marshal_test.go b/v2/session/marshal_test.go index 5164f79f..8e35d86c 100644 --- a/v2/session/marshal_test.go +++ b/v2/session/marshal_test.go @@ -295,7 +295,7 @@ func generateEACL(n int, k, v string) *acl.Table { filter := new(acl.HeaderFilter) filter.SetHeaderType(acl.HeaderTypeObject) filter.SetMatchType(acl.MatchTypeStringEqual) - filter.SetName(k) + filter.SetKey(k) filter.SetValue(v) record := new(acl.Record)