Skip to content

Commit

Permalink
fix podman for mac
Browse files Browse the repository at this point in the history
  • Loading branch information
eemcmullan committed Aug 31, 2023
1 parent f977f9b commit b375e82
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ podman pull quay.io/konveyor/kantra:latest && podman run --name kantra-download

### MacOS

**Note:** On MacOS, in order to correctly mount volumes, your podman machine must contain options:

`podman machine init <name> -v $HOME:$HOME -v /private/tmp:/private/tmp -v /var/folders/:/var/folders/`

```sh
podman pull quay.io/konveyor/kantra:latest && podman run --name kantra-download quay.io/konveyor/kantra:latest 1> /dev/null 2> /dev/null && podman cp kantra-download:/usr/local/bin/darwin-kantra kantra && podman rm kantra-download
```
Expand Down
14 changes: 11 additions & 3 deletions cmd/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"time"
)
Expand Down Expand Up @@ -149,7 +150,8 @@ func (c *container) Run(ctx context.Context, opts ...Option) error {
}
}()
}
args := []string{"run", "-it"}
args := []string{"run"}
os := runtime.GOOS
if c.name != "" {
args = append(args, "--name")
args = append(args, c.name)
Expand All @@ -164,8 +166,14 @@ func (c *container) Run(ctx context.Context, opts ...Option) error {
}
for sourcePath, destPath := range c.volumes {
args = append(args, "-v")
args = append(args, fmt.Sprintf("%s:%s:Z",
filepath.Clean(sourcePath), filepath.Clean(destPath)))
// TODO: check this on windows
if os == "linux" {
args = append(args, fmt.Sprintf("%s:%s:Z",
filepath.Clean(sourcePath), filepath.Clean(destPath)))
} else {
args = append(args, fmt.Sprintf("%s:%s",
filepath.Clean(sourcePath), filepath.Clean(destPath)))
}
}
for k, v := range c.env {
args = append(args, "--env")
Expand Down
12 changes: 11 additions & 1 deletion cmd/settings.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package cmd

import (
"os"
"os/exec"

"github.com/codingconcepts/env"
)

Expand All @@ -22,7 +25,14 @@ type Config struct {
}

func (c *Config) Load() error {
err := env.Set(Settings)
podmanPath, err := exec.LookPath("podman")
if err != nil {
return err
}
if podmanPath != Settings.PodmanBinary {
os.Setenv("PODMAN_BIN", podmanPath)
}
err = env.Set(Settings)
if err != nil {
return err
}
Expand Down

0 comments on commit b375e82

Please sign in to comment.