mirror of
https://github.com/sergi0g/cup.git
synced 2025-11-15 08:33:49 -05:00
Compare commits
3 Commits
v3.1.0
...
v3.2.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6562ef76f | ||
|
|
846b24bf2d | ||
|
|
d7f766f1f5 |
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -355,7 +355,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cup"
|
name = "cup"
|
||||||
version = "3.1.0"
|
version = "3.2.0-alpha.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bollard",
|
"bollard",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cup"
|
name = "cup"
|
||||||
version = "3.1.0"
|
version = "3.2.0-alpha.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||

|

|
||||||

|

|
||||||

|

|
||||||

|
[](https://discord.gg/jmh5ctzwNG)
|
||||||
|
|
||||||
|
|
||||||
Cup is the easiest way to check for container image updates.
|
Cup is the easiest way to check for container image updates.
|
||||||
|
|||||||
@@ -42,7 +42,26 @@ pub async fn get_images_from_docker_daemon(
|
|||||||
references: &Option<Vec<String>>,
|
references: &Option<Vec<String>>,
|
||||||
) -> Vec<Image> {
|
) -> Vec<Image> {
|
||||||
let client: Docker = create_docker_client(ctx.config.socket.as_deref());
|
let client: Docker = create_docker_client(ctx.config.socket.as_deref());
|
||||||
match references {
|
let mut swarm_images = match client.list_services::<String>(None).await {
|
||||||
|
Ok(services) => services
|
||||||
|
.iter()
|
||||||
|
.filter_map(|service| match &service.spec {
|
||||||
|
Some(service_spec) => match &service_spec.task_template {
|
||||||
|
Some(task_spec) => match &task_spec.container_spec {
|
||||||
|
Some(container_spec) => match &container_spec.image {
|
||||||
|
Some(image) => Image::from_inspect_data(image),
|
||||||
|
None => None,
|
||||||
|
},
|
||||||
|
None => None,
|
||||||
|
},
|
||||||
|
None => None,
|
||||||
|
},
|
||||||
|
None => None,
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
Err(_) => Vec::new(),
|
||||||
|
};
|
||||||
|
let mut local_images = match references {
|
||||||
Some(refs) => {
|
Some(refs) => {
|
||||||
let mut inspect_handles = Vec::with_capacity(refs.len());
|
let mut inspect_handles = Vec::with_capacity(refs.len());
|
||||||
for reference in refs {
|
for reference in refs {
|
||||||
@@ -69,7 +88,9 @@ pub async fn get_images_from_docker_daemon(
|
|||||||
images
|
images
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|image| Image::from_inspect_data(image.clone()))
|
.filter_map(|image| Image::from_inspect_data(image.clone()))
|
||||||
.collect()
|
.collect::<Vec<Image>>()
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
local_images.append(&mut swarm_images);
|
||||||
|
local_images
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ impl Image {
|
|||||||
let digests = image.digests().unwrap();
|
let digests = image.digests().unwrap();
|
||||||
if !tags.is_empty() && !digests.is_empty() {
|
if !tags.is_empty() && !digests.is_empty() {
|
||||||
let reference = tags[0].clone();
|
let reference = tags[0].clone();
|
||||||
|
if reference.contains('@') {
|
||||||
|
return None; // As far as I know, references that contain @ are either manually pulled by the user or automatically created because of swarm. In the first case AFAICT we can't know what tag was originally pulled, so we'd have to make assumptions and I've decided to remove this. The other case is already handled seperately, so this also ensures images aren't displayed twice, once with and once without a digest.
|
||||||
|
};
|
||||||
let (registry, repository, tag) = split(&reference);
|
let (registry, repository, tag) = split(&reference);
|
||||||
let version_tag = Version::from_tag(&tag);
|
let version_tag = Version::from_tag(&tag);
|
||||||
let local_digests = digests
|
let local_digests = digests
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
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>>;
|
||||||
fn url(&self) -> Option<String>;
|
fn url(&self) -> Option<String>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InspectData for ImageInspect {
|
impl InspectData for ImageInspect {
|
||||||
fn tags(&self) -> Option<&Vec<String>> {
|
fn tags(&self) -> Option<Vec<String>> {
|
||||||
self.repo_tags.as_ref()
|
self.repo_tags.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn digests(&self) -> Option<&Vec<String>> {
|
fn digests(&self) -> Option<Vec<String>> {
|
||||||
self.repo_digests.as_ref()
|
self.repo_digests.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn url(&self) -> Option<String> {
|
fn url(&self) -> Option<String> {
|
||||||
@@ -27,15 +27,36 @@ impl InspectData for ImageInspect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl InspectData for ImageSummary {
|
impl InspectData for ImageSummary {
|
||||||
fn tags(&self) -> Option<&Vec<String>> {
|
fn tags(&self) -> Option<Vec<String>> {
|
||||||
Some(&self.repo_tags)
|
Some(self.repo_tags.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn digests(&self) -> Option<&Vec<String>> {
|
fn digests(&self) -> Option<Vec<String>> {
|
||||||
Some(&self.repo_digests)
|
Some(self.repo_digests.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn url(&self) -> Option<String> {
|
fn url(&self) -> Option<String> {
|
||||||
self.labels.get("org.opencontainers.image.url").cloned()
|
self.labels.get("org.opencontainers.image.url").cloned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl InspectData for &String {
|
||||||
|
fn tags(&self) -> Option<Vec<String>> {
|
||||||
|
self.split('@').next().map(|tag| vec![tag.to_string()])
|
||||||
|
}
|
||||||
|
|
||||||
|
fn digests(&self) -> Option<Vec<String>> {
|
||||||
|
match self.split_once('@') {
|
||||||
|
Some((reference, digest)) => Some(vec![format!(
|
||||||
|
"{}@{}",
|
||||||
|
reference.split(':').next().unwrap(),
|
||||||
|
digest
|
||||||
|
)]),
|
||||||
|
None => Some(vec![]),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn url(&self) -> Option<String> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user