Refactor remote socket path determination in tests

Separate the code that determines the directory and file prefix
from the code that chooses and applies a UUID; we will make the
second part more complex in a bit.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač
2021-11-03 15:59:23 +01:00
parent 172d4eb400
commit ee146a9ab0

View File

@@ -274,15 +274,15 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration {
} }
if remote { if remote {
uuid := stringid.GenerateNonCryptoID() var pathPrefix string
if !rootless.IsRootless() { if !rootless.IsRootless() {
p.RemoteSocket = fmt.Sprintf("unix:/run/podman/podman-%s.sock", uuid) pathPrefix = "/run/podman/podman"
} else { } else {
runtimeDir := os.Getenv("XDG_RUNTIME_DIR") runtimeDir := os.Getenv("XDG_RUNTIME_DIR")
socket := fmt.Sprintf("podman-%s.sock", uuid) pathPrefix = filepath.Join(runtimeDir, "podman")
fqpath := filepath.Join(runtimeDir, socket)
p.RemoteSocket = fmt.Sprintf("unix:%s", fqpath)
} }
uuid := stringid.GenerateNonCryptoID()
p.RemoteSocket = fmt.Sprintf("unix:%s-%s.sock", pathPrefix, uuid)
} }
// Setup registries.conf ENV variable // Setup registries.conf ENV variable