diff --git a/cmd/podman/containers/stats.go b/cmd/podman/containers/stats.go index 576ecc2705..cdf1928ab8 100644 --- a/cmd/podman/containers/stats.go +++ b/cmd/podman/containers/stats.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "os" + "strconv" tm "github.com/buger/goterm" "github.com/containers/common/pkg/completion" @@ -222,7 +223,7 @@ func (s *containerStats) BlockIO() string { } func (s *containerStats) PIDS() string { - return fmt.Sprintf("%d", s.PIDs) + return strconv.FormatUint(s.PIDs, 10) } func (s *containerStats) MemUsage() string { diff --git a/libpod/container_internal_common.go b/libpod/container_internal_common.go index 89aa607593..15485efa40 100644 --- a/libpod/container_internal_common.go +++ b/libpod/container_internal_common.go @@ -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 } diff --git a/libpod/container_log.go b/libpod/container_log.go index cce587a2f0..5d399b7129 100644 --- a/libpod/container_log.go +++ b/libpod/container_log.go @@ -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) } }() diff --git a/libpod/events.go b/libpod/events.go index 0ce737e2bf..7d148b86dd 100644 --- a/libpod/events.go +++ b/libpod/events.go @@ -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 } diff --git a/libpod/lock/file/file_lock_test.go b/libpod/lock/file/file_lock_test.go index 2d7dded23b..6fe2e10e3b 100644 --- a/libpod/lock/file/file_lock_test.go +++ b/libpod/lock/file/file_lock_test.go @@ -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) diff --git a/libpod/oci_conmon_common.go b/libpod/oci_conmon_common.go index 3eac697651..f0cbbdf870 100644 --- a/libpod/oci_conmon_common.go +++ b/libpod/oci_conmon_common.go @@ -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 != "" { diff --git a/libpod/oci_conmon_exec_common.go b/libpod/oci_conmon_exec_common.go index 22d1217665..88e24233bd 100644 --- a/libpod/oci_conmon_exec_common.go +++ b/libpod/oci_conmon_exec_common.go @@ -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)}...) } } diff --git a/libpod/util.go b/libpod/util.go index ce2ce2d96f..4069e31cd0 100644 --- a/libpod/util.go +++ b/libpod/util.go @@ -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 } diff --git a/pkg/domain/infra/abi/pods_stats.go b/pkg/domain/infra/abi/pods_stats.go index a270db769f..447ceab9de 100644 --- a/pkg/domain/infra/abi/pods_stats.go +++ b/pkg/domain/infra/abi/pods_stats.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "strconv" "github.com/containers/common/pkg/cgroups" "github.com/containers/podman/v4/libpod" @@ -90,5 +91,5 @@ func pidsToString(pid uint64) string { // If things go bazinga, return a safe value return "--" } - return fmt.Sprintf("%d", pid) + return strconv.FormatUint(pid, 10) } diff --git a/pkg/rootless/rootless_linux.go b/pkg/rootless/rootless_linux.go index 76d7b982a5..7b69cf5bf3 100644 --- a/pkg/rootless/rootless_linux.go +++ b/pkg/rootless/rootless_linux.go @@ -64,10 +64,10 @@ func IsRootless() bool { if err := os.Setenv("_CONTAINERS_USERNS_CONFIGURED", "done"); err != nil { logrus.Errorf("Failed to set environment variable %s as %s", "_CONTAINERS_USERNS_CONFIGURED", "done") } - if err := os.Setenv("_CONTAINERS_ROOTLESS_UID", fmt.Sprintf("%d", rootlessUIDInit)); err != nil { + if err := os.Setenv("_CONTAINERS_ROOTLESS_UID", strconv.Itoa(rootlessUIDInit)); err != nil { logrus.Errorf("Failed to set environment variable %s as %d", "_CONTAINERS_ROOTLESS_UID", rootlessUIDInit) } - if err := os.Setenv("_CONTAINERS_ROOTLESS_GID", fmt.Sprintf("%d", rootlessGIDInit)); err != nil { + if err := os.Setenv("_CONTAINERS_ROOTLESS_GID", strconv.Itoa(rootlessGIDInit)); err != nil { logrus.Errorf("Failed to set environment variable %s as %d", "_CONTAINERS_ROOTLESS_GID", rootlessGIDInit) } } @@ -132,7 +132,7 @@ func tryMappingTool(uid bool, pid int, hostID int, mappings []idtools.IDMap) err return append(l, strconv.Itoa(a), strconv.Itoa(b), strconv.Itoa(c)) } - args := []string{path, fmt.Sprintf("%d", pid)} + args := []string{path, strconv.Itoa(pid)} args = appendTriplet(args, 0, hostID, 1) for _, i := range mappings { if hostID >= i.HostID && hostID < i.HostID+i.Size { diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go index a9b742ebe2..5bb135d19f 100644 --- a/pkg/specgen/generate/kube/kube.go +++ b/pkg/specgen/generate/kube/kube.go @@ -867,7 +867,7 @@ func setupSecurityContext(s *specgen.SpecGenerator, securityContext *v1.Security runAsUser = podSecurityContext.RunAsUser } if runAsUser != nil { - s.User = fmt.Sprintf("%d", *runAsUser) + s.User = strconv.FormatInt(*runAsUser, 10) } runAsGroup := securityContext.RunAsGroup @@ -881,7 +881,7 @@ func setupSecurityContext(s *specgen.SpecGenerator, securityContext *v1.Security s.User = fmt.Sprintf("%s:%d", s.User, *runAsGroup) } for _, group := range podSecurityContext.SupplementalGroups { - s.Groups = append(s.Groups, fmt.Sprintf("%d", group)) + s.Groups = append(s.Groups, strconv.FormatInt(group, 10)) } } diff --git a/pkg/systemd/activation_test.go b/pkg/systemd/activation_test.go index d2553777bd..687472206f 100644 --- a/pkg/systemd/activation_test.go +++ b/pkg/systemd/activation_test.go @@ -1,8 +1,8 @@ package systemd import ( - "fmt" "os" + "strconv" "testing" "github.com/stretchr/testify/assert" @@ -18,7 +18,7 @@ func TestSocketActivated(t *testing.T) { assert.False(SocketActivated()) // same pid no fds - assert.NoError(os.Setenv("LISTEN_PID", fmt.Sprintf("%d", os.Getpid()))) + assert.NoError(os.Setenv("LISTEN_PID", strconv.Itoa(os.Getpid()))) assert.NoError(os.Setenv("LISTEN_FDS", "0")) assert.False(SocketActivated()) diff --git a/pkg/systemd/generate/containers.go b/pkg/systemd/generate/containers.go index db641c70de..fb4485735a 100644 --- a/pkg/systemd/generate/containers.go +++ b/pkg/systemd/generate/containers.go @@ -500,7 +500,7 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst } if info.GenerateTimestamp { - info.TimeStamp = fmt.Sprintf("%v", time.Now().Format(time.UnixDate)) + info.TimeStamp = time.Now().Format(time.UnixDate) } // Sort the slices to assure a deterministic output. sort.Strings(info.BoundToServices) diff --git a/pkg/systemd/generate/pods.go b/pkg/systemd/generate/pods.go index 94cebccbbf..7433d9dbdb 100644 --- a/pkg/systemd/generate/pods.go +++ b/pkg/systemd/generate/pods.go @@ -384,7 +384,7 @@ func executePodTemplate(info *podInfo, options entities.GenerateSystemdOptions) } if info.GenerateTimestamp { - info.TimeStamp = fmt.Sprintf("%v", time.Now().Format(time.UnixDate)) + info.TimeStamp = time.Now().Format(time.UnixDate) } // Sort the slices to assure a deterministic output. diff --git a/pkg/timetype/timestamp_test.go b/pkg/timetype/timestamp_test.go index 0fffb85a9b..a29e53b8fc 100644 --- a/pkg/timetype/timestamp_test.go +++ b/pkg/timetype/timestamp_test.go @@ -3,7 +3,7 @@ package timetype // code adapted from https://github.com/moby/moby/blob/master/api/types/time/timestamp.go import ( - "fmt" + "strconv" "testing" "time" ) @@ -47,9 +47,9 @@ func TestGetTimestamp(t *testing.T) { {"1136073600", "1136073600", false}, {"1136073600.000000001", "1136073600.000000001", false}, // Durations - {"1m", fmt.Sprintf("%d", now.Add(-1*time.Minute).Unix()), false}, - {"1.5h", fmt.Sprintf("%d", now.Add(-90*time.Minute).Unix()), false}, - {"1h30m", fmt.Sprintf("%d", now.Add(-90*time.Minute).Unix()), false}, + {"1m", strconv.FormatInt(now.Add(-1*time.Minute).Unix(), 10), false}, + {"1.5h", strconv.FormatInt(now.Add(-90*time.Minute).Unix(), 10), false}, + {"1h30m", strconv.FormatInt(now.Add(-90*time.Minute).Unix(), 10), false}, {"invalid", "", true}, {"", "", true}, diff --git a/pkg/util/utils_supported.go b/pkg/util/utils_supported.go index b269b97011..406d56ce6f 100644 --- a/pkg/util/utils_supported.go +++ b/pkg/util/utils_supported.go @@ -11,6 +11,7 @@ import ( "fmt" "os" "path/filepath" + "strconv" "syscall" "github.com/containers/podman/v4/pkg/rootless" @@ -33,7 +34,7 @@ func GetRuntimeDir() (string, error) { return } - uid := fmt.Sprintf("%d", rootless.GetRootlessUID()) + uid := strconv.Itoa(rootless.GetRootlessUID()) if runtimeDir == "" { tmpDir := filepath.Join("/run", "user", uid) if err := os.MkdirAll(tmpDir, 0700); err != nil { diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 927b0407a0..713c56ea22 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -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 { diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index 2ec49b2794..b03d12cd4b 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -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()) diff --git a/test/e2e/events_test.go b/test/e2e/events_test.go index 0679a356cd..cf62c8a8de 100644 --- a/test/e2e/events_test.go +++ b/test/e2e/events_test.go @@ -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)) diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 38139e159c..b1ba5431d3 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -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}) diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index d9ea79d96e..3be0213b51 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -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 diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index d8712547ac..3f85fee821 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -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")) diff --git a/test/e2e/run_userns_test.go b/test/e2e/run_userns_test.go index 923f7accf7..d24251f17e 100644 --- a/test/e2e/run_userns_test.go +++ b/test/e2e/run_userns_test.go @@ -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)"}) diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go index 3d6e6cc7e2..981e1adc4b 100644 --- a/test/e2e/search_test.go +++ b/test/e2e/search_test.go @@ -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()