Merge pull request #2760 from mheon/misc_small_changes

Remove ulele/deepcopier in favor of JSON deep copy
This commit is contained in:
OpenShift Merge Robot
2019-03-28 07:06:31 -07:00
committed by GitHub
27 changed files with 107 additions and 559 deletions

View File

@@ -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,

View File

@@ -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 (

View File

@@ -2,7 +2,6 @@ package main
import (
"context"
"encoding/json"
"strings"
"github.com/containers/buildah/pkg/formats"

View File

@@ -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)

View File

@@ -1,7 +1,6 @@
package main
import (
"encoding/json"
"fmt"
"github.com/containers/libpod/cmd/podman/cliconfig"

View File

@@ -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

View File

@@ -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
}

View File

@@ -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

View File

@@ -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

View File

@@ -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)
}

View File

@@ -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

View File

@@ -1,7 +1,6 @@
package main
import (
"encoding/json"
"io/ioutil"
"os"
"sort"