mirror of
https://github.com/containers/podman.git
synced 2025-05-17 06:59:07 +08:00
Pass all of PodmanExecOptions to various [mM]akeOptions functions
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č <mitr@redhat.com>
This commit is contained in:
@ -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" {
|
||||
|
@ -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...)
|
||||
|
@ -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,
|
||||
})
|
||||
|
@ -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),
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ var _ = Describe("Podman mount", func() {
|
||||
|
||||
// command: podman <options> unshare podman <options> 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 <options> unshare podman <options> 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/..."
|
||||
|
@ -61,7 +61,7 @@ var _ = Describe("Podman run exit", func() {
|
||||
|
||||
// command: podman <options> unshare podman <options> 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)
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
|
@ -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, " ")]
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user