Skip to content

Commit 9a23188

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

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

cmd/aws-lambda-rie/main.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,23 @@ 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+
66+
var bootstrapCmdCandidates = []string{
6667
fmt.Sprintf("%s/bootstrap", currentWorkingDir),
6768
optBootstrap,
6869
runtimeBootstrap,
6970
}
7071

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

0 commit comments

Comments
 (0)