mirror of
https://github.com/containers/podman.git
synced 2025-06-03 12:17:13 +08:00
trivial cleanups from golang
the results of a code cleanup performed by the goland IDE. Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
@ -62,7 +62,7 @@ func init() {
|
||||
layerFlags := buildahcli.GetLayerFlags(&layerValues)
|
||||
flag = layerFlags.Lookup("layers")
|
||||
flag.Value.Set(useLayers())
|
||||
flag.DefValue = (useLayers())
|
||||
flag.DefValue = useLayers()
|
||||
flag = layerFlags.Lookup("force-rm")
|
||||
flag.Value.Set("true")
|
||||
flag.DefValue = "true"
|
||||
|
@ -86,7 +86,7 @@ func copyBetweenHostAndContainer(runtime *libpod.Runtime, src string, dest strin
|
||||
return errors.Errorf("invalid arguments %s, %s you must specify paths", src, dest)
|
||||
}
|
||||
ctr := srcCtr
|
||||
isFromHostToCtr := (ctr == nil)
|
||||
isFromHostToCtr := ctr == nil
|
||||
if isFromHostToCtr {
|
||||
ctr = destCtr
|
||||
}
|
||||
@ -307,7 +307,7 @@ func copy(src, destPath, dest string, idMappingOpts storage.IDMappingOptions, ch
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return errors.Wrapf(err, "error checking directory %q", destdir)
|
||||
}
|
||||
destDirIsExist := (err == nil)
|
||||
destDirIsExist := err == nil
|
||||
if err = os.MkdirAll(destdir, 0755); err != nil {
|
||||
return errors.Wrapf(err, "error creating directory %q", destdir)
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ func getHistoryTemplateOutput(history []*image.History, opts historyOptions) (hi
|
||||
}
|
||||
|
||||
if opts.human {
|
||||
createdTime = units.HumanDuration(time.Since((*hist.Created))) + " ago"
|
||||
createdTime = units.HumanDuration(time.Since(*hist.Created)) + " ago"
|
||||
outputSize = units.HumanSize(float64(hist.Size))
|
||||
} else {
|
||||
createdTime = (hist.Created).Format(time.RFC3339)
|
||||
|
@ -280,7 +280,7 @@ func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerIma
|
||||
ID: imageID,
|
||||
Digest: img.Digest(),
|
||||
CreatedTime: createdTime,
|
||||
Created: units.HumanDuration(time.Since((createdTime))) + " ago",
|
||||
Created: units.HumanDuration(time.Since(createdTime)) + " ago",
|
||||
Size: sizeStr,
|
||||
}
|
||||
imagesOutput = append(imagesOutput, params)
|
||||
|
@ -55,7 +55,7 @@ func podKillCmd(c *cliconfig.PodKillValues) error {
|
||||
}
|
||||
defer runtime.Shutdown(false)
|
||||
|
||||
var killSignal uint = uint(syscall.SIGTERM)
|
||||
killSignal := uint(syscall.SIGTERM)
|
||||
|
||||
if c.Signal != "" {
|
||||
// Check if the signalString provided by the user is valid
|
||||
|
@ -271,7 +271,7 @@ func printPSFormat(format string, stats []*podStatOut, headerNames map[string]st
|
||||
|
||||
func outputToStdOut(stats []*podStatOut) {
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
|
||||
outFormat := ("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n")
|
||||
outFormat := "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n"
|
||||
fmt.Fprintf(w, outFormat, "POD", "CID", "NAME", "CPU %", "MEM USAGE/ LIMIT", "MEM %", "NET IO", "BLOCK IO", "PIDS")
|
||||
for _, i := range stats {
|
||||
if len(stats) == 0 {
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
"github.com/containers/libpod/libpod/image"
|
||||
"github.com/containers/libpod/pkg/adapter"
|
||||
"github.com/containers/libpod/pkg/util"
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
"github.com/opentracing/opentracing-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"github.com/containers/libpod/cmd/podman/cliconfig"
|
||||
"github.com/containers/libpod/pkg/adapter"
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
"github.com/opentracing/opentracing-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -279,8 +279,8 @@ func generateContainerFilterFuncs(filter, filterValue string, r *libpod.Runtime)
|
||||
return strings.Contains(c.ID(), filterValue)
|
||||
}, nil
|
||||
case "label":
|
||||
var filterArray []string = strings.SplitN(filterValue, "=", 2)
|
||||
var filterKey string = filterArray[0]
|
||||
var filterArray = strings.SplitN(filterValue, "=", 2)
|
||||
var filterKey = filterArray[0]
|
||||
if len(filterArray) > 1 {
|
||||
filterValue = filterArray[1]
|
||||
} else {
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"github.com/containers/libpod/libpod"
|
||||
cc "github.com/containers/libpod/pkg/spec"
|
||||
"github.com/docker/go-connections/nat"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
)
|
||||
|
||||
// InspectContainer holds all inspect data for a container.
|
||||
|
@ -127,7 +127,7 @@ func printImageChildren(layerMap map[string]*image.LayerInfo, layerID string, pr
|
||||
}
|
||||
fmt.Printf("%sID: %s Size: %7v%s\n", intend, ll.ID[:12], units.HumanSizeWithPrecision(float64(ll.Size), 4), tags)
|
||||
for count, childID := range ll.ChildID {
|
||||
if err := printImageChildren(layerMap, childID, prefix, (count == len(ll.ChildID)-1)); err != nil {
|
||||
if err := printImageChildren(layerMap, childID, prefix, count == len(ll.ChildID)-1); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -610,7 +610,7 @@ func (c *Container) isStopped() (bool, error) {
|
||||
if err != nil {
|
||||
return true, err
|
||||
}
|
||||
return (c.state.State != define.ContainerStateRunning && c.state.State != define.ContainerStatePaused), nil
|
||||
return c.state.State != define.ContainerStateRunning && c.state.State != define.ContainerStatePaused, nil
|
||||
}
|
||||
|
||||
// save container state to the database
|
||||
|
@ -19,8 +19,8 @@ import (
|
||||
"github.com/containers/image/types"
|
||||
"github.com/containers/libpod/libpod/events"
|
||||
"github.com/containers/libpod/pkg/registries"
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/opentracing/opentracing-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
@ -22,7 +22,7 @@ var (
|
||||
// BitmapSize is the size of the bitmap used when managing SHM locks.
|
||||
// an SHM lock manager's max locks will be rounded up to a multiple of
|
||||
// this number.
|
||||
BitmapSize uint32 = uint32(C.bitmap_size_c)
|
||||
BitmapSize = uint32(C.bitmap_size_c)
|
||||
)
|
||||
|
||||
// SHMLocks is a struct enabling POSIX semaphore locking in a shared memory
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
hooks "github.com/containers/libpod/pkg/hooks"
|
||||
"github.com/containers/libpod/pkg/hooks"
|
||||
current "github.com/containers/libpod/pkg/hooks/1.0.0"
|
||||
rspec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
)
|
||||
|
@ -30,7 +30,7 @@ func TestAlways(t *testing.T) {
|
||||
for _, always := range []bool{true, false} {
|
||||
for _, or := range []bool{true, false} {
|
||||
for _, process := range []*rspec.Process{processStruct, nil} {
|
||||
t.Run(fmt.Sprintf("always %t, or %t, has process %t", always, or, (process != nil)), func(t *testing.T) {
|
||||
t.Run(fmt.Sprintf("always %t, or %t, has process %t", always, or, process != nil), func(t *testing.T) {
|
||||
config.Process = process
|
||||
when := When{Always: &always, Or: or}
|
||||
match, err := when.Match(config, map[string]string{}, false)
|
||||
|
@ -135,7 +135,7 @@ func parseCRILog(log []byte, msg *logMessage) error {
|
||||
}
|
||||
// Keep this forward compatible.
|
||||
tags := bytes.Split(log[:idx], tagDelimiter)
|
||||
partial := (LogTag(tags[0]) == LogTagPartial)
|
||||
partial := LogTag(tags[0]) == LogTagPartial
|
||||
// Trim the tailing new line if this is a partial line.
|
||||
if partial && len(log) > 0 && log[len(log)-1] == '\n' {
|
||||
log = log[:len(log)-1]
|
||||
|
@ -215,7 +215,7 @@ func EnableLinger() (string, error) {
|
||||
|
||||
// If we have a D-BUS connection, attempt to read the LINGER property from it.
|
||||
if conn != nil {
|
||||
path := dbus.ObjectPath((fmt.Sprintf("/org/freedesktop/login1/user/_%s", uid)))
|
||||
path := dbus.ObjectPath(fmt.Sprintf("/org/freedesktop/login1/user/_%s", uid))
|
||||
ret, err := conn.Object("org.freedesktop.login1", path).GetProperty("org.freedesktop.login1.User.Linger")
|
||||
if err == nil && ret.Value().(bool) {
|
||||
lingerEnabled = true
|
||||
@ -265,7 +265,7 @@ func EnableLinger() (string, error) {
|
||||
|
||||
// If we have a D-BUS connection, attempt to read the RUNTIME PATH from it.
|
||||
if conn != nil {
|
||||
path := dbus.ObjectPath((fmt.Sprintf("/org/freedesktop/login1/user/_%s", uid)))
|
||||
path := dbus.ObjectPath(fmt.Sprintf("/org/freedesktop/login1/user/_%s", uid))
|
||||
ret, err := conn.Object("org.freedesktop.login1", path).GetProperty("org.freedesktop.login1.User.RuntimePath")
|
||||
if err == nil {
|
||||
return strings.Trim(ret.String(), "\"\n"), nil
|
||||
|
@ -20,7 +20,7 @@ func TestIsCpusetListAvailable(t *testing.T) {
|
||||
for _, c := range cases {
|
||||
r, err := isCpusetListAvailable(c.provided, c.available)
|
||||
if (c.err && err == nil) && r != c.res {
|
||||
t.Fatalf("Expected pair: %v, %v for %s, %s. Got %v, %v instead", c.res, c.err, c.provided, c.available, (c.err && err == nil), r)
|
||||
t.Fatalf("Expected pair: %v, %v for %s, %s. Got %v, %v instead", c.res, c.err, c.provided, c.available, c.err && err == nil, r)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
jaeger "github.com/uber/jaeger-client-go"
|
||||
config "github.com/uber/jaeger-client-go/config"
|
||||
"github.com/opentracing/opentracing-go"
|
||||
"github.com/uber/jaeger-client-go"
|
||||
"github.com/uber/jaeger-client-go/config"
|
||||
)
|
||||
|
||||
// Init returns an instance of Jaeger Tracer that samples 100% of traces and logs all spans to stdout.
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
"github.com/containers/image/types"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// PolicyContent struct for policy.json file
|
||||
|
Reference in New Issue
Block a user