Skip to content

Commit c5fe49f

Browse files
authored
fix: use tags instead of a custom invalid runtime option
Serverless 3 will throw an error if we use a `provider.runtime` option different from the allowed values. This PR removes the need to use the new runtime option (`rust`) and uses `tags.rust: true` inside the function configuration. This PR resolves softprops#107
1 parent c5d5e71 commit c5fe49f

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

index.js

+4-14
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ const { mkdirSync, writeFileSync, readFileSync } = require("fs");
1212

1313
const DEFAULT_DOCKER_TAG = "latest";
1414
const DEFAULT_DOCKER_IMAGE = "softprops/lambda-rust";
15-
const RUST_RUNTIME = "rust";
16-
const BASE_RUNTIME = "provided.al2";
1715
const NO_OUTPUT_CAPTURE = { stdio: ["ignore", process.stdout, process.stderr] };
1816
const MUSL_PLATFORMS = ["darwin", "win32", "linux"];
1917

@@ -77,7 +75,7 @@ class RustPlugin {
7775

7876
let target = (funcArgs || {}).target || this.custom.target
7977

80-
const targetArgs =
78+
const targetArgs =
8179
target ?
8280
['--target', target]
8381
: MUSL_PLATFORMS.includes(platform)
@@ -288,8 +286,8 @@ class RustPlugin {
288286
let rustFunctionsFound = false;
289287
this.functions().forEach((funcName) => {
290288
const func = service.getFunction(funcName);
291-
const runtime = func.runtime || service.provider.runtime;
292-
if (runtime != RUST_RUNTIME) {
289+
const isRustFunction = !!func.tags?.rust
290+
if (!isRustFunction) {
293291
// skip functions which don't apply to rust
294292
return;
295293
}
@@ -324,19 +322,11 @@ class RustPlugin {
324322
);
325323
func.package = func.package || {};
326324
func.package.artifact = artifactPath;
327-
328-
// Ensure the runtime is set to a sane value for other plugins
329-
if (func.runtime == RUST_RUNTIME) {
330-
func.runtime = BASE_RUNTIME;
331-
}
332325
});
333-
if (service.provider.runtime === RUST_RUNTIME) {
334-
service.provider.runtime = BASE_RUNTIME;
335-
}
336326
if (!rustFunctionsFound) {
337327
throw new Error(
338328
`Error: no Rust functions found. ` +
339-
`Use 'runtime: ${RUST_RUNTIME}' in global or ` +
329+
`Use 'tags.rust: true' in ` +
340330
`function configuration to use this plugin.`
341331
);
342332
}

0 commit comments

Comments
 (0)