Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix podman for Mac #45

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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