diff --git a/cup.schema.json b/cup.schema.json index ed441e8..f3c4e22 100644 --- a/cup.schema.json +++ b/cup.schema.json @@ -14,6 +14,16 @@ "type": "boolean", "description": "Whether or not to enable agent mode. When agent mode is enabled, the server only exposes the API and the web interface is unavailable." }, + "ignore_update_type": { + "type": "string", + "description": "The types of updates to ignore. Ignoring an update type also implies ignoring all update types less specific than it. For example, ignoring patch updates also implies ignoring major and minor updates.", + "enum": [ + "none", + "major", + "minor", + "patch" + ] + }, "images": { "type": "object", "description": "Configuration options for specific images", @@ -59,8 +69,8 @@ } }, "socket": { - "description": "The path to the unix socket you would like Cup to use for communication with the Docker daemon. Useful if you're trying to use Cup with Podman.", "type": "string", + "description": "The path to the unix socket you would like Cup to use for communication with the Docker daemon. Useful if you're trying to use Cup with Podman.", "minLength": 1 }, "servers": { @@ -73,8 +83,8 @@ "minProperties": 1 }, "theme": { - "description": "The theme used by the web UI", "type": "string", + "description": "The theme used by the web UI", "enum": [ "default", "blue" diff --git a/docs/src/content/docs/configuration/ignore-update-type.mdx b/docs/src/content/docs/configuration/ignore-update-type.mdx new file mode 100644 index 0000000..92d81af --- /dev/null +++ b/docs/src/content/docs/configuration/ignore-update-type.mdx @@ -0,0 +1,23 @@ +import { Callout } from "nextra/components"; + +# Ignored update types + +To ignore certain update types, you can modify your config like this: + +```jsonc +{ + "ignore_update_type": "minor" +} +``` + +Available options are: + +- `none`: Do not ignore any update types (default). +- `major`: Ignore major updates. +- `minor`: Ignore major and minor updates. +- `patch`: Ignore major, minor and patch updates. + + + Ignoring an update type also implies ignoring all update types less specific than it. + For example, ignoring patch updates also implies ignoring major and minor updates. + diff --git a/src/config.rs b/src/config.rs index 2e0c20a..9084607 100644 --- a/src/config.rs +++ b/src/config.rs @@ -6,10 +6,9 @@ use serde::Deserialize; use crate::error; #[derive(Clone, Deserialize)] +#[serde(rename_all = "snake_case")] pub enum Theme { - #[serde(rename = "default")] Default, - #[serde(rename = "blue")] Blue, } @@ -19,6 +18,21 @@ impl Default for Theme { } } +#[derive(Clone, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum UpdateType { + None, + Major, + Minor, + Patch, +} + +impl Default for UpdateType { + fn default() -> Self { + Self::None + } +} + #[derive(Clone, Deserialize, Default)] #[serde(deny_unknown_fields)] #[serde(default)] @@ -40,6 +54,7 @@ pub struct ImageConfig { pub struct Config { version: u8, pub agent: bool, + pub ignore_update_type: UpdateType, pub images: ImageConfig, pub refresh_interval: Option, pub registries: FxHashMap, @@ -53,6 +68,7 @@ impl Config { Self { version: 3, agent: false, + ignore_update_type: UpdateType::default(), images: ImageConfig::default(), refresh_interval: None, registries: FxHashMap::default(), diff --git a/src/registry.rs b/src/registry.rs index 3755319..bc561a1 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -3,6 +3,7 @@ use std::time::SystemTime; use itertools::Itertools; use crate::{ + config::UpdateType, error, http::Client, structs::{ @@ -150,6 +151,7 @@ pub async fn get_latest_tag( &headers, base, &image.version_info.as_ref().unwrap().format_str, + ctx, client, ) .await @@ -214,6 +216,7 @@ pub async fn get_extra_tags( headers: &[(&str, Option<&str>)], base: &Version, format_str: &str, + ctx: &Context, client: &Client, ) -> Result<(Vec, Option), String> { let response = client.get(url, &headers, false).await; @@ -237,7 +240,18 @@ pub async fn get_extra_tags( } _ => false, }) - .map(|(tag, _)| tag) + .filter_map(|(tag, _)| match ctx.config.ignore_update_type { + UpdateType::None => Some(tag), + UpdateType::Major => Some(tag).filter(|tag| base.major == tag.major), + UpdateType::Minor => { + Some(tag).filter(|tag| base.major == tag.major && base.minor == tag.minor) + } + UpdateType::Patch => Some(tag).filter(|tag| { + base.major == tag.major + && base.minor == tag.minor + && base.patch == tag.patch + }), + }) .dedup() .collect(); Ok((result, next_url))