コード例 #1
0
ファイル: python.go プロジェクト: DavidTPate/apex
// Build injects a script for loading the environment.
func (p *Plugin) Build(fn *function.Function, zip *archive.Zip) error {
	if fn.Runtime != RuntimeCanonical || len(fn.Environment) == 0 {
		return nil
	}

	if len(strings.Split(fn.Handler, ".")) < 2 {
		return errors.New("lambda requires handler function name to be of the format 'filename.function_name'")
	}

	fn.Log.Debug("injecting prelude")

	var buf bytes.Buffer
	file := strings.Split(fn.Handler, ".")[0]
	method := strings.Split(fn.Handler, ".")[1]

	err := prelude.Execute(&buf, struct {
		EnvFile      string
		HandleFile   string
		HandleMethod string
	}{
		EnvFile:      env.FileName,
		HandleFile:   file,
		HandleMethod: method,
	})

	if err != nil {
		return err
	}

	fn.Handler = "_apex_main." + method

	return zip.AddBytes("_apex_main.py", buf.Bytes())
}
コード例 #2
0
ファイル: nodejs.go プロジェクト: kujohn/apex
// Build injects a script for loading the environment.
func (p *Plugin) Build(fn *function.Function, zip *archive.Archive) error {
	if len(fn.Environment) == 0 {
		return nil
	}

	fn.Log.Debug("injecting prelude")

	var buf bytes.Buffer
	file := strings.Split(fn.Handler, ".")[0]
	method := strings.Split(fn.Handler, ".")[1]

	err := prelude.Execute(&buf, struct {
		EnvFile      string
		HandleFile   string
		HandleMethod string
	}{
		EnvFile:      ".env.json",
		HandleFile:   file,
		HandleMethod: method,
	})

	if err != nil {
		return err
	}

	fn.Handler = "_apex_index.handle"

	return zip.AddBytes("_apex_index.js", buf.Bytes())
}
コード例 #3
0
ファイル: python.go プロジェクト: elizar/apex
// Build injects a script for loading the environment.
func (p *Plugin) Build(fn *function.Function, zip *archive.Archive) error {
	if fn.Runtime != RuntimeCanonical || len(fn.Environment) == 0 {
		return nil
	}

	fn.Log.Debug("injecting prelude")

	var buf bytes.Buffer
	file := strings.Split(fn.Handler, ".")[0]
	method := strings.Split(fn.Handler, ".")[1]

	err := prelude.Execute(&buf, struct {
		EnvFile      string
		HandleFile   string
		HandleMethod string
	}{
		EnvFile:      env.FileName,
		HandleFile:   file,
		HandleMethod: method,
	})

	if err != nil {
		return err
	}

	fn.Handler = "_apex_main.handle"

	return zip.AddBytesMTime("_apex_main.py", buf.Bytes(), time.Unix(0, 0))
}
コード例 #4
0
ファイル: nodejs.go プロジェクト: kujohn/apex
// Open adds nodejs defaults.
func (p *Plugin) Open(fn *function.Function) error {
	if fn.Runtime != "nodejs" {
		return nil
	}

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

	return nil
}
コード例 #5
0
ファイル: nodejs.go プロジェクト: pilwon/apex
// Run specifies nodejs defaults.
func (p *Plugin) Run(hook function.Hook, fn *function.Function) error {
	if hook != function.OpenHook || fn.Runtime != "nodejs" {
		return nil
	}

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

	return nil
}
コード例 #6
0
ファイル: nodejs.go プロジェクト: DavidTPate/apex
// Open adds nodejs defaults.
func (p *Plugin) Open(fn *function.Function) error {
	if !p.runtimeSupported(fn) {
		return nil
	}

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

	return nil
}
コード例 #7
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
}
コード例 #8
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
}
コード例 #9
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
}
コード例 #10
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
}
コード例 #11
0
ファイル: java.go プロジェクト: DavidTPate/apex
// Open adds java defaults. No clean operation is implemented, as it is
// assumed that the build tool generating the fat JAR will handle that workflow
// on its own.
func (p *Plugin) Open(fn *function.Function) error {
	if fn.Runtime != Runtime {
		return nil
	}

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

	if len(fn.IgnoreFile) == 0 {
		// Since we're deploying a fat jar, we don't need anything else.
		fn.IgnoreFile = []byte(`
*
!**/apex.jar
`)
	}

	return nil
}