Skip to content

Commit 7723b9f

Browse files
Remove podman detection from docker-env per review feedback
- Remove DockerBackendDetector and DetectDockerBackend function - Remove podman-specific logic from dockerEnvVars - Simplify docker-env to only handle Docker API compatibility
1 parent a1f2849 commit 7723b9f

File tree

2 files changed

+2
-47
lines changed

2 files changed

+2
-47
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,4 @@ hack/legacy_fill_db/gopogh_filldb_log.txt
6666
hack/legacy_fill_db/out/output_summary.json
6767
hack/legacy_fill_db/out/output.html
6868
hack/go-licenses
69+
._b00t_.toml

cmd/minikube/cmd/docker-env.go

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ type DockerShellConfig struct {
121121
SSHAgentPID string
122122
}
123123

124-
// DockerBackendDetector is a function variable for backend detection, allowing injection/mocking in tests.
125-
var DockerBackendDetector = DetectDockerBackend
126124
var (
127125
noProxy bool
128126
sshHost bool
@@ -384,17 +382,6 @@ docker-cli install instructions: https://minikube.sigs.k8s.io/docs/tutorials/doc
384382
sshAgentPID: co.Config.SSHAgentPID,
385383
}
386384

387-
// Detect backend (docker vs podman) and set ec.driver accordingly.
388-
// This allows robust detection and is injectable/mocked for tests.
389-
backend, err := DockerBackendDetector(func(name string, args ...string) ([]byte, error) {
390-
cmd := exec.Command(name, args...)
391-
return cmd.CombinedOutput()
392-
})
393-
if err != nil {
394-
klog.Warningf("Failed to detect Docker backend, defaulting to driver: %v", err)
395-
} else {
396-
ec.driver = backend
397-
}
398385

399386
dockerPath, err := exec.LookPath("docker")
400387
if err != nil {
@@ -600,8 +587,7 @@ func dockerEnvVars(ec DockerEnvConfig) map[string]string {
600587
} else {
601588
rt = envTCP
602589
}
603-
// Only add "existing" envs if the driver is podman
604-
if ec.driver == "podman" && os.Getenv(constants.MinikubeActiveDockerdEnv) == "" {
590+
if os.Getenv(constants.MinikubeActiveDockerdEnv) == "" {
605591
for _, env := range constants.DockerDaemonEnvs {
606592
if v := oci.InitialEnv(env); v != "" {
607593
key := constants.MinikubeExistingPrefix + env
@@ -703,36 +689,4 @@ func init() {
703689
dockerEnvCmd.Flags().StringVar(&shell.ForceShell, "shell", "", "Force environment to be configured for a specified shell: [fish, cmd, powershell, tcsh, bash, zsh], default is auto-detect")
704690
dockerEnvCmd.Flags().StringVarP(&outputFormat, "output", "o", "", "One of 'text', 'yaml' or 'json'.")
705691
dockerEnvCmd.Flags().BoolVarP(&dockerUnset, "unset", "u", false, "Unset variables instead of setting them")
706-
}
707-
/*
708-
DetectDockerBackend probes the Docker CLI backend by running `docker info` and parsing the output
709-
for Podman signatures. Returns "docker" or "podman" as backend type.
710-
711-
The detection logic looks for "Podman Engine" or "podman" in the "Server" or "Operating System" fields.
712-
The commandRunner argument allows injection/mocking for tests.
713-
*/
714-
func DetectDockerBackend(commandRunner func(name string, args ...string) ([]byte, error)) (string, error) {
715-
output, err := commandRunner("docker", "info", "--format", "{{json .}}")
716-
if err != nil {
717-
return "", fmt.Errorf("failed to run docker info: %w", err)
718-
}
719-
// Try to parse as JSON and look for podman signatures
720-
var info map[string]interface{}
721-
if err := json.Unmarshal(output, &info); err == nil {
722-
// Check "ServerVersion" or "OperatingSystem" fields for podman
723-
if osField, ok := info["OperatingSystem"].(string); ok && strings.Contains(strings.ToLower(osField), "podman") {
724-
return "podman", nil
725-
}
726-
if sv, ok := info["ServerVersion"].(string); ok && strings.Contains(strings.ToLower(sv), "podman") {
727-
return "podman", nil
728-
}
729-
if sv, ok := info["Server"].(string); ok && strings.Contains(strings.ToLower(sv), "podman") {
730-
return "podman", nil
731-
}
732-
}
733-
// Fallback: look for "Podman" in raw output
734-
if strings.Contains(strings.ToLower(string(output)), "podman") {
735-
return "podman", nil
736-
}
737-
return "docker", nil
738692
}

0 commit comments

Comments
 (0)