lint: fix warnings found by perfsprint

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2023-10-20 16:21:12 +02:00
parent 64f43fed4d
commit 29273cda10
24 changed files with 62 additions and 53 deletions

View File

@ -547,7 +547,7 @@ func (c *Container) generateSpec(ctx context.Context) (s *spec.Spec, cleanupFunc
}
g.SetRootPath(c.state.Mountpoint)
g.AddAnnotation("org.opencontainers.image.stopSignal", fmt.Sprintf("%d", c.config.StopSignal))
g.AddAnnotation("org.opencontainers.image.stopSignal", strconv.FormatUint(uint64(c.config.StopSignal), 10))
if _, exists := g.Config.Annotations[annotations.ContainerManager]; !exists {
g.AddAnnotation(annotations.ContainerManager, annotations.ContainerManagerLibpod)
@ -2599,11 +2599,11 @@ func (c *Container) generateUserPasswdEntry(addedUID int) (string, error) {
}
if c.config.PasswdEntry != "" {
entry := c.passwdEntry(fmt.Sprintf("%d", uid), fmt.Sprintf("%d", uid), fmt.Sprintf("%d", gid), "container user", c.WorkingDir())
entry := c.passwdEntry(strconv.FormatUint(uid, 10), strconv.FormatUint(uid, 10), strconv.FormatInt(int64(gid), 10), "container user", c.WorkingDir())
return entry, nil
}
u, err := user.LookupId(fmt.Sprintf("%d", uid))
u, err := user.LookupId(strconv.FormatUint(uid, 10))
if err == nil {
return fmt.Sprintf("%s:*:%d:%d:%s:%s:/bin/sh\n", u.Username, uid, gid, u.Name, c.WorkingDir()), nil
}

View File

@ -155,7 +155,7 @@ func (c *Container) readFromLogFile(ctx context.Context, options *logs.LogOption
// before stopping the file logger (see #10675).
time.Sleep(watch.POLL_DURATION)
tailError := t.StopAtEOF()
if tailError != nil && fmt.Sprintf("%v", tailError) != "tail: stop at eof" {
if tailError != nil && tailError.Error() != "tail: stop at eof" {
logrus.Errorf("Stopping logger: %v", tailError)
}
}()

View File

@ -69,7 +69,7 @@ func (c *Container) newContainerEventWithInspectData(status events.Status, inspe
if status == events.HealthStatus {
containerHealthStatus, err := c.healthCheckStatus()
if err != nil {
e.HealthStatus = fmt.Sprintf("%v", err)
e.HealthStatus = err.Error()
}
e.HealthStatus = containerHealthStatus
}

View File

@ -1,10 +1,10 @@
package file
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strconv"
"testing"
"github.com/stretchr/testify/assert"
@ -58,7 +58,7 @@ func TestLockAndUnlock(t *testing.T) {
lslocks, err := exec.LookPath("lslocks")
if err == nil {
lockPath := l.getLockPath(lock)
out, err := exec.Command(lslocks, "--json", "-p", fmt.Sprintf("%d", os.Getpid())).CombinedOutput()
out, err := exec.Command(lslocks, "--json", "-p", strconv.Itoa(os.Getpid())).CombinedOutput()
assert.NoError(t, err)
assert.Contains(t, string(out), lockPath)

View File

@ -375,9 +375,9 @@ func (r *ConmonOCIRuntime) killContainer(ctr *Container, signal uint, all, captu
var args []string
args = append(args, r.runtimeFlags...)
if all {
args = append(args, "kill", "--all", ctr.ID(), fmt.Sprintf("%d", signal))
args = append(args, "kill", "--all", ctr.ID(), strconv.FormatUint(uint64(signal), 10))
} else {
args = append(args, "kill", ctr.ID(), fmt.Sprintf("%d", signal))
args = append(args, "kill", ctr.ID(), strconv.FormatUint(uint64(signal), 10))
}
var (
stderr io.Writer = os.Stderr
@ -1128,7 +1128,7 @@ func (r *ConmonOCIRuntime) createOCIContainer(ctr *Container, restoreOptions *Co
}
if preserveFDs > 0 {
args = append(args, formatRuntimeOpts("--preserve-fds", fmt.Sprintf("%d", preserveFDs))...)
args = append(args, formatRuntimeOpts("--preserve-fds", strconv.FormatUint(uint64(preserveFDs), 10))...)
}
if restoreOptions != nil {
@ -1388,7 +1388,7 @@ func (r *ConmonOCIRuntime) sharedConmonArgs(ctr *Container, cuuid, bundlePath, p
size = ctr.config.LogSize
}
if size > 0 {
args = append(args, "--log-size-max", fmt.Sprintf("%v", size))
args = append(args, "--log-size-max", strconv.FormatInt(size, 10))
}
if ociLogPath != "" {

View File

@ -7,6 +7,7 @@ import (
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"syscall"
"time"
@ -387,7 +388,7 @@ func (r *ConmonOCIRuntime) startExec(c *Container, sessionID string, options *Ex
args := r.sharedConmonArgs(c, sessionID, c.execBundlePath(sessionID), c.execPidPath(sessionID), c.execLogPath(sessionID), c.execExitFileDir(sessionID), ociLog, define.NoLogging, c.config.LogTag)
if options.PreserveFDs > 0 {
args = append(args, formatRuntimeOpts("--preserve-fds", fmt.Sprintf("%d", options.PreserveFDs))...)
args = append(args, formatRuntimeOpts("--preserve-fds", strconv.FormatUint(uint64(options.PreserveFDs), 10))...)
}
if options.Terminal {
@ -410,7 +411,7 @@ func (r *ConmonOCIRuntime) startExec(c *Container, sessionID string, options *Ex
args = append(args, []string{"--exit-command-arg", arg}...)
}
if options.ExitCommandDelay > 0 {
args = append(args, []string{"--exit-delay", fmt.Sprintf("%d", options.ExitCommandDelay)}...)
args = append(args, []string{"--exit-delay", strconv.FormatUint(uint64(options.ExitCommandDelay), 10)}...)
}
}

View File

@ -9,6 +9,7 @@ import (
"os"
"path/filepath"
"sort"
"strconv"
"strings"
"time"
@ -232,7 +233,7 @@ func makeInspectPorts(bindings []types.PortMapping, expose map[uint16][]string)
hostPorts := portBindings[key]
hostPorts = append(hostPorts, define.InspectHostPort{
HostIP: port.HostIP,
HostPort: fmt.Sprintf("%d", port.HostPort+i),
HostPort: strconv.FormatUint(uint64(port.HostPort+i), 10),
})
portBindings[key] = hostPorts
}