[#302] pkg/container: Convert nil Container to nil message

Make `Container.ToV2` method to return `nil`
when called on `nil`. Write corresponding
unit test.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-06-08 15:38:53 +03:00 committed by Alex Vanin
parent 3984353d37
commit c08b90dbbc
2 changed files with 15 additions and 0 deletions

View file

@ -44,7 +44,14 @@ func New(opts ...NewOption) *Container {
return cnr
}
// ToV2 returns the v2 Container message.
//
// Nil Container converts to nil.
func (c *Container) ToV2() *container.Container {
if c == nil {
return nil
}
return &c.v2
}