mirror of
https://github.com/sergi0g/cup.git
synced 2025-11-16 17:13:46 -05:00
Remove some clone usage
This commit is contained in:
@@ -1,26 +1,26 @@
|
|||||||
use bollard::secret::{ImageInspect, ImageSummary};
|
use bollard::secret::{ImageInspect, ImageSummary};
|
||||||
|
|
||||||
pub trait InspectData {
|
pub trait InspectData {
|
||||||
fn tags(&self) -> Option<Vec<String>>;
|
fn tags(&self) -> Option<&Vec<String>>;
|
||||||
fn digests(&self) -> Option<Vec<String>>;
|
fn digests(&self) -> Option<&Vec<String>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InspectData for ImageInspect {
|
impl InspectData for ImageInspect {
|
||||||
fn tags(&self) -> Option<Vec<String>> {
|
fn tags(&self) -> Option<&Vec<String>> {
|
||||||
self.repo_tags.clone()
|
self.repo_tags.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn digests(&self) -> Option<Vec<String>> {
|
fn digests(&self) -> Option<&Vec<String>> {
|
||||||
self.repo_digests.clone()
|
self.repo_digests.as_ref()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InspectData for ImageSummary {
|
impl InspectData for ImageSummary {
|
||||||
fn tags(&self) -> Option<Vec<String>> {
|
fn tags(&self) -> Option<&Vec<String>> {
|
||||||
Some(self.repo_tags.clone())
|
Some(&self.repo_tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn digests(&self) -> Option<Vec<String>> {
|
fn digests(&self) -> Option<&Vec<String>> {
|
||||||
Some(self.repo_digests.clone())
|
Some(&self.repo_digests)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,13 @@ pub fn split(reference: &str) -> (String, String, String) {
|
|||||||
Some(registry) => registry.as_str().to_owned(),
|
Some(registry) => registry.as_str().to_owned(),
|
||||||
None => String::from(DEFAULT_REGISTRY),
|
None => String::from(DEFAULT_REGISTRY),
|
||||||
};
|
};
|
||||||
|
let is_default_registry = registry == DEFAULT_REGISTRY;
|
||||||
return (
|
return (
|
||||||
registry.clone(),
|
registry,
|
||||||
match c.name("repository") {
|
match c.name("repository") {
|
||||||
Some(repository) => {
|
Some(repository) => {
|
||||||
let repo = repository.as_str().to_owned();
|
let repo = repository.as_str().to_owned();
|
||||||
if !repo.contains('/') && registry == DEFAULT_REGISTRY {
|
if !repo.contains('/') && is_default_registry {
|
||||||
format!("library/{}", repo)
|
format!("library/{}", repo)
|
||||||
} else {
|
} else {
|
||||||
repo
|
repo
|
||||||
|
|||||||
Reference in New Issue
Block a user