feat: auto-discover container images from registries
- Add ListImages() to registry interface, implement for Gitea - Add owner field to registry config (needed for Gitea packages API) - GET /api/registries/:id/images endpoint - "Browse Images" button on Projects and Quick Deploy pages - Image dropdown with registry grouping and search - i18n support (EN/RU) for all new UI strings
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { inspectImage, quickDeploy } from '$lib/api';
|
||||
import type { InspectResult } from '$lib/types';
|
||||
import { inspectImage, quickDeploy, listRegistries, listRegistryImages } from '$lib/api';
|
||||
import type { InspectResult, Registry, RegistryImage } from '$lib/types';
|
||||
import FormField from '$lib/components/FormField.svelte';
|
||||
import { toasts } from '$lib/stores/toast';
|
||||
import { t } from '$lib/i18n';
|
||||
@@ -21,6 +21,44 @@
|
||||
|
||||
let errors = $state<Record<string, string>>({});
|
||||
|
||||
// Image browser state
|
||||
let showImageBrowser = $state(false);
|
||||
let browseImages = $state<(RegistryImage & { registryName: string })[]>([]);
|
||||
let browseLoading = $state(false);
|
||||
|
||||
async function handleBrowseImages() {
|
||||
showImageBrowser = !showImageBrowser;
|
||||
if (!showImageBrowser) return;
|
||||
|
||||
browseLoading = true;
|
||||
browseImages = [];
|
||||
try {
|
||||
const registries = await listRegistries();
|
||||
const allImages: (RegistryImage & { registryName: string })[] = [];
|
||||
for (const reg of registries) {
|
||||
if (!reg.owner) continue;
|
||||
try {
|
||||
const images = await listRegistryImages(reg.id);
|
||||
for (const img of images) {
|
||||
allImages.push({ ...img, registryName: reg.name });
|
||||
}
|
||||
} catch {
|
||||
// Skip registries that fail.
|
||||
}
|
||||
}
|
||||
browseImages = allImages;
|
||||
} catch {
|
||||
toasts.error($t('quickDeploy.imageLoadFailed'));
|
||||
} finally {
|
||||
browseLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
function selectBrowsedImage(image: RegistryImage & { registryName: string }) {
|
||||
imageUrl = image.full_ref + ':latest';
|
||||
showImageBrowser = false;
|
||||
}
|
||||
|
||||
function validateImageUrl(url: string): string {
|
||||
if (!url.trim()) return $t('validation.required', { field: 'Image URL' });
|
||||
if (!/^[a-zA-Z0-9._\-/]+:[a-zA-Z0-9._\-]+$/.test(url.trim())) {
|
||||
@@ -137,7 +175,15 @@
|
||||
disabled={inspecting}
|
||||
/>
|
||||
</div>
|
||||
<div class="flex items-end">
|
||||
<div class="flex items-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onclick={handleBrowseImages}
|
||||
class="inline-flex items-center gap-1.5 rounded-lg border border-[var(--border-primary)] px-3 py-2 text-sm font-medium text-[var(--text-secondary)] hover:bg-[var(--surface-card-hover)] transition-colors"
|
||||
>
|
||||
<IconSearch size={14} />
|
||||
{$t('quickDeploy.browseImages')}
|
||||
</button>
|
||||
<button
|
||||
onclick={handleInspect}
|
||||
disabled={inspecting || !imageUrl.trim()}
|
||||
@@ -153,6 +199,34 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{#if showImageBrowser}
|
||||
<div class="mt-3 rounded-lg border border-[var(--border-primary)] bg-[var(--surface-card)] p-3 shadow-[var(--shadow-md)] max-h-60 overflow-y-auto animate-scale-in">
|
||||
{#if browseLoading}
|
||||
<div class="flex items-center gap-2 py-2 text-sm text-[var(--text-secondary)]">
|
||||
<IconLoader size={14} />
|
||||
{$t('quickDeploy.loadingImages')}
|
||||
</div>
|
||||
{:else if browseImages.length === 0}
|
||||
<p class="text-sm text-[var(--text-tertiary)]">{$t('quickDeploy.noImages')}</p>
|
||||
{:else}
|
||||
<p class="mb-2 text-xs font-medium text-[var(--text-tertiary)]">{$t('quickDeploy.selectImage')}</p>
|
||||
<ul class="space-y-1">
|
||||
{#each browseImages as image}
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => selectBrowsedImage(image)}
|
||||
class="w-full rounded-md px-3 py-2 text-left text-sm hover:bg-[var(--surface-card-hover)] transition-colors"
|
||||
>
|
||||
<span class="font-medium text-[var(--text-primary)]">{image.full_ref}</span>
|
||||
<span class="ml-2 text-xs text-[var(--text-tertiary)]">({image.registryName})</span>
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Step 2 -->
|
||||
|
||||
Reference in New Issue
Block a user