forked from containers/common
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The PR containers#1226 was merged to soon, it breaks podman tests and backwards compat. `{{json}}` and `{{json.}}` are not valid templates but it worked before the same as `json` so we should keep that for compat reasons. Fixes up commit 152c840 Signed-off-by: Paul Holzinger <[email protected]>
- Loading branch information
Showing
2 changed files
with
14 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
package report | ||
|
||
import "strings" | ||
import ( | ||
"regexp" | ||
) | ||
|
||
// Check for json, {{json }} and {{ json. }} which are not valid go template, | ||
// {{json .}} is valid and thus not matched to let the template handle it like docker does. | ||
var jsonRegex = regexp.MustCompile(`^\s*(json|{{\s*json\.?\s*}})\s*$`) | ||
|
||
// JSONFormat test CLI --format string to be a JSON request | ||
// | ||
// if report.IsJSON(cmd.Flag("format").Value.String()) { | ||
// ... process JSON and output | ||
// } | ||
func IsJSON(s string) bool { | ||
return strings.TrimSpace(s) == "json" | ||
return jsonRegex.MatchString(s) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters