From 0eedcf58f591a775fe10ef8f9502a2b334e23f97 Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Wed, 1 Apr 2026 08:50:59 -0600 Subject: [PATCH] feat: support data URLs, http(s) URLs, and file:// URLs in registry set-icon CLI --- core/locales/i18n.yaml | 7 +++++++ core/src/registry/info.rs | 23 +++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/core/locales/i18n.yaml b/core/locales/i18n.yaml index 08e0aaa5e..b1f899fe6 100644 --- a/core/locales/i18n.yaml +++ b/core/locales/i18n.yaml @@ -2959,6 +2959,13 @@ help.arg.icon-path: fr_FR: "Chemin vers le fichier d'icône du service" pl_PL: "Ścieżka do pliku ikony usługi" +help.arg.icon-source: + en_US: "Icon source: file path, file:// URL, http(s):// URL, or data: URL" + de_DE: "Icon-Quelle: Dateipfad, file://-URL, http(s)://-URL oder data:-URL" + es_ES: "Fuente del icono: ruta de archivo, URL file://, URL http(s):// o URL data:" + fr_FR: "Source de l'icône : chemin de fichier, URL file://, URL http(s):// ou URL data:" + pl_PL: "Źródło ikony: ścieżka pliku, URL file://, URL http(s):// lub URL data:" + help.arg.image-id: en_US: "Docker image identifier" de_DE: "Docker-Image-Kennung" diff --git a/core/src/registry/info.rs b/core/src/registry/info.rs index c6c9ae81e..72cceab80 100644 --- a/core/src/registry/info.rs +++ b/core/src/registry/info.rs @@ -1,5 +1,4 @@ use std::collections::BTreeMap; -use std::path::PathBuf; use clap::Parser; use imbl_value::InternedString; @@ -107,8 +106,8 @@ pub async fn set_icon( #[serde(rename_all = "camelCase")] #[ts(export)] pub struct CliSetIconParams { - #[arg(help = "help.arg.icon-path")] - pub icon: PathBuf, + #[arg(help = "help.arg.icon-source")] + pub icon: String, } pub async fn cli_set_icon( @@ -120,7 +119,23 @@ pub async fn cli_set_icon( .. }: HandlerArgs, ) -> Result<(), Error> { - let data_url = DataUrl::from_path(icon).await?; + let data_url = if icon.starts_with("data:") { + icon.parse::>() + .with_kind(ErrorKind::ParseUrl)? + } else if icon.starts_with("https://") || icon.starts_with("http://") { + let res = ctx + .client + .get(&icon) + .send() + .await + .with_kind(ErrorKind::Network)?; + DataUrl::from_response(res).await? + } else { + let path = icon + .strip_prefix("file://") + .unwrap_or(&icon); + DataUrl::from_path(path).await? + }; ctx.call_remote::( &parent_method.into_iter().chain(method).join("."), imbl_value::json!({