serverless-plugin-go 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cz.toml +1 -1
- package/CHANGELOG.md +6 -0
- package/README.md +2 -2
- package/index.js +1 -1
- package/index.test.js +58 -0
- package/package.json +1 -1
package/.cz.toml
CHANGED
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
```yaml
|
|
32
32
|
functions:
|
|
33
33
|
example:
|
|
34
|
-
runtime: 'provided.al2
|
|
34
|
+
runtime: 'provided.al2023' # or provided.al2
|
|
35
35
|
handler: 'functions/example/main.go' # or just functions/example
|
|
36
36
|
```
|
|
37
37
|
|
|
@@ -87,7 +87,7 @@ Change architecture field from `provider` or function configuration to `arm64`:
|
|
|
87
87
|
```yaml
|
|
88
88
|
provider:
|
|
89
89
|
architecture: 'arm64'
|
|
90
|
-
runtime: 'provided.al2
|
|
90
|
+
runtime: 'provided.al2023' # or provided.al2
|
|
91
91
|
|
|
92
92
|
# If you define architecture at function level, this will have preference instead the provider configuration
|
|
93
93
|
|
package/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import AdmZip from "adm-zip";
|
|
|
8
8
|
import { readFileSync } from "fs";
|
|
9
9
|
|
|
10
10
|
// SupportedRuntimes Runtimes that are allowed to run Golang lambdas.
|
|
11
|
-
const supportedRuntimes = ["provided.al2"];
|
|
11
|
+
const supportedRuntimes = ["provided.al2", "provided.al2023"];
|
|
12
12
|
|
|
13
13
|
const logPrefix = "GoPlugin";
|
|
14
14
|
|
package/index.test.js
CHANGED
|
@@ -57,6 +57,16 @@ describe("Go Plugin", () => {
|
|
|
57
57
|
runtime: "go1.x",
|
|
58
58
|
handler: "functions/func4",
|
|
59
59
|
},
|
|
60
|
+
testFunc5: {
|
|
61
|
+
name: "testFunc5",
|
|
62
|
+
runtime: "provided.al2023",
|
|
63
|
+
handler: "functions/func5/main.go",
|
|
64
|
+
},
|
|
65
|
+
testFunc6: {
|
|
66
|
+
name: "testFunc6",
|
|
67
|
+
runtime: "provided.al2023",
|
|
68
|
+
handler: "functions/func6",
|
|
69
|
+
},
|
|
60
70
|
});
|
|
61
71
|
|
|
62
72
|
const plugin = new Go(config);
|
|
@@ -91,6 +101,30 @@ describe("Go Plugin", () => {
|
|
|
91
101
|
env: { ...process.env, ...{ CGO_ENABLED: "0", GOOS: "linux" } },
|
|
92
102
|
},
|
|
93
103
|
);
|
|
104
|
+
|
|
105
|
+
expect(config.service.functions.testFunc5.handler).to.equal(
|
|
106
|
+
`.bin/testFunc5`,
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
expect(execStub).to.have.been.calledWith(
|
|
110
|
+
`go build -ldflags="-s -w" -o .bin/testFunc5 functions/func5/main.go`,
|
|
111
|
+
{
|
|
112
|
+
cwd: ".",
|
|
113
|
+
env: { ...process.env, ...{ CGO_ENABLED: "0", GOOS: "linux" } },
|
|
114
|
+
},
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
expect(config.service.functions.testFunc6.handler).to.equal(
|
|
118
|
+
`.bin/testFunc6`,
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
expect(execStub).to.have.been.calledWith(
|
|
122
|
+
`go build -ldflags="-s -w" -o .bin/testFunc6 functions/func6`,
|
|
123
|
+
{
|
|
124
|
+
cwd: ".",
|
|
125
|
+
env: { ...process.env, ...{ CGO_ENABLED: "0", GOOS: "linux" } },
|
|
126
|
+
},
|
|
127
|
+
);
|
|
94
128
|
});
|
|
95
129
|
|
|
96
130
|
it("Compiles Go function with custom command", async () => {
|
|
@@ -243,6 +277,30 @@ describe("Go Plugin", () => {
|
|
|
243
277
|
expect(execStub).to.have.been.calledOnce;
|
|
244
278
|
});
|
|
245
279
|
|
|
280
|
+
it("Compiles Go function with global runtime provided.al2023 defined", async () => {
|
|
281
|
+
config.service
|
|
282
|
+
.setProvider({
|
|
283
|
+
runtime: "provided.al2023",
|
|
284
|
+
})
|
|
285
|
+
.setFunctions({
|
|
286
|
+
testFunc1: {
|
|
287
|
+
name: "testFunc1",
|
|
288
|
+
handler: "functions/func1/main.go",
|
|
289
|
+
},
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
const plugin = new Go(config);
|
|
293
|
+
plugin.exec = execStub;
|
|
294
|
+
plugin.readFileSync = readFileSyncStub;
|
|
295
|
+
plugin.zip = admZipStub;
|
|
296
|
+
|
|
297
|
+
// when
|
|
298
|
+
await plugin.hooks["before:package:createDeploymentArtifacts"]();
|
|
299
|
+
|
|
300
|
+
// then
|
|
301
|
+
expect(execStub).to.have.been.calledOnce;
|
|
302
|
+
});
|
|
303
|
+
|
|
246
304
|
it("Compiles single Go function", async () => {
|
|
247
305
|
config.service.setFunctions({
|
|
248
306
|
testFunc1: {
|