Skip to content

Commit b2b8227

Browse files
committed
fix: trigger al2 via runtimeVersion field
1 parent d0b5ad5 commit b2b8227

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

go/porcelain/deploy.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -886,10 +886,6 @@ func newFunctionFile(filePath string, i os.FileInfo, runtime string, metadata *F
886886
if err := archive.Close(); err != nil {
887887
return nil, err
888888
}
889-
890-
if runtime == goRuntime {
891-
file.Runtime = amazonLinux2
892-
}
893889
}
894890

895891
fileBuffer := new(bytes.Buffer)
@@ -964,6 +960,13 @@ func ignoreFile(rel string, ignoreInstallDirs bool) bool {
964960

965961
func createHeader(archive *zip.Writer, i os.FileInfo, runtime string) (io.Writer, error) {
966962
if runtime == goRuntime {
963+
return archive.CreateHeader(&zip.FileHeader{
964+
CreatorVersion: 3 << 8, // indicates Unix
965+
ExternalAttrs: 0777 << 16, // -rwxrwxrwx file permissions
966+
Name: i.Name(),
967+
Method: zip.Deflate,
968+
})
969+
} else if runtime == amazonLinux2 {
967970
return archive.CreateHeader(&zip.FileHeader{
968971
CreatorVersion: 3 << 8, // indicates Unix
969972
ExternalAttrs: 0777 << 16, // -rwxrwxrwx file permissions

go/porcelain/deploy_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,14 +456,15 @@ func TestBundle(t *testing.T) {
456456
assert.Equal(t, "js", jsFunction.Runtime)
457457
assert.Equal(t, "py", pyFunction.Runtime)
458458
assert.Equal(t, "rs", rsFunction.Runtime)
459-
assert.Equal(t, "provided.al2", goFunction.Runtime)
459+
assert.Equal(t, "go", goFunction.Runtime)
460460
}
461461

462462
func TestBundleWithManifest(t *testing.T) {
463463
cwd, _ := os.Getwd()
464464
basePath := path.Join(filepath.Dir(cwd), "internal", "data")
465465
jsFunctionPath := strings.Replace(filepath.Join(basePath, "hello-js-function-test.zip"), "\\", "/", -1)
466466
pyFunctionPath := strings.Replace(filepath.Join(basePath, "hello-py-function-test.zip"), "\\", "/", -1)
467+
goFunctionPath := strings.Replace(filepath.Join(basePath, "hello-go-binary-function"), "\\", "/", -1)
467468
manifestPath := path.Join(basePath, "manifest.json")
468469
manifestFile := fmt.Sprintf(`{
469470
"functions": [
@@ -493,10 +494,16 @@ func TestBundleWithManifest(t *testing.T) {
493494
"mainFile": "/some/path/hello-py-function-test",
494495
"name": "hello-py-function-test",
495496
"invocationMode": "stream"
497+
},
498+
{
499+
"path": "%s",
500+
"runtime": "go",
501+
"runtimeVersion": "provided.al2",
502+
"name": "hello-go-binary-function"
496503
}
497504
],
498505
"version": 1
499-
}`, jsFunctionPath, pyFunctionPath)
506+
}`, jsFunctionPath, pyFunctionPath, goFunctionPath)
500507

501508
err := ioutil.WriteFile(manifestPath, []byte(manifestFile), 0644)
502509
defer os.Remove(manifestPath)
@@ -509,11 +516,13 @@ func TestBundleWithManifest(t *testing.T) {
509516
assert.Equal(t, "hello-js-function-test", schedules[0].Name)
510517
assert.Equal(t, "* * * * *", schedules[0].Cron)
511518

512-
assert.Equal(t, 2, len(functions.Files))
519+
assert.Equal(t, 3, len(functions.Files))
513520
assert.Equal(t, "a-runtime", functions.Files["hello-js-function-test"].Runtime)
514521
assert.Empty(t, functions.Files["hello-js-function-test"].FunctionMetadata.InvocationMode)
515522
assert.Equal(t, "some-other-runtime", functions.Files["hello-py-function-test"].Runtime)
516523
assert.Equal(t, "stream", functions.Files["hello-py-function-test"].FunctionMetadata.InvocationMode)
524+
assert.Equal(t, "provided.al2", functions.Files["hello-go-binary-function"].Runtime)
525+
assert.Empty(t, functions.Files["hello-go-binary-function"].FunctionMetadata.InvocationMode)
517526

518527
helloJSConfig := functionsConfig["hello-js-function-test"]
519528

0 commit comments

Comments
 (0)