diff --git a/pkg/acl/eacl/filter.go b/pkg/acl/eacl/filter.go index d66978b2..3be0bb52 100644 --- a/pkg/acl/eacl/filter.go +++ b/pkg/acl/eacl/filter.go @@ -66,7 +66,13 @@ func (f Filter) From() FilterHeaderType { } // ToV2 converts Filter to v2 acl.EACLRecord.Filter message. +// +// Nil Filter converts to nil. func (f *Filter) ToV2() *v2acl.HeaderFilter { + if f == nil { + return nil + } + filter := new(v2acl.HeaderFilter) filter.SetValue(f.value.String()) filter.SetKey(f.key.String()) diff --git a/pkg/acl/eacl/filter_test.go b/pkg/acl/eacl/filter_test.go index 64636ccd..7918042a 100644 --- a/pkg/acl/eacl/filter_test.go +++ b/pkg/acl/eacl/filter_test.go @@ -59,3 +59,11 @@ func TestFilterEncoding(t *testing.T) { require.Equal(t, f, d2) }) } + +func TestFilter_ToV2(t *testing.T) { + t.Run("nil", func(t *testing.T) { + var x *Filter + + require.Nil(t, x.ToV2()) + }) +}