Skip to content

Commit

Permalink
Allow overriding bin name
Browse files Browse the repository at this point in the history
  • Loading branch information
janekbaraniewski committed Sep 11, 2024
1 parent b50612f commit 2a6a58f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions pkg/devcontainer/crane/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const (
GitCrane = "git"
EnvironmentCrane = "environment"

BinPath = "devpod-crane" // FIXME

tmpDirTemplate = "devpod-crane-*"
defaultBinName = "devpod-crane"
envDevPodCraneName = "DEVPOD_CRANE_NAME"
tmpDirTemplate = "devpod-crane-*"
)

type Content struct {
Expand All @@ -40,12 +40,12 @@ func ShouldUse(cliOptions *provider2.CLIOptions) bool {

// IsAvailable checks if devpod crane is installed in host system
func IsAvailable() bool {
_, err := exec.LookPath(BinPath)
_, err := exec.LookPath(getBinName())
return err == nil
}

func runCommand(command string, args ...string) (string, error) {
cmd := exec.Command(BinPath, append([]string{command}, args...)...)
cmd := exec.Command(getBinName(), append([]string{command}, args...)...)

var outBuf, errBuf bytes.Buffer
cmd.Stdout = &outBuf
Expand Down Expand Up @@ -128,3 +128,10 @@ func storeFilesInDirectory(content *Content, path string) (string, error) {

return path, nil
}

func getBinName() string {
if name := os.Getenv(envDevPodCraneName); name != "" {
return name
}
return defaultBinName
}

0 comments on commit 2a6a58f

Please sign in to comment.