diff options
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/cp.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/system_df.go | 13 | ||||
-rw-r--r-- | cmd/podman/trust_set_show.go | 1 | ||||
-rw-r--r-- | cmd/podman/varlink/io.podman.varlink | 1 |
15 files changed, 54 insertions, 24 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/cp.go b/cmd/podman/cp.go index 6223676ac..18fb2cb73 100644 --- a/cmd/podman/cp.go +++ b/cmd/podman/cp.go @@ -7,11 +7,11 @@ import ( "strconv" "strings" + "github.com/containers/buildah/pkg/chrootuser" "github.com/containers/buildah/util" "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/cmd/podman/libpodruntime" "github.com/containers/libpod/libpod" - "github.com/containers/libpod/pkg/chrootuser" "github.com/containers/libpod/pkg/rootless" "github.com/containers/storage" "github.com/containers/storage/pkg/archive" 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/system_df.go b/cmd/podman/system_df.go index 60da4238a..992e869bd 100644 --- a/cmd/podman/system_df.go +++ b/cmd/podman/system_df.go @@ -85,6 +85,9 @@ type volumeVerboseDiskUsage struct { } const systemDfDefaultFormat string = "table {{.Type}}\t{{.Total}}\t{{.Active}}\t{{.Size}}\t{{.Reclaimable}}" +const imageVerboseFormat string = "table {{.Repository}}\t{{.Tag}}\t{{.ImageID}}\t{{.Created}}\t{{.Size}}\t{{.SharedSize}}\t{{.UniqueSize}}\t{{.Containers}}" +const containerVerboseFormat string = "table {{.ContainerID}}\t{{.Image}}\t{{.Command}}\t{{.LocalVolumes}}\t{{.Size}}\t{{.Created}}\t{{.Status}}\t{{.Names}}" +const volumeVerboseFormat string = "table {{.VolumeName}}\t{{.Links}}\t{{.Size}}" func init() { dfSystemCommand.Command = _dfSystemCommand @@ -473,7 +476,7 @@ func getImageVerboseDiskUsage(ctx context.Context, images []*image.Image, images Repository: repo, Tag: tag, ImageID: shortID(img.ID()), - Created: units.HumanDuration(time.Since((img.Created().Local()))) + " ago", + Created: fmt.Sprintf("%s ago", units.HumanDuration(time.Since((img.Created().Local())))), Size: units.HumanSizeWithPrecision(float64(*size), 3), SharedSize: units.HumanSizeWithPrecision(float64(*size-imgUniqueSizeMap[img.ID()]), 3), UniqueSize: units.HumanSizeWithPrecision(float64(imgUniqueSizeMap[img.ID()]), 3), @@ -502,7 +505,7 @@ func getContainerVerboseDiskUsage(containers []*libpod.Container) (containersVer Command: strings.Join(ctr.Command(), " "), LocalVolumes: len(ctr.UserVolumes()), Size: units.HumanSizeWithPrecision(float64(size), 3), - Created: units.HumanDuration(time.Since(ctr.CreatedTime().Local())) + "ago", + Created: fmt.Sprintf("%s ago", units.HumanDuration(time.Since(ctr.CreatedTime().Local()))), Status: state.String(), Names: ctr.Name(), } @@ -548,7 +551,7 @@ func imagesVerboseOutput(ctx context.Context, metaData dfMetaData) error { return errors.Wrapf(err, "error getting verbose output of images") } os.Stderr.WriteString("Images space usage:\n\n") - out := formats.StdoutTemplateArray{Output: systemDfImageVerboseDiskUsageToGeneric(imagesVerboseDiskUsage), Template: "table {{.Repository}}\t{{.Tag}}\t{{.ImageID}}\t{{.Created}}\t{{.Size}}\t{{.SharedSize}}\t{{.UniqueSize}}\t{{.Containers}}", Fields: imageVerboseHeader} + out := formats.StdoutTemplateArray{Output: systemDfImageVerboseDiskUsageToGeneric(imagesVerboseDiskUsage), Template: imageVerboseFormat, Fields: imageVerboseHeader} formats.Writer(out).Out() return nil } @@ -569,7 +572,7 @@ func containersVerboseOutput(ctx context.Context, metaData dfMetaData) error { return errors.Wrapf(err, "error getting verbose output of containers") } os.Stderr.WriteString("\nContainers space usage:\n\n") - out := formats.StdoutTemplateArray{Output: systemDfContainerVerboseDiskUsageToGeneric(containersVerboseDiskUsage), Template: "table {{.ContainerID}}\t{{.Image}}\t{{.Command}}\t{{.LocalVolumes}}\t{{.Size}}\t{{.Created}}\t{{.Status}}\t{{.Names}}", Fields: containerVerboseHeader} + out := formats.StdoutTemplateArray{Output: systemDfContainerVerboseDiskUsageToGeneric(containersVerboseDiskUsage), Template: containerVerboseFormat, Fields: containerVerboseHeader} formats.Writer(out).Out() return nil } @@ -585,7 +588,7 @@ func volumesVerboseOutput(ctx context.Context, metaData dfMetaData) error { return errors.Wrapf(err, "error getting verbose ouput of volumes") } os.Stderr.WriteString("\nLocal Volumes space usage:\n\n") - out := formats.StdoutTemplateArray{Output: systemDfVolumeVerboseDiskUsageToGeneric(volumesVerboseDiskUsage), Template: "table {{.VolumeName}}\t{{.Links}}\t{{.Size}}", Fields: volumeVerboseHeader} + out := formats.StdoutTemplateArray{Output: systemDfVolumeVerboseDiskUsageToGeneric(volumesVerboseDiskUsage), Template: volumeVerboseFormat, Fields: volumeVerboseHeader} formats.Writer(out).Out() return nil } 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" diff --git a/cmd/podman/varlink/io.podman.varlink b/cmd/podman/varlink/io.podman.varlink index ad2de56f8..5e996f46b 100644 --- a/cmd/podman/varlink/io.podman.varlink +++ b/cmd/podman/varlink/io.podman.varlink @@ -59,6 +59,7 @@ type VolumeRemoveOpts ( type Image ( id: string, + digest: string, parentId: string, repoTags: []string, repoDigests: []string, |