From 48837bd5da3d197c95b45f72569c1a190e79f950 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 27 May 2021 14:50:37 +0300 Subject: [PATCH] [#288] pkg/eacl: Fix conversion of slices in Table.ToV2 method Nil slice of records of the `Table` should be converted to nil slice in corresponding field of API v2 message structure. Add nil-check in `Table.ToV2` implementation. The changes fix corresponding unit test. Signed-off-by: Leonard Lyubich --- pkg/acl/eacl/table.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/acl/eacl/table.go b/pkg/acl/eacl/table.go index d18ab0c7..81bee1a9 100644 --- a/pkg/acl/eacl/table.go +++ b/pkg/acl/eacl/table.go @@ -88,13 +88,16 @@ func (t *Table) ToV2() *v2acl.Table { v2.SetContainerID(t.cid.ToV2()) } - records := make([]*v2acl.Record, 0, len(t.records)) - for _, record := range t.records { - records = append(records, record.ToV2()) + if t.records != nil { + records := make([]*v2acl.Record, 0, len(t.records)) + for _, record := range t.records { + records = append(records, record.ToV2()) + } + + v2.SetRecords(records) } v2.SetVersion(t.version.ToV2()) - v2.SetRecords(records) return v2 }