示例#1
0
文件: golang.go 项目: pilwon/apex
// Run adds the shim when runtime is "golang".
func (p *Plugin) Run(hook function.Hook, fn *function.Function) error {
	if hook != function.OpenHook || fn.Runtime != "golang" {
		return nil
	}

	fn.Shim = true
	fn.Runtime = "nodejs"
	fn.Hooks.Build = "GOOS=linux GOARCH=amd64 go build -o main main.go"
	fn.Hooks.Clean = "rm -f main"

	return nil
}
示例#2
0
文件: python.go 项目: kujohn/apex
// Open adds python defaults.
func (p *Plugin) Open(fn *function.Function) error {
	if fn.Runtime != "python" {
		return nil
	}

	fn.Runtime = "python2.7"

	if fn.Handler == "" {
		fn.Handler = "main.handle"
	}

	return nil
}
示例#3
0
文件: python.go 项目: elizar/apex
// Open adds python defaults.
func (p *Plugin) Open(fn *function.Function) error {
	if fn.Runtime != Runtime {
		return nil
	}

	fn.Runtime = RuntimeCanonical

	if fn.Handler == "" {
		fn.Handler = "main.handle"
	}

	return nil
}
示例#4
0
文件: python.go 项目: pilwon/apex
// Run specifies python defaults.
func (p *Plugin) Run(hook function.Hook, fn *function.Function) error {
	if hook != function.OpenHook || fn.Runtime != "python" {
		return nil
	}

	fn.Runtime = "python2.7"

	if fn.Handler == "" {
		fn.Handler = "main.handle"
	}

	return nil
}
示例#5
0
文件: golang.go 项目: sirodoht/apex
// Open adds the shim and golang defaults.
func (p *Plugin) Open(fn *function.Function) error {
	if fn.Runtime != Runtime {
		return nil
	}

	if fn.Hooks.Build == "" {
		fn.Hooks.Build = "GOOS=linux GOARCH=amd64 go build -o main main.go"
	}

	fn.Shim = true
	fn.Runtime = nodejs.Runtime
	fn.Hooks.Clean = "rm -f main"

	return nil
}
示例#6
0
文件: java.go 项目: elizar/apex
// Open adds java defaults.
func (p *Plugin) Open(fn *function.Function) error {
	if fn.Runtime != Runtime {
		return nil
	}

	fn.Runtime = RuntimeCanonical

	if fn.Handler == "" {
		fn.Handler = "lambda.Main::handler"
	}

	fn.Hooks.Clean = "mvn clean"

	return nil
}
示例#7
0
文件: inference.go 项目: pilwon/apex
// Run checks for files in the function directory to infer its runtime.
func (p *Plugin) Run(hook function.Hook, fn *function.Function) error {
	if hook != function.OpenHook || fn.Runtime != "" {
		return nil
	}

	fn.Log.Debug("inferring runtime")

	for name, runtime := range p.Files {
		if _, err := os.Stat(filepath.Join(fn.Path, name)); err == nil {
			fn.Log.WithField("runtime", runtime).Debug("inferred runtime")
			fn.Runtime = runtime
			return nil
		}
	}

	return nil
}
示例#8
0
文件: java.go 项目: DavidTPate/apex
// Build adds the jar contents to zipfile.
func (p *Plugin) Build(fn *function.Function, zip *archive.Zip) error {
	if fn.Runtime != Runtime {
		return nil
	}
	fn.Runtime = RuntimeCanonical

	fn.Log.Debugf("searching for JAR (%s) in directories: %s", jarFile, strings.Join(jarSearchPaths, ", "))
	expectedJarPath := findJar(fn.Path)
	if expectedJarPath == "" {
		return errors.New("Expected jar file not found")
	}
	fn.Log.Debugf("found jar path: %s", expectedJarPath)

	fn.Log.Debug("appending compiled files")
	reader, err := azip.OpenReader(expectedJarPath)
	if err != nil {
		return err
	}
	defer reader.Close()

	for _, file := range reader.File {
		r, err := file.Open()
		if err != nil {
			return err
		}

		b, err := ioutil.ReadAll(r)
		if err != nil {
			return err
		}
		r.Close()

		zip.AddBytes(file.Name, b)
	}

	return nil
}