Skip to content

Commit

Permalink
fix issue intuit#134
Browse files Browse the repository at this point in the history
1. QSL to support dashed keyname
2. fix full sync API timeout problem after add more k8s clusters
3. support special chars when QSL query is part of http URL, e.g. pod[@containers.$image="k8s.io/test"]{*}
  • Loading branch information
formuzi committed Mar 7, 2019
1 parent 368a0f8 commit 92a442f
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 90 deletions.
1 change: 1 addition & 0 deletions service/apis/entity_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ func (s EntityService) SyncEntities(meta string, data []map[string]interface{})
}
if !found {
s.dbclient.DeleteEntity(uid)
log.Debugf("entity %s deleted by sync", rid)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions service/apis/qsl_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import (
)

// regex to get objtype[filters]{fields}
var blockRegex = `([a-zA-Z0-9]+)\[?(?:(\@[\(\)\"\,\@\$\=\>\<\~\!a-zA-Z0-9\-\.\|\&\:_\^\*]*|\**|\$\$[a-zA-Z0-9\,\=]+))\]?\{([\*|[\,\@\"\=a-zA-Z0-9\-]*)`
var blockRegex = `([a-zA-Z0-9]+)\[?(?:(\@[\(\)\"\,\@\$\=\>\<\~\!a-zA-Z0-9\/\-\.\|\&\:_\^\*]*|\**|\$\$[a-zA-Z0-9\,\=]+))\]?\{([\*|[\,\@\"\=a-zA-Z0-9\-]*)`

// regex to get KeyOperatorValue from something like numreplicas>=2
var filterRegex = `\@([a-zA-Z0-9\(\)\.\$]*)([\!\<\>\=\~]*)(\"?[a-zA-Z0-9\-\.\|\&\:_\$\^]*\"?)`
var filterRegex = `\@([a-zA-Z0-9-_\(\)\.\$]*)([\!\<\>\=\~]*)(\"?[a-zA-Z0-9\-\\\/\.\|\&\:_\$\^]*\"?)`

// QSLService service for QSL
type QSLService struct {
Expand Down Expand Up @@ -438,7 +438,7 @@ func parseQuery(qry string) (string, string, string, error) {
objType := strings.ToLower(matches[1])
filters := matches[2]
fields := strings.ToLower(matches[3])
return objType, filters, fields, nil
return objType, strings.Replace(filters, "/", "\\/", -1), fields, nil
}

func (qa *QSLService) getCntFilter(query, objType string) (string, error) {
Expand Down
Loading

0 comments on commit 92a442f

Please sign in to comment.