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

feat: Add option for using monolithic push #177

Open
wants to merge 1 commit into
base: main
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
22 changes: 15 additions & 7 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,14 +559,18 @@ impl Client {
data: &[u8],
digest: &str,
) -> Result<String> {
match self.push_blob_chunked(image_ref, data, digest).await {
Ok(url) => Ok(url),
Err(OciDistributionError::SpecViolationError(violation)) => {
warn!(?violation, "Registry is not respecting the OCI Distribution Specification when doing chunked push operations");
warn!("Attempting monolithic push");
self.push_blob_monolithically(image_ref, data, digest).await
if self.config.use_monolithic_push {
self.push_blob_monolithically(image_ref, data, digest).await
} else {
match self.push_blob_chunked(image_ref, data, digest).await {
Ok(url) => Ok(url),
Err(OciDistributionError::SpecViolationError(violation)) => {
warn!(?violation, "Registry is not respecting the OCI Distribution Specification when doing chunked push operations");
warn!("Attempting monolithic push");
self.push_blob_monolithically(image_ref, data, digest).await
}
Err(e) => Err(e),
}
Err(e) => Err(e),
}
}

Expand Down Expand Up @@ -1797,6 +1801,9 @@ pub struct ClientConfig {
/// Accept invalid certificates. Defaults to false
pub accept_invalid_certificates: bool,

/// Use monolithic push for pushing blobs. Defaults to false
pub use_monolithic_push: bool,

/// A list of extra root certificate to trust. This can be used to connect
/// to servers using self-signed certificates
pub extra_root_certificates: Vec<Certificate>,
Expand Down Expand Up @@ -1861,6 +1868,7 @@ impl Default for ClientConfig {
#[cfg(feature = "native-tls")]
accept_invalid_hostnames: false,
accept_invalid_certificates: false,
use_monolithic_push: false,
extra_root_certificates: Vec::new(),
platform_resolver: Some(Box::new(current_platform_resolver)),
max_concurrent_upload: DEFAULT_MAX_CONCURRENT_UPLOAD,
Expand Down