mirror of
https://github.com/anthonyoteri/dredge.git
synced 2026-06-05 15:26:53 -04:00
Compare commits
11 Commits
v1.1.0
...
9b602f70a6
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b602f70a6 | |||
| f12615a7f2 | |||
| 39c03a2b5b | |||
| f836b26930 | |||
| 0d9761178c | |||
| 358a19f6f7 | |||
| 0527b6268d | |||
| 67c02581f3 | |||
| b6fda7162f | |||
| 07746429bb | |||
| 23f1d21a2e |
@@ -45,7 +45,7 @@ jobs:
|
||||
continue-on-error: true
|
||||
|
||||
- name: Upload analysis results ot GitHub
|
||||
uses: github/codeql-action/upload-sarif@v2
|
||||
uses: github/codeql-action/upload-sarif@v3
|
||||
with:
|
||||
sarif_file: rust-clippy-results.sarif
|
||||
wait-for-processing: true
|
||||
+4
-4
@@ -27,11 +27,11 @@ name = "dredge"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.4.3", features = ["derive", "env", "wrap_help"] }
|
||||
simple_logger = { version = "4.2.0", features = ["timestamps", "colors", "stderr"] }
|
||||
http = "0.2.9"
|
||||
simple_logger = { version = "5.0.0", features = ["timestamps", "colors", "stderr"] }
|
||||
http = "1.0.0"
|
||||
indoc = "2.0.4"
|
||||
log = "0.4.20"
|
||||
reqwest = { version = "0.11.20", features = ["json", "gzip", "multipart", "native-tls-vendored"] }
|
||||
reqwest = { version = "0.12.3", features = ["json", "gzip", "multipart", "native-tls-vendored"] }
|
||||
serde = { version = "1.0.188", features = ["derive"] }
|
||||
serde_toml = "0.0.1"
|
||||
serde_yaml = "0.9.25"
|
||||
@@ -43,4 +43,4 @@ tokio = { version = "1.32.0", features = ["macros"] }
|
||||
|
||||
[dev-dependencies]
|
||||
mockito = "1.2.0"
|
||||
env_logger = "0.10.0"
|
||||
env_logger = "0.11.3"
|
||||
|
||||
+9
-9
@@ -7,7 +7,9 @@
|
||||
* copied, modified, or distributed except according to those terms.
|
||||
*/
|
||||
|
||||
use http::header;
|
||||
use reqwest::header;
|
||||
use reqwest::header::HeaderValue;
|
||||
use reqwest::StatusCode;
|
||||
use serde::Deserialize;
|
||||
use url::Url;
|
||||
|
||||
@@ -52,7 +54,7 @@ pub async fn fetch_paginated<T: for<'de> Deserialize<'de>>(
|
||||
responses.push(json);
|
||||
}
|
||||
|
||||
if let Some(p) = parse_rfc5988(headers.get(http::header::LINK))? {
|
||||
if let Some(p) = parse_rfc5988(headers.get(header::LINK))? {
|
||||
next_path = p;
|
||||
} else {
|
||||
break;
|
||||
@@ -73,7 +75,7 @@ pub async fn fetch_paginated<T: for<'de> Deserialize<'de>>(
|
||||
///
|
||||
/// Returns and `ApiError` if there is a problem parsing contents of the
|
||||
/// supplied header value.
|
||||
fn parse_rfc5988(header_value: Option<&http::HeaderValue>) -> Result<Option<String>, ApiError> {
|
||||
fn parse_rfc5988(header_value: Option<&HeaderValue>) -> Result<Option<String>, ApiError> {
|
||||
log::trace!("parse_rfc5988(header_value: {header_value:?})");
|
||||
|
||||
if let Some(link_value) = header_value {
|
||||
@@ -127,7 +129,7 @@ pub fn parse_response_status(response: &reqwest::Response) -> Result<(), ApiErro
|
||||
log::trace!("parse_response_status(response: {response:?})");
|
||||
|
||||
match response.status() {
|
||||
http::StatusCode::OK | http::StatusCode::ACCEPTED => {
|
||||
StatusCode::OK | StatusCode::ACCEPTED => {
|
||||
let headers = response.headers();
|
||||
if let Some(header_value) = headers.get("Docker-Distribution-API-Version") {
|
||||
if header_value.to_str()? == "registry/2.0" {
|
||||
@@ -141,8 +143,8 @@ pub fn parse_response_status(response: &reqwest::Response) -> Result<(), ApiErro
|
||||
))
|
||||
}
|
||||
}
|
||||
http::StatusCode::METHOD_NOT_ALLOWED => Err(ApiError::MethodNotAllowed),
|
||||
http::StatusCode::UNAUTHORIZED => {
|
||||
StatusCode::METHOD_NOT_ALLOWED => Err(ApiError::MethodNotAllowed),
|
||||
StatusCode::UNAUTHORIZED => {
|
||||
let headers = response.headers();
|
||||
if let Some(header_value) = headers.get("Docker-Distribution-API-Version") {
|
||||
if header_value.to_str()? == "registry/2.0" {
|
||||
@@ -156,7 +158,7 @@ pub fn parse_response_status(response: &reqwest::Response) -> Result<(), ApiErro
|
||||
))
|
||||
}
|
||||
}
|
||||
http::StatusCode::NOT_FOUND => Err(ApiError::NotFound),
|
||||
StatusCode::NOT_FOUND => Err(ApiError::NotFound),
|
||||
e => Err(ApiError::UnexpectedResponse(format!(
|
||||
"Undocumented status code: {e:?}"
|
||||
))),
|
||||
@@ -192,8 +194,6 @@ pub async fn get_digest(client: &reqwest::Client, url: &Url) -> Result<String, A
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use http::header::HeaderValue;
|
||||
|
||||
use super::*;
|
||||
|
||||
/// Test parsing a valid RFC5988 header value.
|
||||
|
||||
Reference in New Issue
Block a user