yq/pkg/yqlib/operator_not.go

21 lines
563 B
Go
Raw Normal View History

2020-11-03 23:48:43 +00:00
package yqlib
2020-10-20 05:27:30 +00:00
2020-10-21 01:54:58 +00:00
import "container/list"
2020-10-20 05:27:30 +00:00
2020-10-21 01:54:58 +00:00
func NotOperator(d *dataTreeNavigator, matchMap *list.List, pathNode *PathTreeNode) (*list.List, error) {
2020-10-20 05:27:30 +00:00
log.Debugf("-- notOperation")
2020-10-21 01:54:58 +00:00
var results = list.New()
2020-10-20 05:27:30 +00:00
for el := matchMap.Front(); el != nil; el = el.Next() {
candidate := el.Value.(*CandidateNode)
log.Debug("notOperation checking %v", candidate)
truthy, errDecoding := isTruthy(candidate)
if errDecoding != nil {
return nil, errDecoding
}
result := createBooleanCandidate(candidate, !truthy)
2020-10-21 01:54:58 +00:00
results.PushBack(result)
2020-10-20 05:27:30 +00:00
}
return results, nil
}