diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-03-28 07:06:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-28 07:06:31 -0700 |
commit | e7a2eecf5f3975edfb92cd2cacff0d34ef45f808 (patch) | |
tree | 5557aaeb6ec27d61b75b1db18dc5e0a4d85c90be /cmd | |
parent | 850326cc192444d1c5cfd8ba6e1015f653b41e73 (diff) | |
parent | 179a66f1a0a22be66c0346afa8ea3181d5846fb2 (diff) | |
download | podman-e7a2eecf5f3975edfb92cd2cacff0d34ef45f808.tar.gz podman-e7a2eecf5f3975edfb92cd2cacff0d34ef45f808.tar.bz2 podman-e7a2eecf5f3975edfb92cd2cacff0d34ef45f808.zip |
Merge pull request #2760 from mheon/misc_small_changes
Remove ulele/deepcopier in favor of JSON deep copy
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/commit.go | 9 | ||||
-rw-r--r-- | cmd/podman/common.go | 2 | ||||
-rw-r--r-- | cmd/podman/inspect.go | 1 | ||||
-rw-r--r-- | cmd/podman/mount.go | 6 | ||||
-rw-r--r-- | cmd/podman/pod_inspect.go | 1 | ||||
-rw-r--r-- | cmd/podman/pod_stats.go | 6 | ||||
-rw-r--r-- | cmd/podman/ps.go | 3 | ||||
-rw-r--r-- | cmd/podman/run.go | 6 | ||||
-rw-r--r-- | cmd/podman/shared/create.go | 15 | ||||
-rw-r--r-- | cmd/podman/sign.go | 6 | ||||
-rw-r--r-- | cmd/podman/start.go | 6 | ||||
-rw-r--r-- | cmd/podman/trust_set_show.go | 1 |
12 files changed, 44 insertions, 18 deletions
diff --git a/cmd/podman/commit.go b/cmd/podman/commit.go index 584ab6880..f7e206856 100644 --- a/cmd/podman/commit.go +++ b/cmd/podman/commit.go @@ -96,9 +96,14 @@ func commitCmd(c *cliconfig.CommitValues) error { return errors.Wrapf(err, "error looking up container %q", container) } - sc := image.GetSystemContext(runtime.GetConfig().SignaturePolicyPath, "", false) + rtc, err := runtime.GetConfig() + if err != nil { + return err + } + + sc := image.GetSystemContext(rtc.SignaturePolicyPath, "", false) coptions := buildah.CommitOptions{ - SignaturePolicyPath: runtime.GetConfig().SignaturePolicyPath, + SignaturePolicyPath: rtc.SignaturePolicyPath, ReportWriter: writer, SystemContext: sc, PreferredManifestType: mimeType, diff --git a/cmd/podman/common.go b/cmd/podman/common.go index 167b3e845..10fed053e 100644 --- a/cmd/podman/common.go +++ b/cmd/podman/common.go @@ -12,12 +12,14 @@ import ( "github.com/containers/libpod/pkg/rootless" "github.com/containers/storage" "github.com/fatih/camelcase" + jsoniter "github.com/json-iterator/go" "github.com/pkg/errors" "github.com/spf13/cobra" ) var ( stores = make(map[storage.Store]struct{}) + json = jsoniter.ConfigCompatibleWithStandardLibrary ) const ( diff --git a/cmd/podman/inspect.go b/cmd/podman/inspect.go index 3d6fd07e0..528320170 100644 --- a/cmd/podman/inspect.go +++ b/cmd/podman/inspect.go @@ -2,7 +2,6 @@ package main import ( "context" - "encoding/json" "strings" "github.com/containers/buildah/pkg/formats" diff --git a/cmd/podman/mount.go b/cmd/podman/mount.go index d074551ce..138548097 100644 --- a/cmd/podman/mount.go +++ b/cmd/podman/mount.go @@ -71,7 +71,11 @@ func mountCmd(c *cliconfig.MountValues) error { defer runtime.Shutdown(false) if os.Geteuid() != 0 { - if driver := runtime.GetConfig().StorageConfig.GraphDriverName; driver != "vfs" { + rtc, err := runtime.GetConfig() + if err != nil { + return err + } + if driver := rtc.StorageConfig.GraphDriverName; driver != "vfs" { // Do not allow to mount a graphdriver that is not vfs if we are creating the userns as part // of the mount command. return fmt.Errorf("cannot mount using driver %s in rootless mode", driver) diff --git a/cmd/podman/pod_inspect.go b/cmd/podman/pod_inspect.go index 851f39aa0..e12678354 100644 --- a/cmd/podman/pod_inspect.go +++ b/cmd/podman/pod_inspect.go @@ -1,7 +1,6 @@ package main import ( - "encoding/json" "fmt" "github.com/containers/libpod/cmd/podman/cliconfig" diff --git a/cmd/podman/pod_stats.go b/cmd/podman/pod_stats.go index e8ff322ce..36b0b95ed 100644 --- a/cmd/podman/pod_stats.go +++ b/cmd/podman/pod_stats.go @@ -9,7 +9,6 @@ import ( "text/tabwriter" "time" - "encoding/json" tm "github.com/buger/goterm" "github.com/containers/buildah/pkg/formats" "github.com/containers/libpod/cmd/podman/cliconfig" @@ -17,7 +16,6 @@ import ( "github.com/containers/libpod/pkg/adapter" "github.com/pkg/errors" "github.com/spf13/cobra" - "github.com/ulule/deepcopier" ) var ( @@ -187,7 +185,9 @@ func podStatsCmd(c *cliconfig.PodStatsValues) error { } time.Sleep(time.Second) previousPodStats := new([]*libpod.PodContainerStats) - deepcopier.Copy(newStats).To(previousPodStats) + if err := libpod.JSONDeepCopy(newStats, previousPodStats); err != nil { + return err + } pods, err = runtime.GetStatPods(c) if err != nil { return err diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go index 27774f95d..a9802d27f 100644 --- a/cmd/podman/ps.go +++ b/cmd/podman/ps.go @@ -1,7 +1,6 @@ package main import ( - "encoding/json" "fmt" "html/template" "os" @@ -647,7 +646,7 @@ func printFormat(format string, containers []shared.PsContainerOutput) error { } func dumpJSON(containers []shared.PsContainerOutput) error { - b, err := json.MarshalIndent(containers, "", "\t") + b, err := json.MarshalIndent(containers, "", " ") if err != nil { return err } diff --git a/cmd/podman/run.go b/cmd/podman/run.go index 32e7b3510..3c26e98c1 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -154,7 +154,11 @@ func runCmd(c *cliconfig.RunValues) error { if errors.Cause(err) == libpod.ErrNoSuchCtr { // The container may have been removed // Go looking for an exit file - ctrExitCode, err := readExitFile(runtime.GetConfig().TmpDir, ctr.ID()) + rtc, err := runtime.GetConfig() + if err != nil { + return err + } + ctrExitCode, err := readExitFile(rtc.TmpDir, ctr.ID()) if err != nil { logrus.Errorf("Cannot get exit code: %v", err) exitCode = 127 diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go index 5f7263cb6..d927e5bf6 100644 --- a/cmd/podman/shared/create.go +++ b/cmd/podman/shared/create.go @@ -43,20 +43,23 @@ func getContext() context.Context { func CreateContainer(ctx context.Context, c *cliconfig.PodmanCommand, runtime *libpod.Runtime) (*libpod.Container, *cc.CreateConfig, error) { var ( healthCheck *manifest.Schema2HealthConfig + err error + cidFile *os.File ) if c.Bool("trace") { span, _ := opentracing.StartSpanFromContext(ctx, "createContainer") defer span.Finish() } - rtc := runtime.GetConfig() + rtc, err := runtime.GetConfig() + if err != nil { + return nil, nil, err + } rootfs := "" if c.Bool("rootfs") { rootfs = c.InputArgs[0] } - var err error - var cidFile *os.File if c.IsSet("cidfile") && os.Geteuid() == 0 { cidFile, err = libpod.OpenExclusiveFile(c.String("cidfile")) if err != nil && os.IsExist(err) { @@ -721,7 +724,11 @@ func ParseCreateOpts(ctx context.Context, c *cliconfig.PodmanCommand, runtime *l if c.Bool("init") { initPath := c.String("init-path") if initPath == "" { - initPath = runtime.GetConfig().InitPath + rtc, err := runtime.GetConfig() + if err != nil { + return nil, err + } + initPath = rtc.InitPath } if err := config.AddContainerInitBinary(initPath); err != nil { return nil, err diff --git a/cmd/podman/sign.go b/cmd/podman/sign.go index 06418e4a5..75d723514 100644 --- a/cmd/podman/sign.go +++ b/cmd/podman/sign.go @@ -108,7 +108,11 @@ func signCmd(c *cliconfig.SignValues) error { } // create the signstore file - newImage, err := runtime.ImageRuntime().New(getContext(), signimage, runtime.GetConfig().SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{SignBy: signby}, false, nil) + rtc, err := runtime.GetConfig() + if err != nil { + return err + } + newImage, err := runtime.ImageRuntime().New(getContext(), signimage, rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{SignBy: signby}, false, nil) if err != nil { return errors.Wrapf(err, "error pulling image %s", signimage) } diff --git a/cmd/podman/start.go b/cmd/podman/start.go index cf406cf66..d17a78268 100644 --- a/cmd/podman/start.go +++ b/cmd/podman/start.go @@ -129,7 +129,11 @@ func startCmd(c *cliconfig.StartValues) error { if errors.Cause(err) == libpod.ErrNoSuchCtr { // The container may have been removed // Go looking for an exit file - ctrExitCode, err := readExitFile(runtime.GetConfig().TmpDir, ctr.ID()) + rtc, err := runtime.GetConfig() + if err != nil { + return err + } + ctrExitCode, err := readExitFile(rtc.TmpDir, ctr.ID()) if err != nil { logrus.Errorf("Cannot get exit code: %v", err) exitCode = 127 diff --git a/cmd/podman/trust_set_show.go b/cmd/podman/trust_set_show.go index d7a4ea6d6..626d27aae 100644 --- a/cmd/podman/trust_set_show.go +++ b/cmd/podman/trust_set_show.go @@ -1,7 +1,6 @@ package main import ( - "encoding/json" "io/ioutil" "os" "sort" |