From 01d9eb9f1115aac2000539d569658e07e6ae4236 Mon Sep 17 00:00:00 2001 From: Emily McMullan Date: Wed, 30 Aug 2023 15:50:33 -0400 Subject: [PATCH] fix podman for man --- README.md | 4 ++++ cmd/container.go | 14 +++++++++++--- cmd/settings.go | 11 ++++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dc64d1b..5285b66 100644 --- a/README.md +++ b/README.md @@ -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 -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 ``` diff --git a/cmd/container.go b/cmd/container.go index 46bc0f9..f73322b 100644 --- a/cmd/container.go +++ b/cmd/container.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strings" "time" ) @@ -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) @@ -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") diff --git a/cmd/settings.go b/cmd/settings.go index 8a6a221..380c776 100644 --- a/cmd/settings.go +++ b/cmd/settings.go @@ -1,6 +1,8 @@ package cmd import ( + "os/exec" + "github.com/codingconcepts/env" ) @@ -22,7 +24,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 { + Settings.PodmanBinary = podmanPath + } + err = env.Set(Settings) if err != nil { return err }