Skip to content

Commit 335de98

Browse files
kk-minypwong99
authored andcommitted
fix: use provided.al2023 runtime if go1.x is specified
1 parent 5b30f55 commit 335de98

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

src/setup/building/builder.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ func buildJava(functionName string, functionDir string, artifactDir string) stri
6767
// buildGolang builds the Golang binary for serverless deployment
6868
func buildGolang(functionName string, functionDir string, artifactDir string) string {
6969
log.Infof("Building Go from the source code at %s directory", functionDir)
70-
artifactPath := fmt.Sprintf("%s/main", artifactDir)
71-
util.RunCommandAndLog(exec.Command("env", "GOOS=linux", "GOARCH=amd64", "CGO_ENABLED=0", "go", "build", "-C", functionDir))
72-
util.RunCommandAndLog(exec.Command("mv", fmt.Sprintf("%s/main", functionDir), artifactPath))
70+
artifactPath := fmt.Sprintf("%s/bootstrap", artifactDir)
71+
util.RunCommandAndLog(exec.Command("env", "GOOS=linux", "GOARCH=amd64", "CGO_ENABLED=0", "go", "build", "-C", functionDir, "-o", "bootstrap"))
72+
util.RunCommandAndLog(exec.Command("mv", fmt.Sprintf("%s/bootstrap", functionDir), artifactPath))
7373
return artifactPath
7474
}
7575

src/setup/deployment/packaging/zip.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func GenerateServerlessZIPArtifacts(experimentID int, provider string, runtime s
121121
func generateServerlessZIPArtifactsGeneral(experimentID int, provider string, runtime string, functionName string, functionImageSizeMB float64) {
122122
defaultBinaryName := map[string]string{
123123
"python3.9": "main.py",
124-
"go1.x": "main",
124+
"go1.x": "bootstrap",
125125
"nodejs18.x": "index.js",
126126
"ruby3.2": "function.rb",
127127
}

src/setup/serverless-config.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,25 +131,31 @@ func (s *Serverless) CreateHeaderConfig(config *Configuration, serviceName strin
131131
s.Service = serviceName
132132
s.FrameworkVersion = "3"
133133

134+
runtimeValue := config.Runtime
135+
if config.Runtime == "go1.x" {
136+
log.Warnf("`go1.x` runtime is deprecated. Runtime `provided.al2023` will be used instead...")
137+
runtimeValue = "provided.al2023"
138+
}
139+
134140
switch config.Provider {
135141
case "azure":
136142
s.Provider = Provider{
137143
Name: config.Provider,
138-
Runtime: config.Runtime,
144+
Runtime: runtimeValue,
139145
Region: region,
140146
FunctionApp: FunctionApp{ExtensionVersion: "~4"},
141147
}
142148
case "aliyun":
143149
s.Provider = Provider{
144150
Name: config.Provider,
145-
Runtime: config.Runtime,
151+
Runtime: runtimeValue,
146152
Region: region,
147153
Credentials: "~/.aliyuncli/credentials",
148154
}
149155
default:
150156
s.Provider = Provider{
151157
Name: config.Provider,
152-
Runtime: config.Runtime,
158+
Runtime: runtimeValue,
153159
Region: region,
154160
}
155161
}
@@ -177,9 +183,14 @@ func (s *Serverless) AddFunctionConfigAWS(subex *SubExperiment, index int, rando
177183
if s.Functions == nil {
178184
s.Functions = make(map[string]*Function)
179185
}
186+
180187
for i := 0; i < subex.Parallelism; i++ {
181188
handler := subex.Handler
182189
runtime := subex.Runtime
190+
if runtime == "go1.x" {
191+
log.Warnf("`go1.x` runtime is deprecated. Using `provided.al2023` runtime instead...")
192+
runtime = "provided.al2023"
193+
}
183194
name := fmt.Sprintf("%s-%s", randomTag, createName(subex, index, i))
184195
events := []Event{
185196
{

0 commit comments

Comments
 (0)