forked from TrueCloudLab/frostfs-api-go
[#302] pkg/netmap: Document default values set in NewFilter
Make `filtersFromV2` return `nil` if passed value is `nil`. Document field values of instance constructed via `NewFilter`. Assert the values in corresponding unit test. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
9a7e120485
commit
44437bf81a
2 changed files with 33 additions and 0 deletions
|
@ -148,6 +148,13 @@ func (c *Context) matchKeyValue(f *Filter, b *Node) bool {
|
|||
}
|
||||
|
||||
// NewFilter creates and returns new Filter instance.
|
||||
//
|
||||
// Defaults:
|
||||
// - name: "";
|
||||
// - key: "";
|
||||
// - value: "";
|
||||
// - operation: 0;
|
||||
// - filters: nil.
|
||||
func NewFilter() *Filter {
|
||||
return NewFilterFromV2(new(netmap.Filter))
|
||||
}
|
||||
|
@ -217,6 +224,10 @@ func (f *Filter) SetOperation(op Operation) {
|
|||
}
|
||||
|
||||
func filtersFromV2(fs []*netmap.Filter) []*Filter {
|
||||
if fs == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
res := make([]*Filter, 0, len(fs))
|
||||
|
||||
for i := range fs {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue