-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When a user request --format `{{json .}}` they would want the go template parser to handle it. Currently we overwrite this and assume that `{{json .}}` equals `json`. This is not correct. When the output is a range (array), i.e. podman ps, it should return one json object per line and not a json array which is the case with `json`. This is required for docker compat. Fixes #16436 Signed-off-by: Paul Holzinger <[email protected]>
- Loading branch information
Showing
2 changed files
with
8 additions
and
11 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,14 +1,12 @@ | ||
package report | ||
|
||
import "regexp" | ||
|
||
var jsonRegex = regexp.MustCompile(`^\s*(json|{{\s*json\s*(\.)?\s*}})\s*$`) | ||
import "strings" | ||
|
||
// 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 jsonRegex.MatchString(s) | ||
return strings.TrimSpace(s) == "json" | ||
} |
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