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}}` is not a valid template but it worked before the same as `json` so we should keep that. Fixes up commit 152c840 Signed-off-by: Paul Holzinger <[email protected]>
- Loading branch information
Showing
2 changed files
with
10 additions
and
4 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 and {{json }} which is not valid go template, | ||
// {{json .}} is valid and thus not matched | ||
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