Merge pull request #2374 from tonistiigi/print-json-format

handle json formatting for print
This commit is contained in:
CrazyMax 2024-04-05 09:08:27 +02:00 committed by GitHub
commit 5c29e6e26e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -852,7 +852,9 @@ func printResult(f *controllerapi.PrintFunc, res map[string]string) error {
case "subrequests.describe":
return printValue(subrequests.PrintDescribe, subrequests.SubrequestsDescribeDefinition.Version, f.Format, res)
default:
if dt, ok := res["result.txt"]; ok {
if dt, ok := res["result.json"]; ok && f.Format == "json" {
fmt.Println(dt)
} else if dt, ok := res["result.txt"]; ok {
fmt.Print(dt)
} else {
log.Printf("%s %+v", f, res)