Skip to content

Commit

Permalink
fix issue #134 (#135)
Browse files Browse the repository at this point in the history
* fix issue #134
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"]{*}

* remove extra tab from log which added by accident

* remove specical chars from returned error message
  • Loading branch information
formuzi authored Mar 21, 2019
1 parent dbb5f9f commit c0529ed
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 92 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 c0529ed

Please sign in to comment.