diff options
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/common/default.go | 6 | ||||
-rw-r--r-- | cmd/podman/common/specgen.go | 1 | ||||
-rw-r--r-- | cmd/podman/containers/container.go | 3 | ||||
-rw-r--r-- | cmd/podman/containers/inspect.go | 1 | ||||
-rw-r--r-- | cmd/podman/containers/mount.go | 1 | ||||
-rw-r--r-- | cmd/podman/containers/ps.go | 1 | ||||
-rw-r--r-- | cmd/podman/images/history.go | 2 | ||||
-rw-r--r-- | cmd/podman/images/image.go | 3 | ||||
-rw-r--r-- | cmd/podman/images/inspect.go | 1 | ||||
-rw-r--r-- | cmd/podman/images/list.go | 2 | ||||
-rw-r--r-- | cmd/podman/pods/inspect.go | 3 | ||||
-rw-r--r-- | cmd/podman/pods/pod.go | 3 | ||||
-rw-r--r-- | cmd/podman/pods/ps.go | 4 | ||||
-rw-r--r-- | cmd/podman/registry/json.go | 20 | ||||
-rw-r--r-- | cmd/podman/report/diff.go | 3 | ||||
-rw-r--r-- | cmd/podman/report/report.go | 6 | ||||
-rw-r--r-- | cmd/podman/system/info.go | 1 | ||||
-rw-r--r-- | cmd/podman/system/system.go | 3 | ||||
-rw-r--r-- | cmd/podman/volumes/inspect.go | 1 | ||||
-rw-r--r-- | cmd/podman/volumes/volume.go | 3 |
20 files changed, 50 insertions, 18 deletions
diff --git a/cmd/podman/common/default.go b/cmd/podman/common/default.go index 89316270b..7233b2091 100644 --- a/cmd/podman/common/default.go +++ b/cmd/podman/common/default.go @@ -1,5 +1,9 @@ package common +import ( + "github.com/containers/libpod/cmd/podman/registry" +) + var ( // DefaultHealthCheckInterval default value DefaultHealthCheckInterval = "30s" @@ -11,4 +15,6 @@ var ( DefaultHealthCheckTimeout = "30s" // DefaultImageVolume default value DefaultImageVolume = "bind" + // Pull in configured json library + json = registry.JsonLibrary() ) diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go index 12fd16551..fc0167461 100644 --- a/cmd/podman/common/specgen.go +++ b/cmd/podman/common/specgen.go @@ -1,7 +1,6 @@ package common import ( - "encoding/json" "fmt" "os" "path/filepath" diff --git a/cmd/podman/containers/container.go b/cmd/podman/containers/container.go index 4b1733eb0..97b73cdd0 100644 --- a/cmd/podman/containers/container.go +++ b/cmd/podman/containers/container.go @@ -8,6 +8,9 @@ import ( ) var ( + // Pull in configured json library + json = registry.JsonLibrary() + // Command: podman _container_ containerCmd = &cobra.Command{ Use: "container", diff --git a/cmd/podman/containers/inspect.go b/cmd/podman/containers/inspect.go index 8d591832b..f9ef1ddbd 100644 --- a/cmd/podman/containers/inspect.go +++ b/cmd/podman/containers/inspect.go @@ -11,7 +11,6 @@ import ( "github.com/containers/libpod/cmd/podman/registry" "github.com/containers/libpod/pkg/domain/entities" - json "github.com/json-iterator/go" "github.com/spf13/cobra" ) diff --git a/cmd/podman/containers/mount.go b/cmd/podman/containers/mount.go index d0d132546..0bdac72cb 100644 --- a/cmd/podman/containers/mount.go +++ b/cmd/podman/containers/mount.go @@ -1,7 +1,6 @@ package containers import ( - "encoding/json" "fmt" "os" "text/tabwriter" diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go index 57b81a609..49e77abd2 100644 --- a/cmd/podman/containers/ps.go +++ b/cmd/podman/containers/ps.go @@ -1,7 +1,6 @@ package containers import ( - "encoding/json" "fmt" "os" "sort" diff --git a/cmd/podman/images/history.go b/cmd/podman/images/history.go index c92072bff..b8d216cc1 100644 --- a/cmd/podman/images/history.go +++ b/cmd/podman/images/history.go @@ -13,7 +13,6 @@ import ( "github.com/containers/libpod/cmd/podman/registry" "github.com/containers/libpod/pkg/domain/entities" "github.com/docker/go-units" - jsoniter "github.com/json-iterator/go" "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -77,7 +76,6 @@ func history(cmd *cobra.Command, args []string) error { layers[i].ImageHistoryLayer = l layers[i].Created = l.Created.Format(time.RFC3339) } - json := jsoniter.ConfigCompatibleWithStandardLibrary enc := json.NewEncoder(os.Stdout) err = enc.Encode(layers) } diff --git a/cmd/podman/images/image.go b/cmd/podman/images/image.go index 37e46ab9e..604f49251 100644 --- a/cmd/podman/images/image.go +++ b/cmd/podman/images/image.go @@ -7,6 +7,9 @@ import ( ) var ( + // Pull in configured json library + json = registry.JsonLibrary() + // Command: podman _image_ imageCmd = &cobra.Command{ Use: "image", diff --git a/cmd/podman/images/inspect.go b/cmd/podman/images/inspect.go index 3190ab725..91c9445eb 100644 --- a/cmd/podman/images/inspect.go +++ b/cmd/podman/images/inspect.go @@ -2,7 +2,6 @@ package images import ( "context" - "encoding/json" "fmt" "os" "strings" diff --git a/cmd/podman/images/list.go b/cmd/podman/images/list.go index 63ddc5d56..b979cb6af 100644 --- a/cmd/podman/images/list.go +++ b/cmd/podman/images/list.go @@ -14,7 +14,6 @@ import ( "github.com/containers/libpod/cmd/podman/registry" "github.com/containers/libpod/pkg/domain/entities" "github.com/docker/go-units" - jsoniter "github.com/json-iterator/go" "github.com/spf13/cobra" "github.com/spf13/pflag" ) @@ -127,7 +126,6 @@ func writeJSON(imageS []*entities.ImageSummary) error { imgs = append(imgs, h) } - json := jsoniter.ConfigCompatibleWithStandardLibrary enc := json.NewEncoder(os.Stdout) return enc.Encode(imgs) } diff --git a/cmd/podman/pods/inspect.go b/cmd/podman/pods/inspect.go index 901ae50b2..1e333247b 100644 --- a/cmd/podman/pods/inspect.go +++ b/cmd/podman/pods/inspect.go @@ -6,7 +6,6 @@ import ( "github.com/containers/libpod/cmd/podman/registry" "github.com/containers/libpod/pkg/domain/entities" - jsoniter "github.com/json-iterator/go" "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -55,7 +54,7 @@ func inspect(cmd *cobra.Command, args []string) error { if err != nil { return err } - b, err := jsoniter.MarshalIndent(responses, "", " ") + b, err := json.MarshalIndent(responses, "", " ") if err != nil { return err } diff --git a/cmd/podman/pods/pod.go b/cmd/podman/pods/pod.go index fa917b2ae..e86b8aba4 100644 --- a/cmd/podman/pods/pod.go +++ b/cmd/podman/pods/pod.go @@ -8,6 +8,9 @@ import ( ) var ( + // Pull in configured json library + json = registry.JsonLibrary() + // Command: podman _pod_ podCmd = &cobra.Command{ Use: "pod", diff --git a/cmd/podman/pods/ps.go b/cmd/podman/pods/ps.go index 8cb7b6266..808980eff 100644 --- a/cmd/podman/pods/ps.go +++ b/cmd/podman/pods/ps.go @@ -2,7 +2,6 @@ package pods import ( "context" - "encoding/json" "fmt" "io" "os" @@ -11,10 +10,9 @@ import ( "text/template" "time" - "github.com/docker/go-units" - "github.com/containers/libpod/cmd/podman/registry" "github.com/containers/libpod/pkg/domain/entities" + "github.com/docker/go-units" "github.com/pkg/errors" "github.com/spf13/cobra" ) diff --git a/cmd/podman/registry/json.go b/cmd/podman/registry/json.go new file mode 100644 index 000000000..f25406c3c --- /dev/null +++ b/cmd/podman/registry/json.go @@ -0,0 +1,20 @@ +package registry + +import ( + "sync" + + jsoniter "github.com/json-iterator/go" +) + +var ( + json jsoniter.API + jsonSync sync.Once +) + +// JsonLibrary provides a "encoding/json" compatible API +func JsonLibrary() jsoniter.API { + jsonSync.Do(func() { + json = jsoniter.ConfigCompatibleWithStandardLibrary + }) + return json +} diff --git a/cmd/podman/report/diff.go b/cmd/podman/report/diff.go index b36189d75..0730f06e8 100644 --- a/cmd/podman/report/diff.go +++ b/cmd/podman/report/diff.go @@ -6,7 +6,6 @@ import ( "github.com/containers/libpod/pkg/domain/entities" "github.com/containers/storage/pkg/archive" - jsoniter "github.com/json-iterator/go" "github.com/pkg/errors" ) @@ -31,7 +30,7 @@ func ChangesToJSON(diffs *entities.DiffReport) error { } } - json := jsoniter.ConfigCompatibleWithStandardLibrary + // Pull in configured json library enc := json.NewEncoder(os.Stdout) return enc.Encode(body) } diff --git a/cmd/podman/report/report.go b/cmd/podman/report/report.go new file mode 100644 index 000000000..8392f10e0 --- /dev/null +++ b/cmd/podman/report/report.go @@ -0,0 +1,6 @@ +package report + +import "github.com/containers/libpod/cmd/podman/registry" + +// Pull in configured json library +var json = registry.JsonLibrary() diff --git a/cmd/podman/system/info.go b/cmd/podman/system/info.go index aa0a66ffc..8e014a91b 100644 --- a/cmd/podman/system/info.go +++ b/cmd/podman/system/info.go @@ -1,7 +1,6 @@ package system import ( - "encoding/json" "fmt" "os" "text/template" diff --git a/cmd/podman/system/system.go b/cmd/podman/system/system.go index 6d8c9ebc5..2d55e8c13 100644 --- a/cmd/podman/system/system.go +++ b/cmd/podman/system/system.go @@ -7,6 +7,9 @@ import ( ) var ( + // Pull in configured json library + json = registry.JsonLibrary() + // Command: podman _system_ systemCmd = &cobra.Command{ Use: "system", diff --git a/cmd/podman/volumes/inspect.go b/cmd/podman/volumes/inspect.go index feaaee176..79f65ea4a 100644 --- a/cmd/podman/volumes/inspect.go +++ b/cmd/podman/volumes/inspect.go @@ -1,7 +1,6 @@ package volumes import ( - "encoding/json" "fmt" "html/template" "os" diff --git a/cmd/podman/volumes/volume.go b/cmd/podman/volumes/volume.go index 06943da62..4d74ff084 100644 --- a/cmd/podman/volumes/volume.go +++ b/cmd/podman/volumes/volume.go @@ -7,6 +7,9 @@ import ( ) var ( + // Pull in configured json library + json = registry.JsonLibrary() + // Command: podman _volume_ volumeCmd = &cobra.Command{ Use: "volume", |