From 1d5d17e5f71af2d19fc8cf617caabc80a35ce208 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Mon, 22 Jul 2024 18:34:26 +0200 Subject: [PATCH] feat(reference): Add clone_with_digest() function This allows to create a copy of the reference but setting a new digest. This also copies the registry_mirror, so the digest also gets pulled from the same mirror. Signed-off-by: Benjamin Neff Signed-off-by: Colin Walters --- src/distribution/reference.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/distribution/reference.rs b/src/distribution/reference.rs index c8fbf210f9..df183d2e1f 100644 --- a/src/distribution/reference.rs +++ b/src/distribution/reference.rs @@ -104,6 +104,17 @@ impl Reference { } } + /// Clone the Reference for the same image with a new digest. + pub fn clone_with_digest(&self, digest: String) -> Self { + Self { + registry: self.registry.clone(), + mirror_registry: self.mirror_registry.clone(), + repository: self.repository.clone(), + tag: None, + digest: Some(digest), + } + } + /// Set a pull mirror registry for this reference. /// /// The mirror registry will be used to resolve the image, the original registry