Code review comment: The reason I had to even touch this code is because if I have the `container-image-podman` extension present but I have both docker & podman installed on my machine, it was always finding docker first and trying to build with docker.  This change makes it so the caller can control the search order (if they want to - its backwards compatible to other callers that don't care).

Code before review:
private static ContainerRuntime getContainerRuntimeEnvironment(List<ContainerRuntime> orderToCheckRuntimes) {
var runtimesToCheck = new ArrayList<>(orderToCheckRuntimes.stream().distinct().toList());
runtimesToCheck.retainAll(List.of(ContainerRuntime.DOCKER, ContainerRuntime.PODMAN));
if (CONTAINER_EXECUTABLE != null) {
var runtime = runtimesToCheck.stream()
.filter(containerRuntime -> CONTAINER_EXECUTABLE.trim()
.equalsIgnoreCase(containerRuntime.getExecutableName()))
.findFirst()
.filter(r -> {
var versionOutput = getVersionOutputFor(r);
return switch (r) {
case DOCKER, DOCKER_ROOTLESS -> versionOutput.contains("Docker version");
case PODMAN, PODMAN_ROOTLESS -> PODMAN_PATTERN.matcher(versionOutput).matches();
default -> false;
};
});
if (runtime.isPresent()) {
return runtime.get();
} else {
log.warn("quarkus.native.container-runtime config property must be set to either podman or docker " +
"and the executable must be available. Ignoring it.");
}
}
for (var runtime : runtimesToCheck) {
var versionOutput = getVersionOutputFor(runtime);
switch (runtime) {
case DOCKER:
case DOCKER_ROOTLESS:
var dockerAvailable = versionOutput.contains("Docker version");
if (dockerAvailable) {
return PODMAN_PATTERN.matcher(versionOutput).matches() ? ContainerRuntime.PODMAN
: ContainerRuntime.DOCKER;
}
break;
case PODMAN:
case PODMAN_ROOTLESS:
if (PODMAN_PATTERN.matcher(versionOutput).matches()) {
return ContainerRuntime.PODMAN;
}
break;
}
}
return ContainerRuntime.UNAVAILABLE;
}

Line under review: .filter(r -> {

Code after addressing the review:
private static ContainerRuntime getContainerRuntimeEnvironment(List<ContainerRuntime> orderToCheckRuntimes) {
var runtimesToCheck = new ArrayList<>(orderToCheckRuntimes.stream().distinct().toList());
runtimesToCheck.retainAll(List.of(ContainerRuntime.DOCKER, ContainerRuntime.PODMAN));
if (CONTAINER_EXECUTABLE != null) {
var runtime = runtimesToCheck.stream()
.filter(containerRuntime -> CONTAINER_EXECUTABLE.trim()
.equalsIgnoreCase(containerRuntime.getExecutableName()))
.findFirst()
.filter(r -> {
var versionOutput = getVersionOutputFor(r);
return switch (r) {
case DOCKER, DOCKER_ROOTLESS -> versionOutput.contains("Docker version");
case PODMAN, PODMAN_ROOTLESS -> PODMAN_PATTERN.matcher(versionOutput).matches();
default -> false;
};
});
if (runtime.isPresent()) {
return runtime.get();
} else {
log.warn("quarkus.native.container-runtime config property must be set to either podman or docker " +
"and the executable must be available. Ignoring it.");
}
}
for (var runtime : runtimesToCheck) {
var versionOutput = getVersionOutputFor(runtime);
switch (runtime) {
case DOCKER:
case DOCKER_ROOTLESS:
var dockerAvailable = versionOutput.contains("Docker version");
if (dockerAvailable) {
return PODMAN_PATTERN.matcher(versionOutput).matches() ? ContainerRuntime.PODMAN
: ContainerRuntime.DOCKER;
}
break;
case PODMAN:
case PODMAN_ROOTLESS:
if (PODMAN_PATTERN.matcher(versionOutput).matches()) {
return ContainerRuntime.PODMAN;
}
break;
}
}
return ContainerRuntime.UNAVAILABLE;
}