Skip to content

Commit

Permalink
Lookup fly executable on the PATH
Browse files Browse the repository at this point in the history
- Don't panic if the URL is too short
  • Loading branch information
jdeppe-pivotal committed May 31, 2017
1 parent 9ef44be commit 9c45421
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/fly-utils/fly-hijack/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import (
"os"
"net/url"
"fly-utils/flyrc"
"os/exec"
)

const (
PIPELINE = 4
JOB = 6
BUILD = 8
JOB = 6
BUILD = 8
)

func main() {
Expand Down Expand Up @@ -43,6 +44,10 @@ func main() {
}
}

if len(parts) < JOB + 1 {
log.Fatal("URL appears too short - make sure it at least contains a 'jobs' value")
}

args := []string{
"fly",
"-t", instance,
Expand All @@ -54,7 +59,12 @@ func main() {
args = append(args, "-b", parts[BUILD])
}

err = syscall.Exec("/usr/local/bin/fly", args, os.Environ())
flyPath, err := exec.LookPath("fly")
if err != nil {
log.Fatal("Unable to find 'fly' executable in your PATH")
}

err = syscall.Exec(flyPath, args, os.Environ())
if err != nil {
log.Fatal(fmt.Sprintf("Unable to launch fly: %s", err))
}
Expand Down

0 comments on commit 9c45421

Please sign in to comment.