Skip to content

Commit 012cf33

Browse files
anjannathpraveenkumar
authored andcommitted
create symlink for podman in ~/.crc/bin/podman dir
earlier both oc and podman binaries were present in the ~/.crc/bin/oc dir and added to PATH by the `crc oc-env` command, which resulted in adding both the binaries to path when the user might want only the `oc` binary to be added to path by the `crc oc-env` command this adds the `podman` binary in a separate directory ~/.crc/bin/podman and is added to PATH by running the `crc podman-env` command fixes #4022
1 parent 77d0a2e commit 012cf33

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

cmd/crc/cmd/podman_env.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func runPodmanEnv() error {
4242
if root {
4343
socket = constants.RootfulPodmanSocket
4444
}
45-
fmt.Println(shell.GetPathEnvString(userShell, constants.CrcOcBinDir))
45+
fmt.Println(shell.GetPathEnvString(userShell, constants.CrcPodmanBinDir))
4646
fmt.Println(shell.GetEnvString(userShell, "CONTAINER_SSHKEY", connectionDetails.SSHKeys[0]))
4747
fmt.Println(shell.GetEnvString(userShell, "CONTAINER_HOST",
4848
fmt.Sprintf("ssh://%s@%s:%d%s",

pkg/crc/constants/constants.go

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ var (
106106
CrcBaseDir = filepath.Join(GetHomeDir(), ".crc")
107107
CrcBinDir = filepath.Join(CrcBaseDir, "bin")
108108
CrcOcBinDir = filepath.Join(CrcBinDir, "oc")
109+
CrcPodmanBinDir = filepath.Join(CrcBinDir, "podman")
109110
CrcSymlinkPath = filepath.Join(CrcBinDir, "crc")
110111
ConfigPath = filepath.Join(CrcBaseDir, ConfigFile)
111112
LogFilePath = filepath.Join(CrcBaseDir, LogFile)

pkg/crc/machine/bundle/repository.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ const (
2727
)
2828

2929
type Repository struct {
30-
CacheDir string
31-
OcBinDir string
30+
CacheDir string
31+
OcBinDir string
32+
PodmanBinDir string
3233
}
3334

3435
func (repo *Repository) Get(bundleName string) (*CrcBundleInfo, error) {
@@ -91,7 +92,7 @@ func (repo *Repository) Use(bundleName string) (*CrcBundleInfo, error) {
9192
if err := bundleInfo.createSymlinkOrCopyOpenShiftClient(repo.OcBinDir); err != nil {
9293
return nil, err
9394
}
94-
if err := bundleInfo.createSymlinkOrCopyPodmanRemote(repo.OcBinDir); err != nil {
95+
if err := bundleInfo.createSymlinkOrCopyPodmanRemote(repo.PodmanBinDir); err != nil {
9596
return nil, err
9697
}
9798
return bundleInfo, nil
@@ -181,8 +182,9 @@ func (repo *Repository) CalculateBundleSha256Sum(bundlePath string) (string, err
181182
}
182183

183184
var defaultRepo = &Repository{
184-
CacheDir: constants.MachineCacheDir,
185-
OcBinDir: constants.CrcOcBinDir,
185+
CacheDir: constants.MachineCacheDir,
186+
OcBinDir: constants.CrcOcBinDir,
187+
PodmanBinDir: constants.CrcPodmanBinDir,
186188
}
187189

188190
func Get(bundleName string) (*CrcBundleInfo, error) {

pkg/crc/podman/podman.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const (
1313
rootfulConn = "crc-root"
1414
)
1515

16-
var podmanExecutablePath = filepath.Join(constants.CrcOcBinDir, constants.PodmanRemoteExecutableName)
16+
var podmanExecutablePath = filepath.Join(constants.CrcPodmanBinDir, constants.PodmanRemoteExecutableName)
1717

1818
func run(args ...string) (string, string, error) {
1919
return crcos.RunWithDefaultLocale(podmanExecutablePath, args...)

test/integration/podman_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ var _ = Describe("podman preset", Serial, Ordered, Label("podman-preset"), func(
4141

4242
It("podman-env", func() {
4343
// Do what 'eval $(crc podman-env) would do
44-
path := os.ExpandEnv("${HOME}/.crc/bin/oc:$PATH")
44+
path := os.ExpandEnv("${HOME}/.crc/bin/podman:$PATH")
4545
csshk := os.ExpandEnv("${HOME}/.crc/machines/crc/id_ecdsa")
4646
dh := os.ExpandEnv("unix:///${HOME}/.crc/machines/crc/docker.sock")
4747
ch := "ssh://[email protected]:2222/run/user/1000/podman/podman.sock"
4848
if runtime.GOOS == "windows" {
4949
userHomeDir, _ := os.UserHomeDir()
50-
unexpandedPath := filepath.Join(userHomeDir, ".crc/bin/oc;${PATH}")
50+
unexpandedPath := filepath.Join(userHomeDir, ".crc/bin/podman;${PATH}")
5151
path = os.ExpandEnv(unexpandedPath)
5252
csshk = filepath.Join(userHomeDir, ".crc/machines/crc/id_ecdsa")
5353
dh = "npipe:////./pipe/crc-podman"

0 commit comments

Comments
 (0)