summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <pbuetow@mimecast.com>2020-07-02 14:42:09 +0100
committerPaul Buetow <pbuetow@mimecast.com>2020-07-02 14:42:09 +0100
commit9983d8b5162756f5016e4c0d0bc28ad86c2293e6 (patch)
tree3795641e63fa55a0fe685a9760977593e9d65d44
parent51998506b2f51eba9b6d82d07003c4f27928ae7f (diff)
add lacks string operator, lacks is the opposite of contains. e.g.: not contains
-rw-r--r--internal/mapr/wherecondition.go5
-rwxr-xr-xsamples/dtail.schema.json23
2 files changed, 28 insertions, 0 deletions
diff --git a/internal/mapr/wherecondition.go b/internal/mapr/wherecondition.go
index 5ca3c44..3ca9103 100644
--- a/internal/mapr/wherecondition.go
+++ b/internal/mapr/wherecondition.go
@@ -18,6 +18,7 @@ const (
StringEq QueryOperation = iota
StringNe QueryOperation = iota
StringContains QueryOperation = iota
+ StringNotContains QueryOperation = iota
FloatOperation QueryOperation = iota
FloatEq QueryOperation = iota
FloatNe QueryOperation = iota
@@ -99,6 +100,8 @@ func makeWhereConditions(tokens []token) (where []whereCondition, err error) {
wc.Operation = StringNe
case "contains":
wc.Operation = StringContains
+ case "lacks":
+ wc.Operation = StringNotContains
default:
return wc, nil, errors.New(invalidQuery + "Unknown operation in 'where' clause: " + whereOp)
}
@@ -187,6 +190,8 @@ func (wc *whereCondition) stringClause(lValue string, rValue string) bool {
return lValue != rValue
case StringContains:
return strings.Contains(lValue, rValue)
+ case StringNotContains:
+ return !strings.Contains(lValue, rValue)
default:
logger.Error("Unknown string operation", lValue, wc.Operation, rValue)
}
diff --git a/samples/dtail.schema.json b/samples/dtail.schema.json
index 68db788..73807fc 100755
--- a/samples/dtail.schema.json
+++ b/samples/dtail.schema.json
@@ -43,6 +43,29 @@
}
}
},
+ "Monitor": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "Name": {
+ "type": "string"
+ },
+ "Enable": {
+ "type": "boolean"
+ },
+ "Files": {
+ "type": "string"
+ },
+ "Outfile": {
+ "type": "string"
+ },
+ "Query": {
+ "type": "string"
+ }
+ }
+ }
+ },
"HostKeyFile": {
"type": "string"
},