Eliminate PodmanSystemdScope

It seems this utility is not all that generally useful,
so eliminate it from the global namespace and use
PodmanWithOptions directly.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač 2025-01-22 23:17:30 +01:00
parent 9363c8c362
commit df9e8c3ce6
3 changed files with 8 additions and 24 deletions

View File

@ -34,17 +34,6 @@ func (p *PodmanTestIntegration) PodmanWithOptions(options PodmanExecOptions, arg
return &PodmanSessionIntegration{podmanSession} return &PodmanSessionIntegration{podmanSession}
} }
// PodmanSystemdScope runs the podman command in a new systemd scope
func (p *PodmanTestIntegration) PodmanSystemdScope(args []string) *PodmanSessionIntegration {
wrapper := []string{"systemd-run", "--scope"}
if isRootless() {
wrapper = []string{"systemd-run", "--scope", "--user"}
}
return p.PodmanWithOptions(PodmanExecOptions{
Wrapper: wrapper,
}, args...)
}
func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() { func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() {
defaultFile := "registries.conf" defaultFile := "registries.conf"
if UsingCacheRegistry() { if UsingCacheRegistry() {

View File

@ -26,17 +26,6 @@ func (p *PodmanTestIntegration) PodmanWithOptions(options PodmanExecOptions, arg
return &PodmanSessionIntegration{podmanSession} return &PodmanSessionIntegration{podmanSession}
} }
// PodmanSystemdScope runs the podman command in a new systemd scope
func (p *PodmanTestIntegration) PodmanSystemdScope(args []string) *PodmanSessionIntegration {
wrapper := []string{"systemd-run", "--scope"}
if isRootless() {
wrapper = []string{"systemd-run", "--scope", "--user"}
}
return p.PodmanWithOptions(PodmanExecOptions{
Wrapper: wrapper,
}, args...)
}
func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() { func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() {
defaultFile := "registries.conf" defaultFile := "registries.conf"
if UsingCacheRegistry() { if UsingCacheRegistry() {

View File

@ -1704,7 +1704,13 @@ VOLUME %s`, ALPINE, volPath, volPath)
} }
} }
container := podmanTest.PodmanSystemdScope([]string{"run", "--rm", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup"}) scopeOptions := PodmanExecOptions{
Wrapper: []string{"systemd-run", "--scope"},
}
if isRootless() {
scopeOptions.Wrapper = append(scopeOptions.Wrapper, "--user")
}
container := podmanTest.PodmanWithOptions(scopeOptions, "run", "--rm", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup")
container.WaitWithDefaultTimeout() container.WaitWithDefaultTimeout()
Expect(container).Should(Exit(0)) Expect(container).Should(Exit(0))
checkLines(container.OutputToStringArray()) checkLines(container.OutputToStringArray())
@ -1713,7 +1719,7 @@ VOLUME %s`, ALPINE, volPath, volPath)
ContainSubstring("Running as unit: "))) // systemd >= 255 ContainSubstring("Running as unit: "))) // systemd >= 255
// check that --cgroups=split is honored also when a container runs in a pod // check that --cgroups=split is honored also when a container runs in a pod
container = podmanTest.PodmanSystemdScope([]string{"run", "--rm", "--pod", "new:split-test-pod", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup"}) container = podmanTest.PodmanWithOptions(scopeOptions, "run", "--rm", "--pod", "new:split-test-pod", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup")
container.WaitWithDefaultTimeout() container.WaitWithDefaultTimeout()
Expect(container).Should(Exit(0)) Expect(container).Should(Exit(0))
checkLines(container.OutputToStringArray()) checkLines(container.OutputToStringArray())