diff options
author | Matthew Heon <matthew.heon@pm.me> | 2019-03-25 15:43:38 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2019-03-27 20:00:31 -0400 |
commit | 5ed62991dcbe85e28774b036a7c89033af80136f (patch) | |
tree | ea5b57abb6290bf0afac083292aad6dc653f52be /libpod/runtime.go | |
parent | 340eeec1b654880f9d339c9ac2957bcaeaee6829 (diff) | |
download | podman-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 'libpod/runtime.go')
-rw-r--r-- | libpod/runtime.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go index b3b75d791..a4fc9e493 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -23,7 +23,6 @@ import ( "github.com/docker/docker/pkg/namesgenerator" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/ulule/deepcopier" ) // RuntimeStateStore is a constant indicating which state store implementation @@ -355,7 +354,9 @@ func newRuntimeFromConfig(userConfigPath string, options ...RuntimeOption) (runt if err != nil { return nil, err } - deepcopier.Copy(defaultRuntimeConfig).To(runtime.config) + if err := JSONDeepCopy(defaultRuntimeConfig, runtime.config); err != nil { + return nil, errors.Wrapf(err, "error copying runtime default config") + } runtime.config.TmpDir = tmpDir storageConf, err := util.GetDefaultStoreOptions() @@ -923,20 +924,22 @@ func makeRuntime(runtime *Runtime) (err error) { } // GetConfig returns a copy of the configuration used by the runtime -func (r *Runtime) GetConfig() *RuntimeConfig { +func (r *Runtime) GetConfig() (*RuntimeConfig, error) { r.lock.RLock() defer r.lock.RUnlock() if !r.valid { - return nil + return nil, ErrRuntimeStopped } config := new(RuntimeConfig) // Copy so the caller won't be able to modify the actual config - deepcopier.Copy(r.config).To(config) + if err := JSONDeepCopy(r.config, config); err != nil { + return nil, errors.Wrapf(err, "error copying config") + } - return config + return config, nil } // Shutdown shuts down the runtime and associated containers and storage |