Skip to content

Commit

Permalink
Use %q instead of %s for strings with quotes (#2700)
Browse files Browse the repository at this point in the history
Signed-off-by: Mustafa Abdelrahman <[email protected]>
  • Loading branch information
MustafaSaber authored and szuecs committed Nov 7, 2023
1 parent 2e1f3b0 commit b02d474
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cmd/webhook/admission/admission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ func TestRouteGroupAdmitter(t *testing.T) {
{
name: "invalid routgroup multiple filters per json/yaml array item",
inputFile: "rg-with-multiple-filters.json",
message: `single filter expected at \"status(201) -> inlineContent(\"hi\")\"\nsingle filter expected at \" \"`,
message: `single filter expected at \"status(201) -> inlineContent(\\\"hi\\\")\"\nsingle filter expected at \" \"`,
},
{
name: "invalid routgroup multiple predicates per json/yaml array item",
inputFile: "rg-with-multiple-predicates.json",
message: `single predicate expected at \"Method(\"GET\") && Path(\"/\")\"\nsingle predicate expected at \" \"`,
message: `single predicate expected at \"Method(\\\"GET\\\") && Path(\\\"/\\\")\"\nsingle predicate expected at \" \"`,
},
} {
t.Run(tc.name, func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions dataclients/kubernetes/definitions/routegroupvalidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (rgv *RouteGroupValidator) filtersValidation(item *RouteGroupItem) error {
if err != nil {
errs = append(errs, err)
} else if len(filters) != 1 {
errs = append(errs, fmt.Errorf("%w at \"%s\"", errSingleFilterExpected, f))
errs = append(errs, fmt.Errorf("%w at %q", errSingleFilterExpected, f))
}
}
}
Expand All @@ -84,7 +84,7 @@ func (rgv *RouteGroupValidator) predicatesValidation(item *RouteGroupItem) error
if err != nil {
errs = append(errs, err)
} else if len(predicates) != 1 {
errs = append(errs, fmt.Errorf("%w at \"%s\"", errSinglePredicateExpected, p))
errs = append(errs, fmt.Errorf("%w at %q", errSinglePredicateExpected, p))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
route group without name
error in route group default/rg1: route group without backend
single predicate expected at "Path("/foo") && Method("GET")"
single predicate expected at "Path(\"/foo\") && Method(\"GET\")"
single predicate expected at ""
single filter expected at "inlineContent("/foo") -> status(200)"
single filter expected at "inlineContent(\"/foo\") -> status(200)"
single filter expected at " "

0 comments on commit b02d474

Please sign in to comment.