enable gofumpt formatter

Based on our discussion gofumpt won the vote so use that one via
golangci-lint.

https://github.com/containers/podman/discussions/27291

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2025-11-11 12:12:42 +01:00
parent 2555b8b413
commit 5c1ed12d8d
389 changed files with 1228 additions and 1600 deletions

View File

@@ -43,18 +43,21 @@ import (
)
var _ = Describe("Toolbox-specific testing", func() {
It("podman run --dns=none - allows self-management of /etc/resolv.conf", func() {
session := podmanTest.Podman([]string{"run", "--dns", "none", ALPINE, "sh", "-c",
"rm -f /etc/resolv.conf; touch -d '1970-01-01 00:02:03' /etc/resolv.conf; stat -c %s:%Y /etc/resolv.conf"})
session := podmanTest.Podman([]string{
"run", "--dns", "none", ALPINE, "sh", "-c",
"rm -f /etc/resolv.conf; touch -d '1970-01-01 00:02:03' /etc/resolv.conf; stat -c %s:%Y /etc/resolv.conf",
})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("0:123"))
})
It("podman run --no-hosts - allows self-management of /etc/hosts", func() {
session := podmanTest.Podman([]string{"run", "--no-hosts", ALPINE, "sh", "-c",
"rm -f /etc/hosts; touch -d '1970-01-01 00:02:03' /etc/hosts; stat -c %s:%Y /etc/hosts"})
session := podmanTest.Podman([]string{
"run", "--no-hosts", ALPINE, "sh", "-c",
"rm -f /etc/hosts; touch -d '1970-01-01 00:02:03' /etc/hosts; stat -c %s:%Y /etc/hosts",
})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("0:123"))
@@ -78,8 +81,10 @@ var _ = Describe("Toolbox-specific testing", func() {
Expect(err).ToNot(HaveOccurred())
GinkgoWriter.Printf("Expected value: %d", rlimit.Max)
session = podmanTest.Podman([]string{"create", "--name", "test", "--ulimit", "host", ALPINE,
"sleep", "1000"})
session = podmanTest.Podman([]string{
"create", "--name", "test", "--ulimit", "host", ALPINE,
"sleep", "1000",
})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
@@ -87,8 +92,10 @@ var _ = Describe("Toolbox-specific testing", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"exec", "test", "sh", "-c",
"ulimit -H -n"})
session = podmanTest.Podman([]string{
"exec", "test", "sh", "-c",
"ulimit -H -n",
})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
containerHardLimit, err = strconv.Atoi(strings.Trim(session.OutputToString(), "\n"))
@@ -119,8 +126,10 @@ var _ = Describe("Toolbox-specific testing", func() {
hostShmSize, err = strconv.Atoi(fields[1])
Expect(err).ToNot(HaveOccurred())
session = podmanTest.Podman([]string{"create", "--name", "test", "--ipc=host", "--pid=host", ALPINE,
"sleep", "1000"})
session = podmanTest.Podman([]string{
"create", "--name", "test", "--ipc=host", "--pid=host", ALPINE,
"sleep", "1000",
})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
@@ -128,8 +137,10 @@ var _ = Describe("Toolbox-specific testing", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"exec", "test",
"df", "/dev/shm"})
session = podmanTest.Podman([]string{
"exec", "test",
"df", "/dev/shm",
})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
lines = session.OutputToStringArray()
@@ -145,8 +156,10 @@ var _ = Describe("Toolbox-specific testing", func() {
It("podman create --userns=keep-id --user root:root - entrypoint - entrypoint is executed as root", func() {
SkipIfNotRootless("only meaningful when run rootless")
session := podmanTest.Podman([]string{"run", "--userns=keep-id", "--user", "root:root", ALPINE,
"id"})
session := podmanTest.Podman([]string{
"run", "--userns=keep-id", "--user", "root:root", ALPINE,
"id",
})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("uid=0(root) gid=0(root)"))
@@ -163,8 +176,10 @@ var _ = Describe("Toolbox-specific testing", func() {
currentGroup, err := user.LookupGroupId(currentUser.Gid)
Expect(err).ToNot(HaveOccurred())
session = podmanTest.Podman([]string{"create", "--name", "test", "--userns=keep-id", ALPINE,
"sleep", "1000"})
session = podmanTest.Podman([]string{
"create", "--name", "test", "--userns=keep-id", ALPINE,
"sleep", "1000",
})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
Expect(err).ToNot(HaveOccurred())
@@ -177,8 +192,10 @@ var _ = Describe("Toolbox-specific testing", func() {
currentUser.Uid, currentUser.Username,
currentGroup.Gid, currentGroup.Name)
session = podmanTest.Podman([]string{"exec", "test",
"id"})
session = podmanTest.Podman([]string{
"exec", "test",
"id",
})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(expectedOutput))
@@ -189,9 +206,11 @@ var _ = Describe("Toolbox-specific testing", func() {
groupLine := "testuser:x:1001:"
// ensure that the container can edit passwd and group files
session := podmanTest.Podman([]string{"run", "--log-driver", "k8s-file", "--name", "test", "--userns=keep-id",
session := podmanTest.Podman([]string{
"run", "--log-driver", "k8s-file", "--name", "test", "--userns=keep-id",
"--user", "root:root", ALPINE, "sh", "-c",
fmt.Sprintf("echo %s > /etc/passwd && echo %s > /etc/group && cat /etc/passwd && cat /etc/group", passwdLine, groupLine)})
fmt.Sprintf("echo %s > /etc/passwd && echo %s > /etc/group && cat /etc/passwd && cat /etc/group", passwdLine, groupLine),
})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).Should(ContainSubstring(passwdLine))
@@ -202,13 +221,17 @@ var _ = Describe("Toolbox-specific testing", func() {
SkipIfNotRootless("only meaningful when run rootless")
var session *PodmanSessionIntegration
session = podmanTest.Podman([]string{"run", "--privileged", "--userns=keep-id", "--user", "root:root", ALPINE,
"mount", "-t", define.TypeTmpfs, define.TypeTmpfs, "/tmp"})
session = podmanTest.Podman([]string{
"run", "--privileged", "--userns=keep-id", "--user", "root:root", ALPINE,
"mount", "-t", define.TypeTmpfs, define.TypeTmpfs, "/tmp",
})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"run", "--privileged", "--userns=keep-id", "--user", "root:root", ALPINE,
"mount", "--rbind", "/tmp", "/var/tmp"})
session = podmanTest.Podman([]string{
"run", "--privileged", "--userns=keep-id", "--user", "root:root", ALPINE,
"mount", "--rbind", "/tmp", "/var/tmp",
})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
})
@@ -218,7 +241,8 @@ var _ = Describe("Toolbox-specific testing", func() {
// These should be most of the switches that Toolbox uses to create a "toolbox" container
// https://github.com/containers/toolbox/blob/main/src/cmd/create.go
session := podmanTest.Podman([]string{"create",
session := podmanTest.Podman([]string{
"create",
"--log-driver", "k8s-file",
"--dns", "none",
"--hostname", "toolbox",
@@ -233,7 +257,8 @@ var _ = Describe("Toolbox-specific testing", func() {
"--ulimit", "host",
"--userns=keep-id",
"--user", "root:root",
ALPINE, "sh", "-c", "echo READY"})
ALPINE, "sh", "-c", "echo READY",
})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
@@ -256,13 +281,14 @@ var _ = Describe("Toolbox-specific testing", func() {
location := path.Dir(currentUser.HomeDir)
volumeArg := fmt.Sprintf("%s:%s", location, location)
session = podmanTest.Podman([]string{"run",
session = podmanTest.Podman([]string{
"run",
"--userns=keep-id",
"--volume", volumeArg,
ALPINE, "sh", "-c", "echo $HOME"})
ALPINE, "sh", "-c", "echo $HOME",
})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(currentUser.HomeDir))
})
})