mirror of
https://github.com/containers/podman.git
synced 2025-06-02 02:26:52 +08:00
lint: fix warnings found by perfsprint
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}()
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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 != "" {
|
||||
|
@ -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)}...)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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())
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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.
|
||||
|
@ -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},
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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())
|
||||
|
||||
|
@ -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))
|
||||
|
@ -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})
|
||||
|
@ -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
|
||||
|
@ -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"))
|
||||
|
@ -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)"})
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user