forked from TrueCloudLab/frostfs-api-go
[#302] pkg/container: Convert nil Attribute
to nil message
Document that `Attribute.ToV2` method returns `nil` when is called on `nil`. Add corresponding unit test. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
1863694b96
commit
8b7a433864
2 changed files with 22 additions and 0 deletions
|
@ -29,10 +29,17 @@ func (a *Attribute) Value() string {
|
|||
return (*container.Attribute)(a).GetValue()
|
||||
}
|
||||
|
||||
// NewAttributeFromV2 wraps protocol dependent version of
|
||||
// Attribute message.
|
||||
//
|
||||
// Nil container.Attribute converts to nil.
|
||||
func NewAttributeFromV2(v *container.Attribute) *Attribute {
|
||||
return (*Attribute)(v)
|
||||
}
|
||||
|
||||
// ToV2 converts Attribute to v2 Attribute message.
|
||||
//
|
||||
// Nil Attribute converts to nil.
|
||||
func (a *Attribute) ToV2() *container.Attribute {
|
||||
return (*container.Attribute)(a)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue