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

@@ -1239,7 +1239,7 @@ func GetPort() int {
func ncz(port int) bool {
timeout := 500 * time.Millisecond
for i := 0; i < 5; i++ {
ncCmd := []string{"-z", "localhost", fmt.Sprintf("%d", port)}
ncCmd := []string{"-z", "localhost", strconv.Itoa(port)}
GinkgoWriter.Printf("Running: nc %s\n", strings.Join(ncCmd, " "))
check := SystemExec("nc", ncCmd)
if check.ExitCode() == 0 {

View File

@@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
. "github.com/containers/podman/v4/test/utils"
@@ -433,7 +434,7 @@ var _ = Describe("Podman create", func() {
numCpus := 5
nanoCPUs := numCpus * 1000000000
ctrName := "testCtr"
session := podmanTest.Podman([]string{"create", "-t", "--cpus", fmt.Sprintf("%d", numCpus), "--name", ctrName, ALPINE, "/bin/sh"})
session := podmanTest.Podman([]string{"create", "-t", "--cpus", strconv.Itoa(numCpus), "--name", ctrName, ALPINE, "/bin/sh"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())

View File

@@ -3,6 +3,7 @@ package integration
import (
"encoding/json"
"fmt"
"strconv"
"sync"
"time"
@@ -177,7 +178,7 @@ var _ = Describe("Podman events", func() {
// unix timestamp in 10 seconds
until := time.Now().Add(time.Second * 10).Unix()
result := podmanTest.Podman([]string{"events", "--since", "30s", "--until", fmt.Sprint(until)})
result := podmanTest.Podman([]string{"events", "--since", "30s", "--until", strconv.FormatInt(until, 10)})
result.Wait(11)
Expect(result).Should(ExitCleanly())
Expect(result.OutputToString()).To(ContainSubstring(name1))

View File

@@ -4957,7 +4957,7 @@ ENV OPENJ9_JAVA_OPTIONS=%q
usernsInCtr = podmanTest.Podman([]string{"exec", getCtrNameInPod(pod), "id", "-u"})
usernsInCtr.WaitWithDefaultTimeout()
Expect(usernsInCtr).Should(ExitCleanly())
uid := fmt.Sprintf("%d", os.Geteuid())
uid := strconv.Itoa(os.Geteuid())
Expect(string(usernsInCtr.Out.Contents())).To(ContainSubstring(uid))
kube = podmanTest.PodmanNoCache([]string{"kube", "play", "--replace", "--userns=keep-id:uid=10,gid=12", kubeYaml})

View File

@@ -636,7 +636,7 @@ ENTRYPOINT ["sleep","99999"]
session := podmanTest.Podman([]string{"run", "--pod", podName, ALPINE, "id", "-u"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
uid := fmt.Sprintf("%d", os.Geteuid())
uid := strconv.Itoa(os.Geteuid())
Expect(session.OutputToString()).To(ContainSubstring(uid))
// Check passwd

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"net"
"os"
"strconv"
"strings"
"syscall"
@@ -494,9 +495,9 @@ EXPOSE 2004-2005/tcp`, ALPINE)
Expect(session).Should(ExitCleanly())
results := SystemExec("iptables", []string{"-t", "nat", "-nvL"})
Expect(results).Should(ExitCleanly())
Expect(results.OutputToString()).To(ContainSubstring(fmt.Sprintf("%d", port2)))
Expect(results.OutputToString()).To(ContainSubstring(strconv.Itoa(port2)))
ncBusy := SystemExec("nc", []string{"-l", "-p", fmt.Sprintf("%d", port1)})
ncBusy := SystemExec("nc", []string{"-l", "-p", strconv.Itoa(port1)})
Expect(ncBusy).To(ExitWithError())
})
@@ -507,7 +508,7 @@ EXPOSE 2004-2005/tcp`, ALPINE)
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
ncBusy := SystemExec("nc", []string{"-l", "-p", fmt.Sprintf("%d", port2)})
ncBusy := SystemExec("nc", []string{"-l", "-p", strconv.Itoa(port2)})
Expect(ncBusy).To(ExitWithError())
})
@@ -578,11 +579,11 @@ EXPOSE 2004-2005/tcp`, ALPINE)
slirp4netnsHelp := SystemExec("slirp4netns", []string{"--help"})
Expect(slirp4netnsHelp).Should(ExitCleanly())
networkConfiguration := "slirp4netns:outbound_addr=127.0.0.1,allow_host_loopback=true"
port := GetPort()
port := strconv.Itoa(GetPort())
if strings.Contains(slirp4netnsHelp.OutputToString(), "outbound-addr") {
ncListener := StartSystemExec("nc", []string{"-v", "-n", "-l", "-p", fmt.Sprintf("%d", port)})
session := podmanTest.Podman([]string{"run", "--network", networkConfiguration, "-dt", ALPINE, "nc", "-w", "2", "10.0.2.2", fmt.Sprintf("%d", port)})
ncListener := StartSystemExec("nc", []string{"-v", "-n", "-l", "-p", port})
session := podmanTest.Podman([]string{"run", "--network", networkConfiguration, "-dt", ALPINE, "nc", "-w", "2", "10.0.2.2", port})
session.WaitWithDefaultTimeout()
ncListener.WaitWithDefaultTimeout()
@@ -590,7 +591,7 @@ EXPOSE 2004-2005/tcp`, ALPINE)
Expect(ncListener).Should(Exit(0))
Expect(ncListener.ErrorToString()).To(ContainSubstring("Connection from 127.0.0.1"))
} else {
session := podmanTest.Podman([]string{"run", "--network", networkConfiguration, "-dt", ALPINE, "nc", "-w", "2", "10.0.2.2", fmt.Sprintf("%d", port)})
session := podmanTest.Podman([]string{"run", "--network", networkConfiguration, "-dt", ALPINE, "nc", "-w", "2", "10.0.2.2", port})
session.WaitWithDefaultTimeout()
Expect(session).To(ExitWithError())
Expect(session.ErrorToString()).To(ContainSubstring("outbound_addr not supported"))
@@ -604,15 +605,15 @@ EXPOSE 2004-2005/tcp`, ALPINE)
defer conn.Close()
ip := conn.LocalAddr().(*net.UDPAddr).IP
port := GetPort()
port := strconv.Itoa(GetPort())
slirp4netnsHelp := SystemExec("slirp4netns", []string{"--help"})
Expect(slirp4netnsHelp).Should(ExitCleanly())
networkConfiguration := fmt.Sprintf("slirp4netns:outbound_addr=%s,allow_host_loopback=true", ip.String())
if strings.Contains(slirp4netnsHelp.OutputToString(), "outbound-addr") {
ncListener := StartSystemExec("nc", []string{"-v", "-n", "-l", "-p", fmt.Sprintf("%d", port)})
session := podmanTest.Podman([]string{"run", "--network", networkConfiguration, ALPINE, "nc", "-w", "2", "10.0.2.2", fmt.Sprintf("%d", port)})
ncListener := StartSystemExec("nc", []string{"-v", "-n", "-l", "-p", port})
session := podmanTest.Podman([]string{"run", "--network", networkConfiguration, ALPINE, "nc", "-w", "2", "10.0.2.2", port})
session.Wait(30)
ncListener.Wait(30)
@@ -620,7 +621,7 @@ EXPOSE 2004-2005/tcp`, ALPINE)
Expect(ncListener).Should(Exit(0))
Expect(ncListener.ErrorToString()).To(ContainSubstring("Connection from " + ip.String()))
} else {
session := podmanTest.Podman([]string{"run", "--network", networkConfiguration, ALPINE, "nc", "-w", "2", "10.0.2.2", fmt.Sprintf("%d", port)})
session := podmanTest.Podman([]string{"run", "--network", networkConfiguration, ALPINE, "nc", "-w", "2", "10.0.2.2", port})
session.Wait(30)
Expect(session).To(ExitWithError())
Expect(session.ErrorToString()).To(ContainSubstring("outbound_addr not supported"))

View File

@@ -5,6 +5,7 @@ import (
"os"
"os/user"
"path/filepath"
"strconv"
"strings"
. "github.com/containers/podman/v4/test/utils"
@@ -61,7 +62,7 @@ var _ = Describe("Podman UserNS support", func() {
Expect(session).Should(ExitCleanly())
// `1024` is the default size or length of the range of user IDs
// that is mapped between the two user namespaces by --userns=auto.
Expect(session.OutputToString()).To(ContainSubstring(fmt.Sprintf("%d", storage.AutoUserNsMinSize)))
Expect(session.OutputToString()).To(ContainSubstring(strconv.Itoa(storage.AutoUserNsMinSize)))
})
It("podman uidmapping and gidmapping", func() {
@@ -116,7 +117,7 @@ var _ = Describe("Podman UserNS support", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
uid := fmt.Sprintf("%d", os.Geteuid())
uid := strconv.Itoa(os.Geteuid())
Expect(session.OutputToString()).To(ContainSubstring(uid))
session = podmanTest.Podman([]string{"run", "--userns=keep-id:uid=10,gid=12", "alpine", "sh", "-c", "echo $(id -u):$(id -g)"})

View File

@@ -190,7 +190,7 @@ registries = []`
if !WaitContainerReady(podmanTest, "registry", "listening on", 20, 1) {
Fail("Cannot start docker registry on port %s", port)
}
ep := endpoint{Port: fmt.Sprintf("%d", port), Host: "localhost"}
ep := endpoint{Port: strconv.Itoa(port), Host: "localhost"}
search := podmanTest.Podman([]string{"search",
fmt.Sprintf("%s/fake/image:andtag", ep.Address()), "--tls-verify=false"})
search.WaitWithDefaultTimeout()
@@ -215,7 +215,7 @@ registries = []`
if !WaitContainerReady(podmanTest, "registry3", "listening on", 20, 1) {
Fail("Cannot start docker registry on port %s", port)
}
ep := endpoint{Port: fmt.Sprintf("%d", port), Host: "localhost"}
ep := endpoint{Port: strconv.Itoa(port), Host: "localhost"}
err = podmanTest.RestoreArtifact(ALPINE)
Expect(err).ToNot(HaveOccurred())
image := fmt.Sprintf("%s/my-alpine", ep.Address())
@@ -242,7 +242,7 @@ registries = []`
}
port := GetPort()
ep := endpoint{Port: fmt.Sprintf("%d", port), Host: "localhost"}
ep := endpoint{Port: strconv.Itoa(port), Host: "localhost"}
registry := podmanTest.Podman([]string{"run", "-d", "-p", fmt.Sprintf("%d:5000", port),
"--name", "registry4", REGISTRY_IMAGE, "/entrypoint.sh", "/etc/docker/registry/config.yml"})
registry.WaitWithDefaultTimeout()
@@ -286,7 +286,7 @@ registries = []`
Skip("No registry image for ppc64le")
}
port := GetPort()
ep := endpoint{Port: fmt.Sprintf("%d", port), Host: "localhost"}
ep := endpoint{Port: strconv.Itoa(port), Host: "localhost"}
registry := podmanTest.Podman([]string{"run", "-d", "-p", fmt.Sprintf("%d:5000", port),
"--name", "registry5", REGISTRY_IMAGE})
registry.WaitWithDefaultTimeout()
@@ -326,7 +326,7 @@ registries = []`
Skip("No registry image for ppc64le")
}
port := GetPort()
ep := endpoint{Port: fmt.Sprintf("%d", port), Host: "localhost"}
ep := endpoint{Port: strconv.Itoa(port), Host: "localhost"}
registry := podmanTest.Podman([]string{"run", "-d", "-p", fmt.Sprintf("%d:5000", port),
"--name", "registry6", REGISTRY_IMAGE})
registry.WaitWithDefaultTimeout()