Skip to content

Commit

Permalink
fix: needs minio does not print out path if minio is already installed
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Mitchell <[email protected]>
  • Loading branch information
starpit committed Nov 13, 2024
1 parent 7158bee commit 4c51abd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/runtime/needs/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import (
"fmt"
"os"
"os/exec"
"path/filepath"
)

// Find and install (if needed) the minio executable
// @return the directory enclosing the minio executable
func InstallMinio(ctx context.Context, version string, opts Options) (string, error) {
// We may have installed minio in a special place. Before we
// can call LookPath, make sure that special place is on PATH.
Expand All @@ -23,7 +26,8 @@ func InstallMinio(ctx context.Context, version string, opts Options) (string, er
os.Setenv("PATH", os.Getenv("PATH")+":"+dir)
}

if _, err := exec.LookPath("minio"); err != nil {
path, err := exec.LookPath("minio")
if err != nil {
if errors.Is(err, exec.ErrNotFound) {
if opts.Verbose {
fmt.Fprintln(os.Stderr, "needs minio installing minio")
Expand All @@ -32,8 +36,9 @@ func InstallMinio(ctx context.Context, version string, opts Options) (string, er
}
return "", err
}

if opts.Verbose {
fmt.Fprintln(os.Stderr, "needs minio found minio")
fmt.Fprintln(os.Stderr, "needs minio found minio", path)
}
return dir, nil
return filepath.Dir(path), nil
}

0 comments on commit 4c51abd

Please sign in to comment.