mirror of https://github.com/containers/podman.git
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:
parent
f2d552f5db
commit
f17590b2bd
|
@ -1559,8 +1559,8 @@ var _ = Describe("Podman checkpoint", func() {
|
||||||
// Prevent --runtime arg from being set to force using default
|
// Prevent --runtime arg from being set to force using default
|
||||||
// runtime unless explicitly set through passed args.
|
// runtime unless explicitly set through passed args.
|
||||||
preservedMakeOptions := podmanTest.PodmanMakeOptions
|
preservedMakeOptions := podmanTest.PodmanMakeOptions
|
||||||
podmanTest.PodmanMakeOptions = func(args []string, noEvents, noCache bool) []string {
|
podmanTest.PodmanMakeOptions = func(args []string, options PodmanExecOptions) []string {
|
||||||
defaultArgs := preservedMakeOptions(args, noEvents, noCache)
|
defaultArgs := preservedMakeOptions(args, options)
|
||||||
for i := range args {
|
for i := range args {
|
||||||
// Runtime is set explicitly, so we should keep --runtime arg.
|
// Runtime is set explicitly, so we should keep --runtime arg.
|
||||||
if args[i] == "--runtime" {
|
if args[i] == "--runtime" {
|
||||||
|
|
|
@ -679,7 +679,7 @@ func (p *PodmanTestIntegration) BuildImageWithLabel(dockerfile, imageName string
|
||||||
|
|
||||||
// PodmanPID execs podman and returns its PID
|
// PodmanPID execs podman and returns its PID
|
||||||
func (p *PodmanTestIntegration) PodmanPID(args []string) (*PodmanSessionIntegration, int) {
|
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, " "))
|
GinkgoWriter.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " "))
|
||||||
|
|
||||||
command := exec.Command(p.PodmanBinary, 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
|
// 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 p.RemoteTest {
|
||||||
if !slices.Contains(args, "--remote") {
|
if !slices.Contains(args, "--remote") {
|
||||||
return append([]string{"--remote", "--url", p.RemoteSocket}, args...)
|
return append([]string{"--remote", "--url", p.RemoteSocket}, args...)
|
||||||
|
@ -1154,7 +1154,7 @@ func (p *PodmanTestIntegration) makeOptions(args []string, noEvents, noCache boo
|
||||||
}
|
}
|
||||||
|
|
||||||
eventsType := "file"
|
eventsType := "file"
|
||||||
if noEvents {
|
if options.NoEvents {
|
||||||
eventsType = "none"
|
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), " ")
|
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, " ")...)
|
podmanOptions = append(podmanOptions, strings.Split(p.StorageOptions, " ")...)
|
||||||
if !noCache {
|
if !options.NoCache {
|
||||||
cacheOptions := []string{"--storage-opt",
|
cacheOptions := []string{"--storage-opt",
|
||||||
fmt.Sprintf("%s.imagestore=%s", p.PodmanTest.ImageCacheFS, p.PodmanTest.ImageCacheDir)}
|
fmt.Sprintf("%s.imagestore=%s", p.PodmanTest.ImageCacheFS, p.PodmanTest.ImageCacheDir)}
|
||||||
podmanOptions = append(cacheOptions, podmanOptions...)
|
podmanOptions = append(cacheOptions, podmanOptions...)
|
||||||
|
|
|
@ -24,14 +24,14 @@ func IsRemote() bool {
|
||||||
|
|
||||||
// Podman is the exec call to podman on the filesystem
|
// Podman is the exec call to podman on the filesystem
|
||||||
func (p *PodmanTestIntegration) Podman(args []string) *PodmanSessionIntegration {
|
func (p *PodmanTestIntegration) Podman(args []string) *PodmanSessionIntegration {
|
||||||
args = p.makeOptions(args, false, false)
|
args = p.makeOptions(args, PodmanExecOptions{})
|
||||||
podmanSession := p.PodmanBase(args, false, false)
|
podmanSession := p.PodmanBase(args, false, false)
|
||||||
return &PodmanSessionIntegration{podmanSession}
|
return &PodmanSessionIntegration{podmanSession}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PodmanSystemdScope runs the podman command in a new systemd scope
|
// PodmanSystemdScope runs the podman command in a new systemd scope
|
||||||
func (p *PodmanTestIntegration) PodmanSystemdScope(args []string) *PodmanSessionIntegration {
|
func (p *PodmanTestIntegration) PodmanSystemdScope(args []string) *PodmanSessionIntegration {
|
||||||
args = p.makeOptions(args, false, false)
|
args = p.makeOptions(args, PodmanExecOptions{})
|
||||||
|
|
||||||
wrapper := []string{"systemd-run", "--scope"}
|
wrapper := []string{"systemd-run", "--scope"}
|
||||||
if isRootless() {
|
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
|
// 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 {
|
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{
|
podmanSession := p.PodmanExecBaseWithOptions(args, PodmanExecOptions{
|
||||||
ExtraFiles: extraFiles,
|
ExtraFiles: extraFiles,
|
||||||
})
|
})
|
||||||
|
|
|
@ -618,7 +618,7 @@ RUN touch /file
|
||||||
It("authenticated push", func() {
|
It("authenticated push", func() {
|
||||||
registryOptions := &podmanRegistry.Options{
|
registryOptions := &podmanRegistry.Options{
|
||||||
PodmanPath: podmanTest.PodmanBinary,
|
PodmanPath: podmanTest.PodmanBinary,
|
||||||
PodmanArgs: podmanTest.MakeOptions(nil, false, false),
|
PodmanArgs: podmanTest.MakeOptions(nil, PodmanExecOptions{}),
|
||||||
Image: "docker-archive:" + imageTarPath(REGISTRY_IMAGE),
|
Image: "docker-archive:" + imageTarPath(REGISTRY_IMAGE),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ var _ = Describe("Podman mount", func() {
|
||||||
|
|
||||||
// command: podman <options> unshare podman <options> mount cid
|
// command: podman <options> unshare podman <options> mount cid
|
||||||
args := []string{"unshare", podmanTest.PodmanBinary}
|
args := []string{"unshare", podmanTest.PodmanBinary}
|
||||||
opts := podmanTest.PodmanMakeOptions([]string{"mount", cid}, false, false)
|
opts := podmanTest.PodmanMakeOptions([]string{"mount", cid}, PodmanExecOptions{})
|
||||||
args = append(args, opts...)
|
args = append(args, opts...)
|
||||||
|
|
||||||
// container root file system location is podmanTest.TempDir/...
|
// 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
|
// command: podman <options> unshare podman <options> image mount IMAGE
|
||||||
args := []string{"unshare", podmanTest.PodmanBinary}
|
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...)
|
args = append(args, opts...)
|
||||||
|
|
||||||
// image location is podmanTest.TempDir/... because "--root podmanTest.TempDir/..."
|
// 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
|
// command: podman <options> unshare podman <options> image mount ALPINE
|
||||||
args := []string{"unshare", podmanTest.PodmanBinary}
|
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...)
|
args = append(args, opts...)
|
||||||
|
|
||||||
pmount := podmanTest.Podman(args)
|
pmount := podmanTest.Podman(args)
|
||||||
|
|
|
@ -49,7 +49,7 @@ var _ = Describe("Systemd activate", func() {
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
addr := net.JoinHostPort(host, strconv.Itoa(port))
|
addr := net.JoinHostPort(host, strconv.Itoa(port))
|
||||||
|
|
||||||
podmanOptions := podmanTest.makeOptions(nil, false, false)
|
podmanOptions := podmanTest.makeOptions(nil, testUtils.PodmanExecOptions{})
|
||||||
|
|
||||||
systemdArgs := []string{
|
systemdArgs := []string{
|
||||||
"-E", "http_proxy", "-E", "https_proxy", "-E", "no_proxy",
|
"-E", "http_proxy", "-E", "https_proxy", "-E", "no_proxy",
|
||||||
|
|
|
@ -55,7 +55,7 @@ var (
|
||||||
// PodmanTestCommon contains common functions will be updated later in
|
// PodmanTestCommon contains common functions will be updated later in
|
||||||
// the inheritance structs
|
// the inheritance structs
|
||||||
type PodmanTestCommon interface {
|
type PodmanTestCommon interface {
|
||||||
MakeOptions(args []string, noEvents, noCache bool) []string
|
MakeOptions(args []string, options PodmanExecOptions) []string
|
||||||
WaitForContainer() bool
|
WaitForContainer() bool
|
||||||
WaitContainerReady(id string, expStr string, timeout int, step int) bool
|
WaitContainerReady(id string, expStr string, timeout int, step int) bool
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ type PodmanTest struct {
|
||||||
NetworkBackend NetworkBackend
|
NetworkBackend NetworkBackend
|
||||||
DatabaseBackend string
|
DatabaseBackend string
|
||||||
PodmanBinary string
|
PodmanBinary string
|
||||||
PodmanMakeOptions func(args []string, noEvents, noCache bool) []string
|
PodmanMakeOptions func(args []string, options PodmanExecOptions) []string
|
||||||
RemoteCommand *exec.Cmd
|
RemoteCommand *exec.Cmd
|
||||||
RemotePodmanBinary string
|
RemotePodmanBinary string
|
||||||
RemoteSession *os.Process
|
RemoteSession *os.Process
|
||||||
|
@ -90,8 +90,8 @@ type HostOS struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MakeOptions assembles all podman options
|
// MakeOptions assembles all podman options
|
||||||
func (p *PodmanTest) MakeOptions(args []string, noEvents, noCache bool) []string {
|
func (p *PodmanTest) MakeOptions(args []string, options PodmanExecOptions) []string {
|
||||||
return p.PodmanMakeOptions(args, noEvents, noCache)
|
return p.PodmanMakeOptions(args, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PodmanExecOptions modify behavior of PodmanTest.PodmanExecBaseWithOptions and its callers.
|
// 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
|
// PodmanExecBaseWithOptions execs podman with the specified args, and in an environment defined by options
|
||||||
func (p *PodmanTest) PodmanExecBaseWithOptions(args []string, options PodmanExecOptions) *PodmanSession {
|
func (p *PodmanTest) PodmanExecBaseWithOptions(args []string, options PodmanExecOptions) *PodmanSession {
|
||||||
var command *exec.Cmd
|
var command *exec.Cmd
|
||||||
podmanOptions := p.MakeOptions(args, options.NoEvents, options.NoCache)
|
podmanOptions := p.MakeOptions(args, options)
|
||||||
podmanBinary := p.PodmanBinary
|
podmanBinary := p.PodmanBinary
|
||||||
if p.RemoteTest {
|
if p.RemoteTest {
|
||||||
podmanBinary = p.RemotePodmanBinary
|
podmanBinary = p.RemotePodmanBinary
|
||||||
|
|
|
@ -31,7 +31,7 @@ func FakePodmanTestCreate() *FakePodmanTest {
|
||||||
return p
|
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, " ")]
|
return FakeOutputs[strings.Join(args, " ")]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue