diff --git a/pkg/container/attribute.go b/pkg/container/attribute.go index 2e4492fe..ec633e8a 100644 --- a/pkg/container/attribute.go +++ b/pkg/container/attribute.go @@ -50,6 +50,10 @@ func (a *Attribute) ToV2() *container.Attribute { } func NewAttributesFromV2(v []*container.Attribute) Attributes { + if v == nil { + return nil + } + attrs := make(Attributes, 0, len(v)) for i := range v { attrs = append(attrs, NewAttributeFromV2(v[i])) @@ -59,6 +63,10 @@ func NewAttributesFromV2(v []*container.Attribute) Attributes { } func (a Attributes) ToV2() []*container.Attribute { + if a == nil { + return nil + } + attrs := make([]*container.Attribute, 0, len(a)) for i := range a { attrs = append(attrs, a[i].ToV2()) diff --git a/pkg/container/attribute_test.go b/pkg/container/attribute_test.go index e32dfda6..acd7bbd0 100644 --- a/pkg/container/attribute_test.go +++ b/pkg/container/attribute_test.go @@ -61,6 +61,14 @@ func TestAttribute(t *testing.T) { } func TestAttributes(t *testing.T) { + t.Run("nil", func(t *testing.T) { + var x container.Attributes + + require.Nil(t, x.ToV2()) + + require.Nil(t, container.NewAttributesFromV2(nil)) + }) + var ( keys = []string{"key1", "key2", "key3"} vals = []string{"val1", "val2", "val3"} diff --git a/pkg/container/opts.go b/pkg/container/opts.go index d07b6846..8c15ed1f 100644 --- a/pkg/container/opts.go +++ b/pkg/container/opts.go @@ -28,8 +28,8 @@ func defaultContainerOptions() containerOptions { } return containerOptions{ - acl: acl.PrivateBasicRule, - nonce: rand, + acl: acl.PrivateBasicRule, + nonce: rand, } }