forked from TrueCloudLab/frostfs-api-go
[#182] Rename methods to match updated field names
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
5be034ab80
commit
dc9fcd5d98
17 changed files with 47 additions and 47 deletions
|
@ -8,7 +8,7 @@ import (
|
||||||
// header means that request should be processed according to EACL action.
|
// header means that request should be processed according to EACL action.
|
||||||
type Filter struct {
|
type Filter struct {
|
||||||
from FilterHeaderType
|
from FilterHeaderType
|
||||||
name string
|
key string
|
||||||
matcher Match
|
matcher Match
|
||||||
value string
|
value string
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ func (a Filter) Matcher() Match {
|
||||||
return a.matcher
|
return a.matcher
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Filter) Name() string {
|
func (a Filter) Key() string {
|
||||||
return a.name
|
return a.key
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Filter) From() FilterHeaderType {
|
func (a Filter) From() FilterHeaderType {
|
||||||
|
@ -32,7 +32,7 @@ func (a Filter) From() FilterHeaderType {
|
||||||
func (a *Filter) ToV2() *v2acl.HeaderFilter {
|
func (a *Filter) ToV2() *v2acl.HeaderFilter {
|
||||||
filter := new(v2acl.HeaderFilter)
|
filter := new(v2acl.HeaderFilter)
|
||||||
filter.SetValue(a.value)
|
filter.SetValue(a.value)
|
||||||
filter.SetName(a.name)
|
filter.SetKey(a.key)
|
||||||
filter.SetMatchType(a.matcher.ToV2())
|
filter.SetMatchType(a.matcher.ToV2())
|
||||||
filter.SetHeaderType(a.from.ToV2())
|
filter.SetHeaderType(a.from.ToV2())
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ func NewFilterFromV2(filter *v2acl.HeaderFilter) *Filter {
|
||||||
|
|
||||||
f.from = FilterHeaderTypeFromV2(filter.GetHeaderType())
|
f.from = FilterHeaderTypeFromV2(filter.GetHeaderType())
|
||||||
f.matcher = MatchFromV2(filter.GetMatchType())
|
f.matcher = MatchFromV2(filter.GetMatchType())
|
||||||
f.name = filter.GetName()
|
f.key = filter.GetKey()
|
||||||
f.value = filter.GetValue()
|
f.value = filter.GetValue()
|
||||||
|
|
||||||
return f
|
return f
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
func TestFilter(t *testing.T) {
|
func TestFilter(t *testing.T) {
|
||||||
filter := &Filter{
|
filter := &Filter{
|
||||||
from: HeaderFromObject,
|
from: HeaderFromObject,
|
||||||
name: "some name",
|
key: "some name",
|
||||||
matcher: MatchStringEqual,
|
matcher: MatchStringEqual,
|
||||||
value: "200",
|
value: "200",
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ func TestFilter(t *testing.T) {
|
||||||
require.NotNil(t, v2)
|
require.NotNil(t, v2)
|
||||||
require.Equal(t, v2acl.HeaderTypeObject, v2.GetHeaderType())
|
require.Equal(t, v2acl.HeaderTypeObject, v2.GetHeaderType())
|
||||||
require.EqualValues(t, v2acl.MatchTypeStringEqual, v2.GetMatchType())
|
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())
|
require.Equal(t, filter.Value(), v2.GetValue())
|
||||||
|
|
||||||
newFilter := NewFilterFromV2(v2)
|
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) {
|
func (r *Record) AddFilter(from FilterHeaderType, matcher Match, name, value string) {
|
||||||
filter := Filter{
|
filter := Filter{
|
||||||
from: from,
|
from: from,
|
||||||
name: name,
|
key: name,
|
||||||
matcher: matcher,
|
matcher: matcher,
|
||||||
value: value,
|
value: value,
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,13 +62,13 @@ func TestRecord_AddFilter(t *testing.T) {
|
||||||
filters := []Filter{
|
filters := []Filter{
|
||||||
{
|
{
|
||||||
from: HeaderFromObject,
|
from: HeaderFromObject,
|
||||||
name: "some name",
|
key: "some name",
|
||||||
matcher: MatchStringEqual,
|
matcher: MatchStringEqual,
|
||||||
value: "ContainerID",
|
value: "ContainerID",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
from: HeaderFromRequest,
|
from: HeaderFromRequest,
|
||||||
name: "X-Header-Name",
|
key: "X-Header-Name",
|
||||||
matcher: MatchStringNotEqual,
|
matcher: MatchStringNotEqual,
|
||||||
value: "X-Header-Value",
|
value: "X-Header-Value",
|
||||||
},
|
},
|
||||||
|
@ -76,7 +76,7 @@ func TestRecord_AddFilter(t *testing.T) {
|
||||||
|
|
||||||
r := NewRecord()
|
r := NewRecord()
|
||||||
for _, filter := range filters {
|
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())
|
require.Equal(t, filters, r.Filters())
|
||||||
|
|
|
@ -64,7 +64,7 @@ func NewSearchFiltersFromV2(v2 []*v2object.SearchFilter) SearchFilters {
|
||||||
}
|
}
|
||||||
|
|
||||||
filters = append(filters, SearchFilter{
|
filters = append(filters, SearchFilter{
|
||||||
header: v2[i].GetName(),
|
header: v2[i].GetKey(),
|
||||||
value: v2[i].GetValue(),
|
value: v2[i].GetValue(),
|
||||||
op: SearchMatchFromV2(v2[i].GetMatchType()),
|
op: SearchMatchFromV2(v2[i].GetMatchType()),
|
||||||
})
|
})
|
||||||
|
@ -89,7 +89,7 @@ func (f SearchFilters) ToV2() []*v2object.SearchFilter {
|
||||||
result := make([]*v2object.SearchFilter, 0, len(f))
|
result := make([]*v2object.SearchFilter, 0, len(f))
|
||||||
for i := range f {
|
for i := range f {
|
||||||
v2 := new(v2object.SearchFilter)
|
v2 := new(v2object.SearchFilter)
|
||||||
v2.SetName(f[i].header)
|
v2.SetKey(f[i].header)
|
||||||
v2.SetValue(f[i].value)
|
v2.SetValue(f[i].value)
|
||||||
v2.SetMatchType(f[i].op.ToV2())
|
v2.SetMatchType(f[i].op.ToV2())
|
||||||
|
|
||||||
|
|
|
@ -165,8 +165,8 @@ func HeaderFilterToGRPCMessage(f *HeaderFilter) *acl.EACLRecord_Filter {
|
||||||
MatchTypeToGRPCField(f.GetMatchType()),
|
MatchTypeToGRPCField(f.GetMatchType()),
|
||||||
)
|
)
|
||||||
|
|
||||||
m.SetHeaderName(f.GetName())
|
m.SetKey(f.GetKey())
|
||||||
m.SetHeaderVal(f.GetValue())
|
m.SetValue(f.GetValue())
|
||||||
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
@ -187,8 +187,8 @@ func HeaderFilterFromGRPCMessage(m *acl.EACLRecord_Filter) *HeaderFilter {
|
||||||
MatchTypeFromGRPCField(m.GetMatchType()),
|
MatchTypeFromGRPCField(m.GetMatchType()),
|
||||||
)
|
)
|
||||||
|
|
||||||
f.SetName(m.GetHeaderName())
|
f.SetKey(m.GetKey())
|
||||||
f.SetValue(m.GetHeaderVal())
|
f.SetValue(m.GetValue())
|
||||||
|
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,17 +67,17 @@ func (m *EACLRecord_Filter) SetMatchType(v MatchType) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetHeaderName sets header name of the eACL filter.
|
// SetKey sets key of the eACL filter.
|
||||||
func (m *EACLRecord_Filter) SetHeaderName(v string) {
|
func (m *EACLRecord_Filter) SetKey(v string) {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
m.HeaderName = v
|
m.Key = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetHeaderVal sets header value of the eACL filter.
|
// SetValue sets value of the eACL filter.
|
||||||
func (m *EACLRecord_Filter) SetHeaderVal(v string) {
|
func (m *EACLRecord_Filter) SetValue(v string) {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
m.HeaderVal = v
|
m.Value = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,7 +193,7 @@ func (f *HeaderFilter) StableMarshal(buf []byte) ([]byte, error) {
|
||||||
|
|
||||||
offset += n
|
offset += n
|
||||||
|
|
||||||
n, err = proto.StringMarshal(filterNameField, buf[offset:], f.name)
|
n, err = proto.StringMarshal(filterNameField, buf[offset:], f.key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ func (f *HeaderFilter) StableSize() (size int) {
|
||||||
|
|
||||||
size += proto.EnumSize(filterHeaderTypeField, int32(f.hdrType))
|
size += proto.EnumSize(filterHeaderTypeField, int32(f.hdrType))
|
||||||
size += proto.EnumSize(filterMatchTypeField, int32(f.matchType))
|
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)
|
size += proto.StringSize(filterValueField, f.value)
|
||||||
|
|
||||||
return size
|
return size
|
||||||
|
|
|
@ -29,7 +29,7 @@ func generateFilter(t acl.HeaderType, k, v string) *acl.HeaderFilter {
|
||||||
filter := new(acl.HeaderFilter)
|
filter := new(acl.HeaderFilter)
|
||||||
filter.SetHeaderType(t)
|
filter.SetHeaderType(t)
|
||||||
filter.SetMatchType(acl.MatchTypeStringEqual)
|
filter.SetMatchType(acl.MatchTypeStringEqual)
|
||||||
filter.SetName(k)
|
filter.SetKey(k)
|
||||||
filter.SetValue(v)
|
filter.SetValue(v)
|
||||||
|
|
||||||
return filter
|
return filter
|
||||||
|
@ -122,7 +122,7 @@ func TestHeaderFilter_StableMarshal(t *testing.T) {
|
||||||
t.Run("non empty", func(t *testing.T) {
|
t.Run("non empty", func(t *testing.T) {
|
||||||
filterFrom.SetHeaderType(acl.HeaderTypeObject)
|
filterFrom.SetHeaderType(acl.HeaderTypeObject)
|
||||||
filterFrom.SetMatchType(acl.MatchTypeStringEqual)
|
filterFrom.SetMatchType(acl.MatchTypeStringEqual)
|
||||||
filterFrom.SetName("Hello")
|
filterFrom.SetKey("Hello")
|
||||||
filterFrom.SetValue("World")
|
filterFrom.SetValue("World")
|
||||||
|
|
||||||
wire, err := filterFrom.StableMarshal(nil)
|
wire, err := filterFrom.StableMarshal(nil)
|
||||||
|
|
|
@ -9,7 +9,7 @@ type HeaderFilter struct {
|
||||||
|
|
||||||
matchType MatchType
|
matchType MatchType
|
||||||
|
|
||||||
name, value string
|
key, value string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Target is a unified structure of Target
|
// 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 {
|
if f != nil {
|
||||||
return f.name
|
return f.key
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *HeaderFilter) SetName(v string) {
|
func (f *HeaderFilter) SetKey(v string) {
|
||||||
if f != nil {
|
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 := new(acl.HeaderFilter)
|
||||||
filter.SetHeaderType(acl.HeaderTypeObject)
|
filter.SetHeaderType(acl.HeaderTypeObject)
|
||||||
filter.SetMatchType(acl.MatchTypeStringEqual)
|
filter.SetMatchType(acl.MatchTypeStringEqual)
|
||||||
filter.SetName(k)
|
filter.SetKey(k)
|
||||||
filter.SetValue(v)
|
filter.SetValue(v)
|
||||||
|
|
||||||
record := new(acl.Record)
|
record := new(acl.Record)
|
||||||
|
|
|
@ -1118,7 +1118,7 @@ func SearchFilterToGRPCMessage(f *SearchFilter) *object.SearchRequest_Body_Filte
|
||||||
MatchTypeToGRPCField(f.GetMatchType()),
|
MatchTypeToGRPCField(f.GetMatchType()),
|
||||||
)
|
)
|
||||||
|
|
||||||
m.SetName(f.GetName())
|
m.SetKey(f.GetKey())
|
||||||
|
|
||||||
m.SetValue(f.GetValue())
|
m.SetValue(f.GetValue())
|
||||||
|
|
||||||
|
@ -1136,7 +1136,7 @@ func SearchFilterFromGRPCMessage(m *object.SearchRequest_Body_Filter) *SearchFil
|
||||||
MatchTypeFromGRPCField(m.GetMatchType()),
|
MatchTypeFromGRPCField(m.GetMatchType()),
|
||||||
)
|
)
|
||||||
|
|
||||||
f.SetName(m.GetName())
|
f.SetKey(m.GetKey())
|
||||||
|
|
||||||
f.SetValue(m.GetValue())
|
f.SetValue(m.GetValue())
|
||||||
|
|
||||||
|
|
|
@ -402,10 +402,10 @@ func (m *SearchRequest_Body_Filter) SetMatchType(v MatchType) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetName sets name of the filtering header.
|
// SetKey sets key to the filtering header.
|
||||||
func (m *SearchRequest_Body_Filter) SetName(v string) {
|
func (m *SearchRequest_Body_Filter) SetKey(v string) {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
m.Name = v
|
m.Key = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -937,7 +937,7 @@ func (f *SearchFilter) StableMarshal(buf []byte) ([]byte, error) {
|
||||||
|
|
||||||
offset += n
|
offset += n
|
||||||
|
|
||||||
n, err = proto.StringMarshal(searchFilterNameField, buf[offset:], f.name)
|
n, err = proto.StringMarshal(searchFilterNameField, buf[offset:], f.key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -958,7 +958,7 @@ func (f *SearchFilter) StableSize() (size int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
size += proto.EnumSize(searchFilterMatchField, int32(f.matchType))
|
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)
|
size += proto.StringSize(searchFilterValueField, f.val)
|
||||||
|
|
||||||
return size
|
return size
|
||||||
|
|
|
@ -608,7 +608,7 @@ func generateHeadResponseBody(flag bool) *object.HeadResponseBody {
|
||||||
|
|
||||||
func generateFilter(k, v string) *object.SearchFilter {
|
func generateFilter(k, v string) *object.SearchFilter {
|
||||||
f := new(object.SearchFilter)
|
f := new(object.SearchFilter)
|
||||||
f.SetName(k)
|
f.SetKey(k)
|
||||||
f.SetValue(v)
|
f.SetValue(v)
|
||||||
f.SetMatchType(object.MatchStringEqual)
|
f.SetMatchType(object.MatchStringEqual)
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ type HeadResponseBody struct {
|
||||||
type SearchFilter struct {
|
type SearchFilter struct {
|
||||||
matchType MatchType
|
matchType MatchType
|
||||||
|
|
||||||
name, val string
|
key, val string
|
||||||
}
|
}
|
||||||
|
|
||||||
type SearchRequestBody struct {
|
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 {
|
if f != nil {
|
||||||
return f.name
|
return f.key
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *SearchFilter) SetName(v string) {
|
func (f *SearchFilter) SetKey(v string) {
|
||||||
if f != nil {
|
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 := new(acl.HeaderFilter)
|
||||||
filter.SetHeaderType(acl.HeaderTypeObject)
|
filter.SetHeaderType(acl.HeaderTypeObject)
|
||||||
filter.SetMatchType(acl.MatchTypeStringEqual)
|
filter.SetMatchType(acl.MatchTypeStringEqual)
|
||||||
filter.SetName(k)
|
filter.SetKey(k)
|
||||||
filter.SetValue(v)
|
filter.SetValue(v)
|
||||||
|
|
||||||
record := new(acl.Record)
|
record := new(acl.Record)
|
||||||
|
|
Loading…
Reference in a new issue