Skip to content

Commit bfefa72

Browse files
committed
Split template for podman v1 and v2 into two vars
1 parent 9f983a8 commit bfefa72

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cmd/minikube/cmd/podman-env.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ import (
3939
"k8s.io/minikube/pkg/minikube/shell"
4040
)
4141

42-
var podmanEnvTmpl = fmt.Sprintf("{{ if .VarlinkBridge }}{{ .Prefix }}%s{{ .Delimiter }}{{ .VarlinkBridge }}{{ .Suffix }}{{end}}{{ if .ContainerHost }}{{ .Prefix }}%s{{ .Delimiter }}{{ .ContainerHost }}{{ .Suffix }}{{end}}{{ if .ContainerSSHKey }}{{ .Prefix }}%s{{ .Delimiter }}{{ .ContainerSSHKey}}{{ .Suffix }}{{ end }}{{ .Prefix }}%s{{ .Delimiter }}{{ .MinikubePodmanProfile }}{{ .Suffix }}{{ .UsageHint }}", constants.PodmanVarlinkBridgeEnv, constants.PodmanContainerHostEnv, constants.PodmanContainerSSHKeyEnv, constants.MinikubeActivePodmanEnv)
42+
var podmanEnv1Tmpl = fmt.Sprintf("{{ .Prefix }}%s{{ .Delimiter }}{{ .VarlinkBridge }}{{ .Suffix }}{{ .Prefix }}%s{{ .Delimiter }}{{ .MinikubePodmanProfile }}{{ .Suffix }}{{ .UsageHint }}", constants.PodmanVarlinkBridgeEnv, constants.MinikubeActivePodmanEnv)
43+
44+
var podmanEnv2Tmpl = fmt.Sprintf("{{ .Prefix }}%s{{ .Delimiter }}{{ .ContainerHost }}{{ .Suffix }}{{ if .ContainerSSHKey }}{{ .Prefix }}%s{{ .Delimiter }}{{ .ContainerSSHKey}}{{ .Suffix }}{{ end }}{{ .Prefix }}%s{{ .Delimiter }}{{ .MinikubePodmanProfile }}{{ .Suffix }}{{ .UsageHint }}", constants.PodmanContainerHostEnv, constants.PodmanContainerSSHKeyEnv, constants.MinikubeActivePodmanEnv)
4345

4446
// PodmanShellConfig represents the shell config for Podman
4547
type PodmanShellConfig struct {
@@ -202,6 +204,12 @@ type PodmanEnvConfig struct {
202204

203205
// podmanSetScript writes out a shell-compatible 'podman-env' script
204206
func podmanSetScript(ec PodmanEnvConfig, w io.Writer) error {
207+
var podmanEnvTmpl string
208+
if ec.varlink {
209+
podmanEnvTmpl = podmanEnv1Tmpl
210+
} else {
211+
podmanEnvTmpl = podmanEnv2Tmpl
212+
}
205213
envVars := podmanEnvVars(ec)
206214
return shell.SetScript(ec.EnvConfig, w, podmanEnvTmpl, podmanShellCfgSet(ec, envVars))
207215
}

0 commit comments

Comments
 (0)