8000 Fix metadata permissions by calavera · Pull Request #176 · cargo-lambda/cargo-lambda · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ target/lambda
By default, cargo-lambda produces a binary artifact for each Lambda functions in the project.
However, you can configure cargo-lambda to produce a ready to upload zip artifact.

The `--output-format` paramters controls the output format, the two current options are `zip` and `binary` with `binary` being the default.
The `--output-format` parameter controls the output format, the two current options are `zip` and `binary` with `binary` being the default.

Example usage to create a zip.

Expand Down
2 changes: 1 addition & 1 deletion crates/cargo-lambda-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "cargo-lambda-build"
description = "Cargo subcommand to work with AWS Lambda"
version = "0.8.1"
version = "0.8.2"
edition = "2021"
license = "MIT"
readme = "README.md"
Expand Down
15 changes: 14 additions & 1 deletion crates/cargo-lambda-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ fn zip_binary<P: AsRef<Path>>(

let zipped_binary = File::create(&zipped).into_diagnostic()?;
let binary_data = read(path).into_diagnostic()?;
let binary_perm = binary_permissions(path)?;
let binary_data = &*binary_data;
let object = ObjectFile::parse(binary_data).into_diagnostic()?;

Expand All @@ -282,7 +283,7 @@ fn zip_binary<P: AsRef<Path>>(

zip.start_file(
file_name.to_str().expect("failed to convert file path"),
FileOptions::default().unix_permissions(0o755),
FileOptions::default().unix_permissions(binary_perm),
)
.into_diagnostic()?;
zip.write_all(binary_data).into_diagnostic()?;
Expand All @@ -294,3 +295,15 @@ fn zip_binary<P: AsRef<Path>>(
sha256,
})
}

#[cfg(unix)]
fn binary_permissions(path: &Path) -> Result<u32> {
use std::os::unix::prelude::PermissionsExt;
let meta = std::fs::metadata(path).into_diagnostic()?;
Ok(meta.permissions().mode())
}

#[cfg(not(unix))]
fn binary_permissions(_path: &Path) -> Result<u32> {
Ok(0o755)
}
4 changes: 2 additions & 2 deletions crates/cargo-lambda-cli/Cargo.toml
Original file line number Diff line number Diff line change
@ 739E @ -1,7 +1,7 @@
[package]
name = "cargo-lambda"
description = "Cargo subcommand to work with AWS Lambda"
version = "0.8.2"
version = "0.8.3"
edition = "2021"
license = "MIT"
readme = "../../README.md"
Expand All @@ -16,7 +16,7 @@ rust-version = "1.59.0"
# add the latest version of a dependency to the list,
# and it will keep the alphabetic ordering for you.
[dependencies]
cargo-lambda-build = { version = "0.8.1", path = "../cargo-lambda-build" }
cargo-lambda-build = { version = "0.8.2", path = "../cargo-lambda-build" }
cargo-lambda-deploy = { version = "0.8.1", path = "../cargo-lambda-deploy" }
cargo-lambda-invoke = { version = "0.8.0", path = "../cargo-lambda-invoke" }
cargo-lambda-new = { version = "0.8.0", path = "../cargo-lambda-new" }
Expand Down
0