Skip to content

Commit e45a909

Browse files
committed
valid the bootstraps before passing to NewBootstrapSingleCmd
1 parent 08cc122 commit e45a909

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

cmd/aws-lambda-rie/main.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,22 @@ func getBootstrap(args []string, opts options) (*rapidcore.Bootstrap, string) {
6262
currentWorkingDir := "/var/task" // default value
6363

6464
if len(args) <= 1 {
65-
bootstrapLookupCmd = []string{
65+
var bootstrapCmdCandidates = []string{
6666
fmt.Sprintf("%s/bootstrap", currentWorkingDir),
6767
optBootstrap,
6868
runtimeBootstrap,
6969
}
7070

71+
// set default value to /var/task/bootstrap, but switch to the other options if it doesn't exist
72+
bootstrapLookupCmd = []string{bootstrapCmdCandidates[0]}
73+
74+
for i, bootstrapCandidate := range bootstrapCmdCandidates {
75+
if file, err := os.Stat(bootstrapCandidate); !os.IsNotExist(err) && !file.IsDir() {
76+
bootstrapLookupCmd = []string{bootstrapCmdCandidates[i]}
77+
break
78+
}
79+
}
80+
7181
// handler is used later to set an env var for Lambda Image support
7282
handler = ""
7383
} else if len(args) > 1 {

0 commit comments

Comments
 (0)