Merge pull request #3493 from baude/psnostore

ps should use nostore when possible
This commit is contained in:
OpenShift Merge Robot
2019-07-04 10:16:27 +02:00
committed by GitHub

View File

@ -197,7 +197,11 @@ func init() {
} }
func psCmd(c *cliconfig.PsValues) error { func psCmd(c *cliconfig.PsValues) error {
var watch bool var (
watch bool
runtime *adapter.LocalRuntime
err error
)
if c.Watch > 0 { if c.Watch > 0 {
watch = true watch = true
@ -210,8 +214,11 @@ func psCmd(c *cliconfig.PsValues) error {
if err := checkFlagsPassed(c); err != nil { if err := checkFlagsPassed(c); err != nil {
return errors.Wrapf(err, "error with flags passed") return errors.Wrapf(err, "error with flags passed")
} }
if !c.Size {
runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) runtime, err = adapter.GetRuntimeNoStore(getContext(), &c.PodmanCommand)
} else {
runtime, err = adapter.GetRuntime(getContext(), &c.PodmanCommand)
}
if err != nil { if err != nil {
return errors.Wrapf(err, "error creating libpod runtime") return errors.Wrapf(err, "error creating libpod runtime")
} }
@ -308,57 +315,6 @@ func sortPsOutput(sortBy string, psOutput psSorted) (psSorted, error) {
return psOutput, nil return psOutput, nil
} }
// getLabels converts the labels to a string of the form "key=value, key2=value2"
func formatLabels(labels map[string]string) string {
var arr []string
if len(labels) > 0 {
for key, val := range labels {
temp := key + "=" + val
arr = append(arr, temp)
}
return strings.Join(arr, ",")
}
return ""
}
// getMounts converts the volumes mounted to a string of the form "mount1, mount2"
// it truncates it if noTrunc is false
func getMounts(mounts []string, noTrunc bool) string {
return strings.Join(getMountsArray(mounts, noTrunc), ",")
}
func getMountsArray(mounts []string, noTrunc bool) []string {
var arr []string
if len(mounts) == 0 {
return mounts
}
for _, mount := range mounts {
splitArr := strings.Split(mount, ":")
if len(splitArr[0]) > mountTruncLength && !noTrunc {
arr = append(arr, splitArr[0][:mountTruncLength]+"...")
continue
}
arr = append(arr, splitArr[0])
}
return arr
}
// portsToString converts the ports used to a string of the from "port1, port2"
func portsToString(ports []ocicni.PortMapping) string {
var portDisplay []string
if len(ports) == 0 {
return ""
}
for _, v := range ports {
hostIP := v.HostIP
if hostIP == "" {
hostIP = "0.0.0.0"
}
portDisplay = append(portDisplay, fmt.Sprintf("%s:%d->%d/%s", hostIP, v.HostPort, v.ContainerPort, v.Protocol))
}
return strings.Join(portDisplay, ", ")
}
func printFormat(format string, containers []shared.PsContainerOutput) error { func printFormat(format string, containers []shared.PsContainerOutput) error {
// return immediately if no containers are present // return immediately if no containers are present
if len(containers) == 0 { if len(containers) == 0 {