summaryrefslogtreecommitdiff
path: root/pkg/adapter
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/adapter')
-rw-r--r--pkg/adapter/client.go10
-rw-r--r--pkg/adapter/containers_remote.go28
-rw-r--r--pkg/adapter/pods_remote.go4
-rw-r--r--pkg/adapter/runtime_remote.go17
4 files changed, 29 insertions, 30 deletions
diff --git a/pkg/adapter/client.go b/pkg/adapter/client.go
index 5774ebe72..a1b2bd507 100644
--- a/pkg/adapter/client.go
+++ b/pkg/adapter/client.go
@@ -12,7 +12,7 @@ import (
"github.com/varlink/go/varlink"
)
-var remoteEndpoint *Endpoint
+var remoteEndpoint *Endpoint // nolint: deadcode,unused
func (r RemoteRuntime) RemoteEndpoint() (remoteEndpoint *Endpoint, err error) {
remoteConfigConnections, err := remoteclientconfig.ReadRemoteConfig(r.config)
@@ -26,8 +26,8 @@ func (r RemoteRuntime) RemoteEndpoint() (remoteEndpoint *Endpoint, err error) {
remoteEndpoint, err = newBridgeConnection(bridge, nil, r.cmd.LogLevel)
// if an environment variable for podman_varlink_address is defined,
// we used that as passed
- } else if address := os.Getenv("PODMAN_VARLINK_ADDRESS"); address != "" {
- logrus.Debug("creating a varlink address based on env variable: %s", address)
+ } else if address := os.Getenv("PODMAN_VARLINK_ADDRESS"); address != "" { // nolint:gocritic
+ logrus.Debugf("creating a varlink address based on env variable: %s", address)
remoteEndpoint, err = newSocketConnection(address)
// if the user provides a remote host, we use it to configure a bridge connection
} else if len(r.cmd.RemoteHost) > 0 {
@@ -35,7 +35,7 @@ func (r RemoteRuntime) RemoteEndpoint() (remoteEndpoint *Endpoint, err error) {
if len(r.cmd.RemoteUserName) < 1 {
return nil, errors.New("you must provide a username when providing a remote host name")
}
- rc := remoteclientconfig.RemoteConnection{r.cmd.RemoteHost, r.cmd.RemoteUserName, false, r.cmd.Port, r.cmd.IdentityFile, r.cmd.IgnoreHosts}
+ rc := remoteclientconfig.RemoteConnection{r.cmd.RemoteHost, r.cmd.RemoteUserName, false, r.cmd.Port, r.cmd.IdentityFile, r.cmd.IgnoreHosts} // nolint: govet
remoteEndpoint, err = newBridgeConnection("", &rc, r.cmd.LogLevel)
// if the user has a config file with connections in it
} else if len(remoteConfigConnections.Connections) > 0 {
@@ -59,7 +59,7 @@ func (r RemoteRuntime) RemoteEndpoint() (remoteEndpoint *Endpoint, err error) {
logrus.Debug("creating a varlink address based default root address")
remoteEndpoint, err = newSocketConnection(DefaultVarlinkAddress)
}
- return
+ return // nolint: nakedret
}
// Connect provides a varlink connection
diff --git a/pkg/adapter/containers_remote.go b/pkg/adapter/containers_remote.go
index fc8b524d6..777605896 100644
--- a/pkg/adapter/containers_remote.go
+++ b/pkg/adapter/containers_remote.go
@@ -341,7 +341,7 @@ func (r *LocalRuntime) RemoveContainers(ctx context.Context, cli *cliconfig.RmVa
failures[ctr] = errors.Wrapf(err, "Failed to evict container: %q", id)
continue
}
- ok = append(ok, string(id))
+ ok = append(ok, id)
}
return ok, failures, nil
}
@@ -432,7 +432,7 @@ func BatchContainerOp(ctr *Container, opts shared.PsOptions) (shared.BatchContai
// Log one or more containers over a varlink connection
func (r *LocalRuntime) Log(c *cliconfig.LogsValues, options *logs.LogOptions) error {
// GetContainersLogs
- reply, err := iopodman.GetContainersLogs().Send(r.Conn, uint64(varlink.More), c.InputArgs, c.Follow, c.Latest, options.Since.Format(time.RFC3339Nano), int64(c.Tail), c.Timestamps)
+ reply, err := iopodman.GetContainersLogs().Send(r.Conn, uint64(varlink.More), c.InputArgs, c.Follow, c.Latest, options.Since.Format(time.RFC3339Nano), c.Tail, c.Timestamps)
if err != nil {
return errors.Wrapf(err, "failed to get container logs")
}
@@ -753,15 +753,15 @@ func (r *LocalRuntime) attach(ctx context.Context, stdin, stdout *os.File, cid s
return nil, nil, err
}
defer cancel()
- defer restoreTerminal(oldTermState)
+ defer restoreTerminal(oldTermState) // nolint: errcheck
logrus.SetFormatter(&RawTtyFormatter{})
- term.SetRawTerminal(os.Stdin.Fd())
+ term.SetRawTerminal(os.Stdin.Fd()) // nolint: errcheck
}
reply, err := iopodman.Attach().Send(r.Conn, varlink.Upgrade, cid, detachKeys, start)
if err != nil {
- restoreTerminal(oldTermState)
+ restoreTerminal(oldTermState) // nolint: errcheck
return nil, nil, err
}
@@ -769,7 +769,7 @@ func (r *LocalRuntime) attach(ctx context.Context, stdin, stdout *os.File, cid s
_, err = reply()
if err != nil {
- restoreTerminal(oldTermState)
+ restoreTerminal(oldTermState) // nolint: errcheck
return nil, nil, err
}
@@ -857,7 +857,7 @@ func (r *LocalRuntime) Restart(ctx context.Context, c *cliconfig.RestartValues)
useTimeout := c.Flag("timeout").Changed || c.Flag("time").Changed
inputTimeout := c.Timeout
- if c.Latest {
+ if c.Latest { // nolint: gocritic
lastCtr, err := r.GetLatestContainer()
if err != nil {
return nil, nil, errors.Wrapf(err, "unable to get latest container")
@@ -1042,10 +1042,10 @@ func (r *LocalRuntime) ExecContainer(ctx context.Context, cli *cliconfig.ExecVal
return ec, err
}
defer cancel()
- defer restoreTerminal(oldTermState)
+ defer restoreTerminal(oldTermState) // nolint: errcheck
logrus.SetFormatter(&RawTtyFormatter{})
- term.SetRawTerminal(os.Stdin.Fd())
+ term.SetRawTerminal(os.Stdin.Fd()) // nolint: errcheck
}
opts := iopodman.ExecOpts{
@@ -1082,7 +1082,7 @@ func (r *LocalRuntime) ExecContainer(ctx context.Context, cli *cliconfig.ExecVal
return ec, err
}
-func configureVarlinkAttachStdio(reader *bufio.Reader, writer *bufio.Writer, stdin *os.File, stdout *os.File, oldTermState *term.State, resize chan remotecommand.TerminalSize, ecChan chan int) chan error {
+func configureVarlinkAttachStdio(reader *bufio.Reader, writer *bufio.Writer, stdin *os.File, stdout *os.File, oldTermState *term.State, resize chan remotecommand.TerminalSize, ecChan chan int) chan error { // nolint: interfacer
errChan := make(chan error, 1)
// These are the special writers that encode input from the client.
varlinkStdinWriter := virtwriter.NewVirtWriteCloser(writer, virtwriter.ToStdin)
@@ -1092,7 +1092,7 @@ func configureVarlinkAttachStdio(reader *bufio.Reader, writer *bufio.Writer, std
go func() {
// Read from the wire and direct to stdout or stderr
err := virtwriter.Reader(reader, stdout, os.Stderr, nil, nil, ecChan)
- defer restoreTerminal(oldTermState)
+ defer restoreTerminal(oldTermState) // nolint: errcheck
sendGenericError(ecChan)
errChan <- err
}()
@@ -1101,13 +1101,13 @@ func configureVarlinkAttachStdio(reader *bufio.Reader, writer *bufio.Writer, std
for termResize := range resize {
b, err := json.Marshal(termResize)
if err != nil {
- defer restoreTerminal(oldTermState)
+ defer restoreTerminal(oldTermState) // nolint: errcheck,staticcheck
sendGenericError(ecChan)
errChan <- err
}
_, err = varlinkResizeWriter.Write(b)
if err != nil {
- defer restoreTerminal(oldTermState)
+ defer restoreTerminal(oldTermState) // nolint: errcheck,staticcheck
sendGenericError(ecChan)
errChan <- err
}
@@ -1117,7 +1117,7 @@ func configureVarlinkAttachStdio(reader *bufio.Reader, writer *bufio.Writer, std
// Takes stdinput and sends it over the wire after being encoded
go func() {
if _, err := io.Copy(varlinkStdinWriter, stdin); err != nil {
- defer restoreTerminal(oldTermState)
+ defer restoreTerminal(oldTermState) // nolint: errcheck
sendGenericError(ecChan)
errChan <- err
}
diff --git a/pkg/adapter/pods_remote.go b/pkg/adapter/pods_remote.go
index ebd10a92a..4c6eea9a7 100644
--- a/pkg/adapter/pods_remote.go
+++ b/pkg/adapter/pods_remote.go
@@ -515,10 +515,10 @@ func (p *Pod) GetPodStats(previousContainerStats map[string]*libpod.ContainerSta
newStats := varlinkapi.ContainerStatsToLibpodContainerStats(stats)
// If the container wasn't running, don't include it
// but also suppress the error
- if err != nil && errors.Cause(err) != define.ErrCtrStateInvalid {
+ if err != nil && errors.Cause(err) != define.ErrCtrStateInvalid { // nolint: govet
return nil, err
}
- if err == nil {
+ if err == nil { // nolint: govet
newContainerStats[c.ID()] = &newStats
}
}
diff --git a/pkg/adapter/runtime_remote.go b/pkg/adapter/runtime_remote.go
index a4ac660ea..c511b70f1 100644
--- a/pkg/adapter/runtime_remote.go
+++ b/pkg/adapter/runtime_remote.go
@@ -180,7 +180,7 @@ type Pod struct {
type remotepod struct {
config *libpod.PodConfig
state *libpod.PodInspectState
- containers []libpod.PodContainerInfo
+ containers []libpod.PodContainerInfo // nolint: structcheck
Runtime *LocalRuntime
}
@@ -627,7 +627,7 @@ func (r *LocalRuntime) SendFileOverVarlink(source string) (string, error) {
return "", err
}
logrus.Debugf("sending %s over varlink connection", source)
- reply, err := iopodman.SendFile().Send(r.Conn, varlink.Upgrade, "", int64(fileInfo.Size()))
+ reply, err := iopodman.SendFile().Send(r.Conn, varlink.Upgrade, "", fileInfo.Size())
if err != nil {
return "", err
}
@@ -754,9 +754,7 @@ func (r *LocalRuntime) InspectVolumes(ctx context.Context, c *cliconfig.VolumeIn
volumes = append(volumes, vol.Name())
}
} else {
- for _, arg := range c.InputArgs {
- volumes = append(volumes, arg)
- }
+ volumes = append(volumes, c.InputArgs...)
}
for _, vol := range volumes {
@@ -855,7 +853,7 @@ func (r *LocalRuntime) SaveImage(ctx context.Context, c *cliconfig.SaveValues) e
}
}
- if err != nil {
+ if err != nil { // nolint: govet
return err
}
@@ -927,7 +925,7 @@ func IsImageNotFound(err error) bool {
if errors.Cause(err) == image.ErrNoSuchImage {
return true
}
- switch err.(type) {
+ switch err.(type) { // nolint: gocritic
case *iopodman.ImageNotFound:
return true
}
@@ -991,7 +989,7 @@ func (r *LocalRuntime) Events(c *cliconfig.EventValues) error {
Time: eTime,
Type: eType,
}
- if c.Format == formats.JSONString {
+ if c.Format == formats.JSONString { // nolint: gocritic
jsonStr, err := event.ToJSONString()
if err != nil {
return errors.Wrapf(err, "unable to format json")
@@ -1008,6 +1006,7 @@ func (r *LocalRuntime) Events(c *cliconfig.EventValues) error {
return err
}
}
+
if _, err := w.Write([]byte("\n")); err != nil {
return err
}
@@ -1040,7 +1039,7 @@ func stringToChangeType(change string) archive.ChangeType {
return archive.ChangeAdd
case "D":
return archive.ChangeDelete
- default:
+ default: // nolint: gocritic,stylecheck
logrus.Errorf("'%s' is unknown archive type", change)
fallthrough
case "C":