@@ -13,6 +13,7 @@ import (
1313
1414 "github.com/go-resty/resty/v2"
1515 "github.com/mitchellh/mapstructure"
16+ log "github.com/sirupsen/logrus"
1617)
1718
1819func getExecutions (id string , status string , name string , nested bool ) ([]* CodestreamAPIExecutions , error ) {
@@ -28,16 +29,30 @@ func getExecutions(id string, status string, name string, nested bool) ([]*Codes
2829 client := resty .New ()
2930 var qParams = make (map [string ]string )
3031 qParams ["$orderby" ] = "_requestTimeInMicros desc"
32+
33+ var filters []string
3134 if status != "" {
32- qParams [ "$filter" ] = "(( status eq '" + strings .ToUpper (status ) + "') and (_nested eq '" + strconv . FormatBool ( nested ) + "'))"
35+ filters = append ( filters , "( status eq '"+ strings .ToUpper (status )+ "')" )
3336 }
3437 if name != "" {
35- qParams ["$filter" ] = "((name eq '" + name + "') and (_nested eq '" + strconv .FormatBool (nested ) + "'))"
38+ filters = append (filters , "(name eq '" + name + "')" )
39+ }
40+ if nested {
41+ filters = append (filters , "(_nested eq '" + strconv .FormatBool (nested )+ "')" )
42+ }
43+ if project != "" {
44+ filters = append (filters , "(project eq '" + project + "')" )
3645 }
46+ if len (filters ) > 0 {
47+ qParams ["$filter" ] = "(" + strings .Join (filters , ") and (" ) + ")"
48+ log .Debugln (qParams ["$filter" ])
49+ }
50+
3751 queryResponse , err := client .SetTLSClientConfig (& tls.Config {InsecureSkipVerify : ignoreCert }).R ().
3852 SetQueryParams (qParams ).
3953 SetHeader ("Accept" , "application/json" ).
4054 SetResult (& documentsList {}).
55+ SetError (& CodeStreamException {}).
4156 SetAuthToken (targetConfig .accesstoken ).
4257 Get ("https://" + targetConfig .server + "/pipeline/api/executions" )
4358 if queryResponse .IsError () {
0 commit comments