From f17590b2bd889bdbbfffc728dbc44df7b5b5a92c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Wed, 22 Jan 2025 22:40:45 +0100 Subject: [PATCH] Pass all of PodmanExecOptions to various [mM]akeOptions functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will make it easier to structure the API, at the cost of making it a bit more opaque about which parts of PodmanExecOptions are implemented where. Should not change behavior. Signed-off-by: Miloslav Trmač --- test/e2e/checkpoint_test.go | 4 ++-- test/e2e/common_test.go | 8 ++++---- test/e2e/libpod_suite_remote_test.go | 6 +++--- test/e2e/manifest_test.go | 2 +- test/e2e/mount_rootless_test.go | 4 ++-- test/e2e/run_cleanup_test.go | 2 +- test/e2e/systemd_activate_test.go | 2 +- test/utils/utils.go | 10 +++++----- test/utils/utils_suite_test.go | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go index e6abe28d23..0c4a0bb4a0 100644 --- a/test/e2e/checkpoint_test.go +++ b/test/e2e/checkpoint_test.go @@ -1559,8 +1559,8 @@ var _ = Describe("Podman checkpoint", func() { // Prevent --runtime arg from being set to force using default // runtime unless explicitly set through passed args. preservedMakeOptions := podmanTest.PodmanMakeOptions - podmanTest.PodmanMakeOptions = func(args []string, noEvents, noCache bool) []string { - defaultArgs := preservedMakeOptions(args, noEvents, noCache) + podmanTest.PodmanMakeOptions = func(args []string, options PodmanExecOptions) []string { + defaultArgs := preservedMakeOptions(args, options) for i := range args { // Runtime is set explicitly, so we should keep --runtime arg. if args[i] == "--runtime" { diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 10dec2449a..a8d3b4f5e1 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -679,7 +679,7 @@ func (p *PodmanTestIntegration) BuildImageWithLabel(dockerfile, imageName string // PodmanPID execs podman and returns its PID func (p *PodmanTestIntegration) PodmanPID(args []string) (*PodmanSessionIntegration, int) { - podmanOptions := p.MakeOptions(args, false, false) + podmanOptions := p.MakeOptions(args, PodmanExecOptions{}) GinkgoWriter.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " ")) command := exec.Command(p.PodmanBinary, podmanOptions...) @@ -1140,7 +1140,7 @@ func (p *PodmanTestIntegration) PodmanNoEvents(args []string) *PodmanSessionInte } // MakeOptions assembles all the podman main options -func (p *PodmanTestIntegration) makeOptions(args []string, noEvents, noCache bool) []string { +func (p *PodmanTestIntegration) makeOptions(args []string, options PodmanExecOptions) []string { if p.RemoteTest { if !slices.Contains(args, "--remote") { return append([]string{"--remote", "--url", p.RemoteSocket}, args...) @@ -1154,7 +1154,7 @@ func (p *PodmanTestIntegration) makeOptions(args []string, noEvents, noCache boo } eventsType := "file" - if noEvents { + if options.NoEvents { eventsType = "none" } @@ -1162,7 +1162,7 @@ func (p *PodmanTestIntegration) makeOptions(args []string, noEvents, noCache boo debug, p.Root, p.RunRoot, p.OCIRuntime, p.ConmonBinary, p.NetworkConfigDir, p.NetworkBackend.ToString(), p.CgroupManager, p.TmpDir, eventsType, p.DatabaseBackend), " ") podmanOptions = append(podmanOptions, strings.Split(p.StorageOptions, " ")...) - if !noCache { + if !options.NoCache { cacheOptions := []string{"--storage-opt", fmt.Sprintf("%s.imagestore=%s", p.PodmanTest.ImageCacheFS, p.PodmanTest.ImageCacheDir)} podmanOptions = append(cacheOptions, podmanOptions...) diff --git a/test/e2e/libpod_suite_remote_test.go b/test/e2e/libpod_suite_remote_test.go index 26eeecb8a9..9744c79f88 100644 --- a/test/e2e/libpod_suite_remote_test.go +++ b/test/e2e/libpod_suite_remote_test.go @@ -24,14 +24,14 @@ func IsRemote() bool { // Podman is the exec call to podman on the filesystem func (p *PodmanTestIntegration) Podman(args []string) *PodmanSessionIntegration { - args = p.makeOptions(args, false, false) + args = p.makeOptions(args, PodmanExecOptions{}) podmanSession := p.PodmanBase(args, false, false) return &PodmanSessionIntegration{podmanSession} } // PodmanSystemdScope runs the podman command in a new systemd scope func (p *PodmanTestIntegration) PodmanSystemdScope(args []string) *PodmanSessionIntegration { - args = p.makeOptions(args, false, false) + args = p.makeOptions(args, PodmanExecOptions{}) wrapper := []string{"systemd-run", "--scope"} if isRootless() { @@ -46,7 +46,7 @@ func (p *PodmanTestIntegration) PodmanSystemdScope(args []string) *PodmanSession // PodmanExtraFiles is the exec call to podman on the filesystem and passes down extra files func (p *PodmanTestIntegration) PodmanExtraFiles(args []string, extraFiles []*os.File) *PodmanSessionIntegration { - args = p.makeOptions(args, false, false) + args = p.makeOptions(args, PodmanExecOptions{}) podmanSession := p.PodmanExecBaseWithOptions(args, PodmanExecOptions{ ExtraFiles: extraFiles, }) diff --git a/test/e2e/manifest_test.go b/test/e2e/manifest_test.go index 783e9418a9..035f67c34a 100644 --- a/test/e2e/manifest_test.go +++ b/test/e2e/manifest_test.go @@ -618,7 +618,7 @@ RUN touch /file It("authenticated push", func() { registryOptions := &podmanRegistry.Options{ PodmanPath: podmanTest.PodmanBinary, - PodmanArgs: podmanTest.MakeOptions(nil, false, false), + PodmanArgs: podmanTest.MakeOptions(nil, PodmanExecOptions{}), Image: "docker-archive:" + imageTarPath(REGISTRY_IMAGE), } diff --git a/test/e2e/mount_rootless_test.go b/test/e2e/mount_rootless_test.go index 9844f260f9..2d412230be 100644 --- a/test/e2e/mount_rootless_test.go +++ b/test/e2e/mount_rootless_test.go @@ -36,7 +36,7 @@ var _ = Describe("Podman mount", func() { // command: podman unshare podman mount cid args := []string{"unshare", podmanTest.PodmanBinary} - opts := podmanTest.PodmanMakeOptions([]string{"mount", cid}, false, false) + opts := podmanTest.PodmanMakeOptions([]string{"mount", cid}, PodmanExecOptions{}) args = append(args, opts...) // container root file system location is podmanTest.TempDir/... @@ -59,7 +59,7 @@ var _ = Describe("Podman mount", func() { // command: podman unshare podman image mount IMAGE args := []string{"unshare", podmanTest.PodmanBinary} - opts := podmanTest.PodmanMakeOptions([]string{"image", "mount", CITEST_IMAGE}, false, false) + opts := podmanTest.PodmanMakeOptions([]string{"image", "mount", CITEST_IMAGE}, PodmanExecOptions{}) args = append(args, opts...) // image location is podmanTest.TempDir/... because "--root podmanTest.TempDir/..." diff --git a/test/e2e/run_cleanup_test.go b/test/e2e/run_cleanup_test.go index 4629ddee00..9fc679c757 100644 --- a/test/e2e/run_cleanup_test.go +++ b/test/e2e/run_cleanup_test.go @@ -61,7 +61,7 @@ var _ = Describe("Podman run exit", func() { // command: podman unshare podman image mount ALPINE args := []string{"unshare", podmanTest.PodmanBinary} - opts := podmanTest.PodmanMakeOptions([]string{"mount", "--no-trunc"}, false, false) + opts := podmanTest.PodmanMakeOptions([]string{"mount", "--no-trunc"}, PodmanExecOptions{}) args = append(args, opts...) pmount := podmanTest.Podman(args) diff --git a/test/e2e/systemd_activate_test.go b/test/e2e/systemd_activate_test.go index d95b173e32..c15c80ba4f 100644 --- a/test/e2e/systemd_activate_test.go +++ b/test/e2e/systemd_activate_test.go @@ -49,7 +49,7 @@ var _ = Describe("Systemd activate", func() { Expect(err).ToNot(HaveOccurred()) addr := net.JoinHostPort(host, strconv.Itoa(port)) - podmanOptions := podmanTest.makeOptions(nil, false, false) + podmanOptions := podmanTest.makeOptions(nil, testUtils.PodmanExecOptions{}) systemdArgs := []string{ "-E", "http_proxy", "-E", "https_proxy", "-E", "no_proxy", diff --git a/test/utils/utils.go b/test/utils/utils.go index bc8049b38c..e7ba4bb1a1 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -55,7 +55,7 @@ var ( // PodmanTestCommon contains common functions will be updated later in // the inheritance structs type PodmanTestCommon interface { - MakeOptions(args []string, noEvents, noCache bool) []string + MakeOptions(args []string, options PodmanExecOptions) []string WaitForContainer() bool WaitContainerReady(id string, expStr string, timeout int, step int) bool } @@ -67,7 +67,7 @@ type PodmanTest struct { NetworkBackend NetworkBackend DatabaseBackend string PodmanBinary string - PodmanMakeOptions func(args []string, noEvents, noCache bool) []string + PodmanMakeOptions func(args []string, options PodmanExecOptions) []string RemoteCommand *exec.Cmd RemotePodmanBinary string RemoteSession *os.Process @@ -90,8 +90,8 @@ type HostOS struct { } // MakeOptions assembles all podman options -func (p *PodmanTest) MakeOptions(args []string, noEvents, noCache bool) []string { - return p.PodmanMakeOptions(args, noEvents, noCache) +func (p *PodmanTest) MakeOptions(args []string, options PodmanExecOptions) []string { + return p.PodmanMakeOptions(args, options) } // PodmanExecOptions modify behavior of PodmanTest.PodmanExecBaseWithOptions and its callers. @@ -109,7 +109,7 @@ type PodmanExecOptions struct { // PodmanExecBaseWithOptions execs podman with the specified args, and in an environment defined by options func (p *PodmanTest) PodmanExecBaseWithOptions(args []string, options PodmanExecOptions) *PodmanSession { var command *exec.Cmd - podmanOptions := p.MakeOptions(args, options.NoEvents, options.NoCache) + podmanOptions := p.MakeOptions(args, options) podmanBinary := p.PodmanBinary if p.RemoteTest { podmanBinary = p.RemotePodmanBinary diff --git a/test/utils/utils_suite_test.go b/test/utils/utils_suite_test.go index 7afdbaa367..30675354f7 100644 --- a/test/utils/utils_suite_test.go +++ b/test/utils/utils_suite_test.go @@ -31,7 +31,7 @@ func FakePodmanTestCreate() *FakePodmanTest { return p } -func (p *FakePodmanTest) makeOptions(args []string, noEvents, noCache bool) []string { +func (p *FakePodmanTest) makeOptions(args []string, options PodmanExecOptions) []string { return FakeOutputs[strings.Join(args, " ")] }