Revert "fn: add glide support for Go build (#441)"

This reverts commit 1df89cc217.
This commit is contained in:
Carlos C
2016-12-14 23:19:32 +01:00
parent fc57bc58f7
commit 0fc578b4a4
3 changed files with 22 additions and 52 deletions

View File

@@ -4,7 +4,6 @@ import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
)
@@ -25,49 +24,23 @@ func (lh *GoLangHelper) PreBuild() error {
if err != nil {
return err
}
glidefn := filepath.Join(wd, "glide.lock")
if exists(glidefn) {
lh.deps(wd)
// todo: this won't work if the function is more complex since the import paths won't match up, need to fix
pbcmd := fmt.Sprintf("docker run --rm -v %s:/go/src/github.com/x/y -w /go/src/github.com/x/y iron/go:dev go build -o func", wd)
fmt.Println("Running prebuild command:", pbcmd)
parts := strings.Fields(pbcmd)
head := parts[0]
parts = parts[1:len(parts)]
cmd := exec.Command(head, parts...)
// cmd.Dir = dir
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
if err := cmd.Run(); err != nil {
return fmt.Errorf("error running docker build: %v", err)
}
return lh.build(wd)
return nil
}
func (lh *GoLangHelper) AfterBuild() error {
return os.Remove("func")
}
func (lh *GoLangHelper) deps(wd string) error {
pkgname := filepath.Base(wd)
pbcmd := fmt.Sprintf("docker run --rm -v %s:/go/src/%s -w /go/src/%s iron/go:glide glide install -v", wd, pkgname, pkgname)
fmt.Println("Running prebuild command:", pbcmd)
parts := strings.Fields(pbcmd)
head := parts[0]
parts = parts[1:len(parts)]
cmd := exec.Command(head, parts...)
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
if err := cmd.Run(); err != nil {
return fmt.Errorf("error running docker build: %v", err)
}
return nil
}
func (lh *GoLangHelper) build(wd string) error {
pkgname := filepath.Base(wd)
// todo: this won't work if the function is more complex since the import paths won't match up, need to fix
pbcmd := fmt.Sprintf("docker run --rm -v %s:/go/src/%s -w /go/src/%s iron/go:dev go build -o func", wd, pkgname, pkgname)
fmt.Println("Running prebuild command:", pbcmd)
parts := strings.Fields(pbcmd)
head := parts[0]
parts = parts[1:len(parts)]
cmd := exec.Command(head, parts...)
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
if err := cmd.Run(); err != nil {
return fmt.Errorf("error running docker build: %v", err)
}
return nil
}

View File

@@ -46,3 +46,12 @@ func (lh *RubyLangHelper) PreBuild() error {
func (lh *RubyLangHelper) AfterBuild() error {
return nil
}
func exists(name string) bool {
if _, err := os.Stat(name); err != nil {
if os.IsNotExist(err) {
return false
}
}
return true
}

View File

@@ -1,12 +0,0 @@
package langs
import "os"
func exists(name string) bool {
if _, err := os.Stat(name); err != nil {
if os.IsNotExist(err) {
return false
}
}
return true
}