From e39d6b1cd21e8c400aa0693a2c7c5f1cbbd2056a Mon Sep 17 00:00:00 2001 From: David Edler Date: Wed, 3 Apr 2024 14:59:54 +0200 Subject: [PATCH] feat(images) add lxd images server Signed-off-by: David Edler --- src/pages/images/ImageSelector.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/pages/images/ImageSelector.tsx b/src/pages/images/ImageSelector.tsx index 33a4fa791a..178c326f21 100644 --- a/src/pages/images/ImageSelector.tsx +++ b/src/pages/images/ImageSelector.tsx @@ -41,6 +41,9 @@ const minimalJson = "https://cloud-images.ubuntu.com/minimal/releases/streams/v1/com.ubuntu.cloud:released:download.json"; const minimalServer = "https://cloud-images.ubuntu.com/minimal/releases/"; +const imagesLxdJson = "https://images.lxd.canonical.com/streams/v1/images.json"; +const imagesLxdServer = "https://images.lxd.canonical.com/"; + const ANY = "any"; const CONTAINER = "container"; const VM = "virtual-machine"; @@ -82,13 +85,23 @@ const ImageSelector: FC = ({ onSelect, onClose }) => { queryFn: () => loadImages(minimalJson, minimalServer), }); + const { data: imagesLxdImages = [], isLoading: isImagesLxdLoading } = + useQuery({ + queryKey: [queryKeys.images, imagesLxdServer], + queryFn: () => loadImages(imagesLxdJson, imagesLxdServer), + }); + const { data: localImages = [], isLoading: isLocalImageLoading } = useQuery({ queryKey: [queryKeys.images, project], queryFn: () => fetchImageList(project ?? ""), }); const isLoading = - isCiLoading || isMinimalLoading || isLocalImageLoading || isSettingsLoading; + isCiLoading || + isMinimalLoading || + isImagesLxdLoading || + isLocalImageLoading || + isSettingsLoading; const archSupported = getArchitectureAliases( settings?.environment?.architectures ?? [], ); @@ -99,6 +112,7 @@ const ImageSelector: FC = ({ onSelect, onClose }) => { .map(localLxdToRemoteImage) .concat([...minimalImages].reverse().sort(byLtsFirst)) .concat([...canonicalImages].reverse().sort(byLtsFirst)) + .concat([...imagesLxdImages]) .filter((image) => archSupported.includes(image.arch)); const archAll = [...new Set(images.map((item) => item.arch))] @@ -205,6 +219,9 @@ const ImageSelector: FC = ({ onSelect, onClose }) => { if (item.server === minimalServer) { return "Ubuntu Minimal"; } + if (item.server === imagesLxdServer) { + return "LXD Images"; + } return "Custom"; };