in cmd/aws-lambda-rie/main.go [107:154]
func getBootstrap(args []string, opts options) (interop.Bootstrap, string) {
var bootstrapLookupCmd []string
var handler string
currentWorkingDir := "/var/task" // default value
if len(args) <= 1 {
// set default value to /var/task/bootstrap, but switch to the other options if it doesn't exist
bootstrapLookupCmd = []string{
fmt.Sprintf("%s/bootstrap", currentWorkingDir),
}
if !isBootstrapFileExist(bootstrapLookupCmd[0]) {
var bootstrapCmdCandidates = []string{
optBootstrap,
runtimeBootstrap,
}
for i, bootstrapCandidate := range bootstrapCmdCandidates {
if isBootstrapFileExist(bootstrapCandidate) {
bootstrapLookupCmd = []string{bootstrapCmdCandidates[i]}
break
}
}
}
// handler is used later to set an env var for Lambda Image support
handler = ""
} else if len(args) > 1 {
bootstrapLookupCmd = args[1:]
if cwd, err := os.Getwd(); err == nil {
currentWorkingDir = cwd
}
if len(args) > 2 {
// Assume last arg is the handler
handler = args[len(args)-1]
}
log.Infof("exec '%s' (cwd=%s, handler=%s)", args[1], currentWorkingDir, handler)
} else {
log.Panic("insufficient arguments: bootstrap not provided")
}
return NewSimpleBootstrap(bootstrapLookupCmd, currentWorkingDir), handler
}