mirror of
https://github.com/prometheus/alertmanager
synced 2024-12-25 07:32:19 +00:00
*: fix filter parameters with comma
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
parent
0a2d108bb9
commit
bc373f562f
@ -59,6 +59,7 @@ paths:
|
||||
description: A list of matchers to filter silences by
|
||||
required: false
|
||||
type: array
|
||||
collectionFormat: multi
|
||||
items:
|
||||
type: string
|
||||
post:
|
||||
@ -154,6 +155,7 @@ paths:
|
||||
description: A list of matchers to filter alerts by
|
||||
required: false
|
||||
type: array
|
||||
collectionFormat: multi
|
||||
items:
|
||||
type: string
|
||||
- name: receiver
|
||||
|
@ -76,6 +76,7 @@ func init() {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"collectionFormat": "multi",
|
||||
"description": "A list of matchers to filter alerts by",
|
||||
"name": "filter",
|
||||
"in": "query"
|
||||
@ -223,6 +224,7 @@ func init() {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"collectionFormat": "multi",
|
||||
"description": "A list of matchers to filter silences by",
|
||||
"name": "filter",
|
||||
"in": "query"
|
||||
@ -757,6 +759,7 @@ func init() {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"collectionFormat": "multi",
|
||||
"description": "A list of matchers to filter alerts by",
|
||||
"name": "filter",
|
||||
"in": "query"
|
||||
@ -922,6 +925,7 @@ func init() {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"collectionFormat": "multi",
|
||||
"description": "A list of matchers to filter silences by",
|
||||
"name": "filter",
|
||||
"in": "query"
|
||||
|
@ -58,6 +58,7 @@ type GetAlertsParams struct {
|
||||
Active *bool
|
||||
/*A list of matchers to filter alerts by
|
||||
In: query
|
||||
Collection Format: multi
|
||||
*/
|
||||
Filter []string
|
||||
/*Show inhibited alerts
|
||||
@ -153,16 +154,12 @@ func (o *GetAlertsParams) bindActive(rawData []string, hasKey bool, formats strf
|
||||
|
||||
// bindFilter binds and validates array parameter Filter from query.
|
||||
//
|
||||
// Arrays are parsed according to CollectionFormat: "" (defaults to "csv" when empty).
|
||||
// Arrays are parsed according to CollectionFormat: "multi" (defaults to "csv" when empty).
|
||||
func (o *GetAlertsParams) bindFilter(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
|
||||
var qvFilter string
|
||||
if len(rawData) > 0 {
|
||||
qvFilter = rawData[len(rawData)-1]
|
||||
}
|
||||
// CollectionFormat: multi
|
||||
filterIC := rawData
|
||||
|
||||
// CollectionFormat:
|
||||
filterIC := swag.SplitByFormat(qvFilter, "")
|
||||
if len(filterIC) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
@ -69,13 +69,10 @@ func (o *GetAlertsURL) Build() (*url.URL, error) {
|
||||
}
|
||||
}
|
||||
|
||||
filter := swag.JoinByFormat(filterIR, "")
|
||||
filter := swag.JoinByFormat(filterIR, "multi")
|
||||
|
||||
if len(filter) > 0 {
|
||||
qsv := filter[0]
|
||||
if qsv != "" {
|
||||
qs.Set("filter", qsv)
|
||||
}
|
||||
for _, qsv := range filter {
|
||||
qs.Add("filter", qsv)
|
||||
}
|
||||
|
||||
var inhibited string
|
||||
|
@ -11,7 +11,6 @@ import (
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
)
|
||||
@ -34,6 +33,7 @@ type GetSilencesParams struct {
|
||||
|
||||
/*A list of matchers to filter silences by
|
||||
In: query
|
||||
Collection Format: multi
|
||||
*/
|
||||
Filter []string
|
||||
}
|
||||
@ -62,16 +62,12 @@ func (o *GetSilencesParams) BindRequest(r *http.Request, route *middleware.Match
|
||||
|
||||
// bindFilter binds and validates array parameter Filter from query.
|
||||
//
|
||||
// Arrays are parsed according to CollectionFormat: "" (defaults to "csv" when empty).
|
||||
// Arrays are parsed according to CollectionFormat: "multi" (defaults to "csv" when empty).
|
||||
func (o *GetSilencesParams) bindFilter(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
|
||||
var qvFilter string
|
||||
if len(rawData) > 0 {
|
||||
qvFilter = rawData[len(rawData)-1]
|
||||
}
|
||||
// CollectionFormat: multi
|
||||
filterIC := rawData
|
||||
|
||||
// CollectionFormat:
|
||||
filterIC := swag.SplitByFormat(qvFilter, "")
|
||||
if len(filterIC) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
@ -56,13 +56,10 @@ func (o *GetSilencesURL) Build() (*url.URL, error) {
|
||||
}
|
||||
}
|
||||
|
||||
filter := swag.JoinByFormat(filterIR, "")
|
||||
filter := swag.JoinByFormat(filterIR, "multi")
|
||||
|
||||
if len(filter) > 0 {
|
||||
qsv := filter[0]
|
||||
if qsv != "" {
|
||||
qs.Set("filter", qsv)
|
||||
}
|
||||
for _, qsv := range filter {
|
||||
qs.Add("filter", qsv)
|
||||
}
|
||||
|
||||
_result.RawQuery = qs.Encode()
|
||||
|
@ -259,7 +259,7 @@ func (o *GetAlertsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg
|
||||
|
||||
valuesFilter := o.Filter
|
||||
|
||||
joinedFilter := swag.JoinByFormat(valuesFilter, "")
|
||||
joinedFilter := swag.JoinByFormat(valuesFilter, "multi")
|
||||
// query array param filter
|
||||
if err := r.SetQueryParam("filter", joinedFilter...); err != nil {
|
||||
return err
|
||||
|
@ -127,7 +127,7 @@ func (o *GetSilencesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.R
|
||||
|
||||
valuesFilter := o.Filter
|
||||
|
||||
joinedFilter := swag.JoinByFormat(valuesFilter, "")
|
||||
joinedFilter := swag.JoinByFormat(valuesFilter, "multi")
|
||||
// query array param filter
|
||||
if err := r.SetQueryParam("filter", joinedFilter...); err != nil {
|
||||
return err
|
||||
|
@ -43,10 +43,7 @@ script.js: src/Data elm-env format $(ELM_FILES)
|
||||
|
||||
src/Data: ../../api/v2/openapi.yaml
|
||||
-rm -r src/Data
|
||||
# TODO: Use released version instead of `@sha256:d9f87079bb4d7[...]` that
|
||||
# includes patch for
|
||||
# https://github.com/OpenAPITools/openapi-generator/issues/1465
|
||||
docker run --user=$(shell id -u $(USER)):$(shell id -g $(USER)) --rm -v ${PWD}/../..:/local openapitools/openapi-generator-cli@sha256:d9f87079bb4d769e2c6f2a6b72677f4d5e64db687db0455eb41227663290e53c generate \
|
||||
docker run --user=$(shell id -u $(USER)):$(shell id -g $(USER)) --rm -v ${PWD}/../..:/local openapitools/openapi-generator-cli:v3.3.4 generate \
|
||||
-i /local/api/v2/openapi.yaml \
|
||||
-g elm \
|
||||
-o /local/ui/app/$(TEMPOPENAPI)
|
||||
|
Loading…
Reference in New Issue
Block a user