Skip to content

Commit

Permalink
Merge pull request #8378 from jwhonce/issues/8366
Browse files Browse the repository at this point in the history
Swap out json-iterator for golang default
  • Loading branch information
openshift-merge-robot authored Nov 18, 2020
2 parents 8a0c3d8 + 4ed1ef5 commit 4bbf2b6
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions cmd/podman/inspect/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package inspect

import (
"context"
"encoding/json" // due to a bug in json-iterator it cannot be used here
"fmt"
"os"
"regexp"
Expand All @@ -28,17 +29,14 @@ const (
ContainerType = "container"
// ImageType is the image type.
ImageType = "image"
//NetworkType is the network type
// NetworkType is the network type
NetworkType = "network"
//PodType is the pod type.
// PodType is the pod type.
PodType = "pod"
//VolumeType is the volume type
// VolumeType is the volume type
VolumeType = "volume"
)

// Pull in configured json library
var json = registry.JSONLibrary()

// AddInspectFlagSet takes a command and adds the inspect flags and returns an
// InspectOptions object.
func AddInspectFlagSet(cmd *cobra.Command) *entities.InspectOptions {
Expand Down Expand Up @@ -173,7 +171,7 @@ func (i *inspector) inspect(namesOrIDs []string) error {
data = append(data, podData)
}
}
if i.podOptions.Latest { //latest means there are no names in the namesOrID array
if i.podOptions.Latest { // latest means there are no names in the namesOrID array
podData, err := i.containerEngine.PodInspect(ctx, i.podOptions)
if err != nil {
cause := errors.Cause(err)
Expand Down Expand Up @@ -238,9 +236,12 @@ func (i *inspector) inspect(namesOrIDs []string) error {
}

func printJSON(data []interface{}) error {
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
return enc.Encode(data)
buf, err := json.MarshalIndent(data, "", " ")
if err != nil {
return err
}
_, err = fmt.Println(string(buf))
return err
}

func printTmpl(typ, row string, data []interface{}) error {
Expand Down

0 comments on commit 4bbf2b6

Please sign in to comment.