forked from TrueCloudLab/frostfs-api-go
[#182] Rename methods to match updated field names
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>support/v2.15
parent
5be034ab80
commit
dc9fcd5d98
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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())
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue