summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-03-25 15:43:38 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-03-27 20:00:31 -0400
commit5ed62991dcbe85e28774b036a7c89033af80136f (patch)
treeea5b57abb6290bf0afac083292aad6dc653f52be /cmd
parent340eeec1b654880f9d339c9ac2957bcaeaee6829 (diff)
downloadpodman-5ed62991dcbe85e28774b036a7c89033af80136f.tar.gz
podman-5ed62991dcbe85e28774b036a7c89033af80136f.tar.bz2
podman-5ed62991dcbe85e28774b036a7c89033af80136f.zip
Remove ulele/deepcopier in favor of JSON deep copy
We have a very high performance JSON library that doesn't need to perform code generation. Let's use it instead of our questionably performant, reflection-dependent deep copy library. Most changes because some functions can now return errors. Also converts cmd/podman to use jsoniter, instead of pkg/json, for increased performance. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/commit.go9
-rw-r--r--cmd/podman/common.go2
-rw-r--r--cmd/podman/inspect.go1
-rw-r--r--cmd/podman/mount.go6
-rw-r--r--cmd/podman/pod_inspect.go1
-rw-r--r--cmd/podman/pod_stats.go6
-rw-r--r--cmd/podman/ps.go1
-rw-r--r--cmd/podman/run.go6
-rw-r--r--cmd/podman/shared/create.go15
-rw-r--r--cmd/podman/sign.go6
-rw-r--r--cmd/podman/start.go6
-rw-r--r--cmd/podman/trust_set_show.go1
12 files changed, 43 insertions, 17 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..098d18fa4 100644
--- a/cmd/podman/ps.go
+++ b/cmd/podman/ps.go
@@ -1,7 +1,6 @@
package main
import (
- "encoding/json"
"fmt"
"html/template"
"os"
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..35f1dadf2 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"