Skip to content
Open
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
515 changes: 501 additions & 14 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"tools/bottlerocket-variant",
"tools/buildsys",
"tools/buildsys-config",
"tools/casi",
"tools/include-env-compressed",
"tools/include-env-compressed/include-env-compressed-macro",
"tools/oci-cli-wrapper",
Expand Down Expand Up @@ -89,6 +90,8 @@ unplug = { version = "0.1", path = "tools/unplug", artifact = [ "bin:unplug" ] }
update-metadata = { version = "0.1", path = "tools/update-metadata" }

anyhow = "1"
astral-tokio-tar = "0.5"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect you will be like O.O about this tokio tar and the async-compression crate below. The astral-tokio-tar is the currently maintaing tokio tar crate variant which provides us to use streaming tar readers for archives. async-compression likewise creates bufread and writer wrappers over zstd

async-compression = "0.4"
async-recursion = "1"
async-stream = "0.3"
async-trait = "0.1"
Expand All @@ -100,6 +103,7 @@ aws-sdk-ec2 = { version = "1", default-features = false, features = ["default-ht
aws-sdk-kms = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] }
aws-sdk-ssm = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] }
aws-sdk-sts = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] }
aws-sdk-s3 = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] }
aws-smithy-types = "1"
aws-types = "1"
base64 = "0.22"
Expand Down Expand Up @@ -131,10 +135,13 @@ lzma-rs = "0.3"
maplit = "1"
nix = "0.29"
nonzero_ext = "0.3"
num_cpus = "1"
num_cpus = "1.17"
num-traits = "0.2"
oci-spec = "0.8"
once_cell = "1.21"
olpc-cjson = "0.1"
owo-colors = "4.2"
parking_lot = "0.12"
proc-macro2 = "1"
quote = "1"
rand = { version = "0.8", default-features = false }
Expand Down Expand Up @@ -166,6 +173,8 @@ tough = "0.21"
tough-kms = "0.13"
tough-ssm = "0.16"
tracing = "0.1"
tracing-indicatif = "=0.3.9"
tracing-subscriber = "0.3"
tuftool = { version = "0.14", artifact = [ "bin:tuftool" ] }
uds = "0.4.1"
unescape = "0.1"
Expand Down
2 changes: 2 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ wildcards = "deny"
skip = [
# several dependencies are using multiple versions of base64
{ name = "base64" },
# owo-colors uses two versions of supports-color by itself
{ name = "supports-color" }
]

skip-tree = [
Expand Down
45 changes: 45 additions & 0 deletions tools/casi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[package]
name = "casi"
version = "0.1.0"
authors = ["Jarrett Tierney <[email protected]>"]
license = "Apache-2.0 OR MIT"
edition = "2021"
publish = false

[dependencies]
astral-tokio-tar.workspace = true
async-compression = { workspace = true, features = ["tokio", "zstd"] }
async-trait.workspace = true
aws-config.workspace = true
aws-sdk-s3.workspace = true
aws-smithy-types.workspace = true
aws-types.workspace = true
bon.workspace = true
chrono = { workspace = true, features = ["serde", "now"] }
clap = { workspace = true, features = ["derive"] }
futures.workspace = true
hex.workspace = true
indicatif.workspace = true
oci-spec.workspace = true
olpc-cjson.workspace = true
owo-colors = { workspace = true, features = ["supports-colors"] }
parking_lot = { workspace = true, features = ["send_guard", "arc_lock"] }
rand.workspace = true
semver = { workspace = true, features = ["serde"] }
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
sha2.workspace = true
snafu.workspace = true
tempfile.workspace = true
tokio = { workspace = true, features = ["full"] }
tracing.workspace = true
tracing-indicatif.workspace = true
tracing-subscriber = { workspace = true, features = [
"env-filter",
"fmt",
"registry",
] }
url = { workspace = true, features = ["serde"] }
uuid = { workspace = true, features = ["v4"] }
walkdir.workspace = true
zstd.workspace = true
48 changes: 48 additions & 0 deletions tools/casi/src/constants.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//! Constants used throughout the casi crate.
//!
//! This module centralizes magic numbers and commonly used values to improve
//! code maintainability and reduce the likelihood of errors.

/// Default buffer size for I/O operations (64KB)
pub const DEFAULT_BUFFER_SIZE: usize = 64 * 1024;

/// Buffer size for hashing operations (128MB)
/// Uses 8KB chunks which align with standard memory page sizes for optimal
/// performance when reading from files and network streams.
pub const HASH_BUFFER_SIZE: usize = 128 * 1024 * 1024;

/// Maximum number of multipart upload parts for S3
pub const MAX_MULTIPART_PARTS: usize = 10_000;

/// Minimum size for S3 multipart upload parts (5MB)
pub const MIN_MULTIPART_PART_SIZE: usize = 5 * 1024 * 1024;

/// Default compression level for Zstd
pub const DEFAULT_COMPRESSION_LEVEL: i32 = 3;

/// Maximum file name length for cross-platform compatibility
pub const MAX_FILENAME_LENGTH: usize = 255;

/// Default timeout for network operations (30 seconds)
pub const DEFAULT_NETWORK_TIMEOUT_SECS: u64 = 30;

/// Maximum retry attempts for transient failures
pub const MAX_RETRY_ATTEMPTS: usize = 3;

/// Default page size for listing operations
pub const DEFAULT_PAGE_SIZE: usize = 100;

/// Maximum artifacts to display in table format
pub const MAX_TABLE_DISPLAY_ARTIFACTS: usize = 1000;

/// Hash truncation length for display purposes
pub const HASH_DISPLAY_LENGTH: usize = 16;

/// Schema version for OCI manifests
pub const OCI_MANIFEST_SCHEMA_VERSION: u32 = 2;

/// Default file permissions for created files (0o644)
pub const DEFAULT_FILE_PERMISSIONS: u32 = 0o644;

/// Default directory permissions for created directories (0o755)
pub const DEFAULT_DIR_PERMISSIONS: u32 = 0o755;
20 changes: 20 additions & 0 deletions tools/casi/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use snafu::Snafu;

pub type Result<T> = std::result::Result<T, Error>;

#[derive(Debug, Snafu)]
#[snafu(visibility(pub))]
pub enum Error {
#[snafu(display(
"Failed to read data for hashing: {source} - check if the file exists and is readable"
))]
HashingReadError { source: std::io::Error },

#[snafu(display("Failed to initialize logging system: {source}"))]
LogInit {
source: Box<dyn std::error::Error + Send + Sync>,
},

#[snafu(display("Failed to parse log directive: {directive}"))]
LogDirectiveParse { directive: String },
}
Loading