adding rust, fixing python/php, adding ability to detect rusts src/main.rs file

This commit is contained in:
Chad Arimura
2017-06-05 12:32:23 -07:00
parent 9c67c5024f
commit 17bbef04f5
16 changed files with 204 additions and 114 deletions

View File

@@ -2,8 +2,8 @@ package langs
import (
"errors"
"os"
"fmt"
"os"
)
var (
@@ -20,7 +20,7 @@ func GetLangHelper(lang string) LangHelper {
case "ruby":
return &RubyLangHelper{}
case "python":
return &PythonHelper{}
return &PythonLangHelper{}
case "php":
return &PhpLangHelper{}
case "rust":
@@ -54,8 +54,8 @@ type LangHelper interface {
type BaseHelper struct {
}
func (h *BaseHelper) Cmd() string { return "" }
func (h *BaseHelper) HasBoilerplate() bool { return false }
func (h *BaseHelper) Cmd() string { return "" }
func (h *BaseHelper) HasBoilerplate() bool { return false }
func (h *BaseHelper) GenerateBoilerplate() error { return nil }
func exists(name string) bool {
@@ -69,4 +69,4 @@ func exists(name string) bool {
func dockerBuildError(err error) error {
return fmt.Errorf("error running docker build: %v", err)
}
}

View File

@@ -7,20 +7,20 @@ import (
"strings"
)
type PythonHelper struct {
type PythonLangHelper struct {
BaseHelper
}
func (lh *PythonHelper) Entrypoint() string {
func (lh *PythonLangHelper) Entrypoint() string {
return "python2 func.py"
}
func (lh *PythonHelper) HasPreBuild() bool {
func (lh *PythonLangHelper) HasPreBuild() bool {
return true
}
// PreBuild for Go builds the binary so the final image can be as small as possible
func (lh *PythonHelper) PreBuild() error {
func (lh *PythonLangHelper) PreBuild() error {
wd, err := os.Getwd()
if err != nil {
return err
@@ -40,6 +40,6 @@ func (lh *PythonHelper) PreBuild() error {
return nil
}
func (lh *PythonHelper) AfterBuild() error {
func (lh *PythonLangHelper) AfterBuild() error {
return nil
}