Skip to content

Commit

Permalink
Implementing artifact download functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mars committed Oct 17, 2024
1 parent 9dedb9c commit cb310f7
Show file tree
Hide file tree
Showing 4 changed files with 726 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

3 changes: 2 additions & 1 deletion common/release_artifacts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ workspace = true
[dependencies]
aws-config = { version = "1.5.7", features = ["behavior-version-latest"] }
aws-sdk-s3 = { version = "1.52.0", features = ["rt-tokio"] }
aws-smithy-types = { version = "1.2.7" }
flate2 = { version = "1.0.33", default-features = false, features = ["zlib"] }
regex = { version = "1.11.0" }
tar = { version = "0.4.41", default-features = false }
Expand All @@ -19,4 +20,4 @@ url = { version = "2.5.2" }
[dev-dependencies]
aws-smithy-types = { version = "1.0.1" }
aws-smithy-runtime = { version = "1.0.1", features = ["test-util"] }
http = "0.2.9"
http = "1.1.0"
27 changes: 18 additions & 9 deletions common/release_artifacts/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
#[derive(Debug)]
pub enum ReleaseArtifactsError {
ArchiveError(std::io::Error),
ArchiveError(std::io::Error, String),
ArchiveStreamError(aws_sdk_s3::primitives::ByteStreamError),
ConfigMissing(String),
StorageError(String),
StorageKeyNotFound(String),
StorageURLInvalid(url::ParseError),
StorageURLHostMissing(String),
}

impl<T: aws_sdk_s3::error::ProvideErrorMetadata> From<T> for ReleaseArtifactsError {
impl<T: std::error::Error + aws_sdk_s3::error::ProvideErrorMetadata> From<T>
for ReleaseArtifactsError
{
fn from(value: T) -> Self {
ReleaseArtifactsError::StorageError(format!(
"{}: {}",
value.code().map_or("unknown code".into(), String::from),
value
.message()
.map_or("missing reason".into(), String::from),
))
match value.code() {
Some(code) => match code {
"NoSuchKey" => ReleaseArtifactsError::StorageKeyNotFound("Not Found".to_string()),
_ => ReleaseArtifactsError::StorageError(format!(
"{code}: {}",
value.message().map_or("(no message)".into(), String::from)
)),
},
_ => ReleaseArtifactsError::StorageError(format!(
"{}",
aws_smithy_types::error::display::DisplayErrorContext(value)
)),
}
}
}
Loading

0 comments on commit cb310f7

Please sign in to comment.