Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use tags instead of a custom invalid runtime option #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ const { mkdirSync, writeFileSync, readFileSync } = require("fs");

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

Expand Down Expand Up @@ -77,7 +75,7 @@ class RustPlugin {

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

const targetArgs =
const targetArgs =
target ?
['--target', target]
: MUSL_PLATFORMS.includes(platform)
Expand Down Expand Up @@ -288,8 +286,8 @@ class RustPlugin {
let rustFunctionsFound = false;
this.functions().forEach((funcName) => {
const func = service.getFunction(funcName);
const runtime = func.runtime || service.provider.runtime;
if (runtime != RUST_RUNTIME) {
const isRustFunction = !!func.tags?.rust
if (!isRustFunction) {
// skip functions which don't apply to rust
return;
}
Expand Down Expand Up @@ -324,19 +322,11 @@ class RustPlugin {
);
func.package = func.package || {};
func.package.artifact = artifactPath;

// Ensure the runtime is set to a sane value for other plugins
if (func.runtime == RUST_RUNTIME) {
func.runtime = BASE_RUNTIME;
}
});
if (service.provider.runtime === RUST_RUNTIME) {
service.provider.runtime = BASE_RUNTIME;
}
if (!rustFunctionsFound) {
throw new Error(
`Error: no Rust functions found. ` +
`Use 'runtime: ${RUST_RUNTIME}' in global or ` +
`Use 'tags.rust: true' in ` +
`function configuration to use this plugin.`
);
}
Expand Down