From b314111ce5f51640280357dc217d0e210fe21609 Mon Sep 17 00:00:00 2001 From: Charlie Drage Date: Wed, 16 Oct 2024 14:02:15 -0400 Subject: [PATCH] update Signed-off-by: Charlie Drage --- packages/backend/src/api-impl.ts | 8 ++++---- packages/frontend/src/App.svelte | 1 - .../src/lib/disk-image/DiskImageDetails.svelte | 2 +- .../DiskImageDetailsVirtualMachine.svelte | 14 +++++++------- packages/shared/src/BootcAPI.ts | 4 ++-- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/backend/src/api-impl.ts b/packages/backend/src/api-impl.ts index fd8a634b..85201f78 100644 --- a/packages/backend/src/api-impl.ts +++ b/packages/backend/src/api-impl.ts @@ -47,8 +47,8 @@ export class BootcApiImpl implements BootcApi { return checkPrereqs(await getContainerEngine()); } - async checkVMLaunchPrereqs(folder: string, architecture: string): Promise { - return new VMManager(folder, architecture).checkVMLaunchPrereqs(); + async checkVMLaunchPrereqs(build: BootcBuildInfo): Promise { + return new VMManager(build.folder, build.arch).checkVMLaunchPrereqs(); } async buildExists(folder: string, types: BuildType[]): Promise { @@ -59,9 +59,9 @@ export class BootcApiImpl implements BootcApi { return buildDiskImage(build, this.history, overwrite); } - async launchVM(folder: string, architecture: string): Promise { + async launchVM(build: BootcBuildInfo): Promise { try { - await new VMManager(folder, architecture).launchVM(); + await new VMManager(build.folder, build.arch).launchVM(); // Notify it has successfully launched await this.notify(Messages.MSG_VM_LAUNCH_ERROR, { success: 'Launched!', error: '' }); } catch (e) { diff --git a/packages/frontend/src/App.svelte b/packages/frontend/src/App.svelte index 59b60266..3fa59ec4 100644 --- a/packages/frontend/src/App.svelte +++ b/packages/frontend/src/App.svelte @@ -9,7 +9,6 @@ import { getRouterState } from './api/client'; import Homepage from './Homepage.svelte'; import { rpcBrowser } from '/@/api/client'; import { Messages } from '/@shared/src/messages/Messages'; -import VM from './lib/disk-image/DiskImageDetailsVirtualMachine.svelte'; import DiskImageDetails from './lib/disk-image/DiskImageDetails.svelte'; router.mode.hash(); diff --git a/packages/frontend/src/lib/disk-image/DiskImageDetails.svelte b/packages/frontend/src/lib/disk-image/DiskImageDetails.svelte index 2a240573..3d04c4af 100644 --- a/packages/frontend/src/lib/disk-image/DiskImageDetails.svelte +++ b/packages/frontend/src/lib/disk-image/DiskImageDetails.svelte @@ -84,7 +84,7 @@ export function goToHomePage(): void { {#if diskImage?.folder && diskImage?.arch} - + {/if} diff --git a/packages/frontend/src/lib/disk-image/DiskImageDetailsVirtualMachine.svelte b/packages/frontend/src/lib/disk-image/DiskImageDetailsVirtualMachine.svelte index 961fc1d0..846401a6 100644 --- a/packages/frontend/src/lib/disk-image/DiskImageDetailsVirtualMachine.svelte +++ b/packages/frontend/src/lib/disk-image/DiskImageDetailsVirtualMachine.svelte @@ -12,9 +12,9 @@ import VMConnectionStatus from '../../VMConnectionStatus.svelte'; import Link from '../Link.svelte'; import { Messages } from '/@shared/src/messages/Messages'; import type { Subscriber } from '/@shared/src/messages/MessageProxy'; +import type { BootcBuildInfo } from '/@shared/src/models/bootc'; -export let folderLocation: string; -export let architecture: string = ''; +export let build: BootcBuildInfo; // Terminal and WebSocket connection variables let logsXtermDiv: HTMLDivElement; @@ -174,12 +174,12 @@ async function initTerminal() { } // Launch the VM with the folder location and architecture required. -async function launchVM(folderLocation: string, architecture: string): Promise { +async function launchVM(build: BootcBuildInfo): Promise { launchInProgress = true; // This is launched IN THE BACKGROUND. We do not wait for the VM to boot before showing the terminal. // we instead are notified by subscribing to Messages.MSG_VM_LAUNCH_ERROR messages from RPC - bootcClient.launchVM(folderLocation, architecture); + bootcClient.launchVM(build); // Initialize the terminal so it awaits the websocket connection. await initTerminal(); @@ -193,7 +193,7 @@ async function launchVM(folderLocation: string, architecture: string): Promise { resizeObserver.observe(logsXtermDiv); // Launch the VM if we pass all the prerequisites, otherwise we will show the empty screen with content / information checks. - vmLaunchPrereqs = await bootcClient.checkVMLaunchPrereqs(folderLocation, architecture); + vmLaunchPrereqs = await bootcClient.checkVMLaunchPrereqs(build); if (!vmLaunchPrereqs) { - await launchVM(folderLocation, architecture); + await launchVM(build); } }); diff --git a/packages/shared/src/BootcAPI.ts b/packages/shared/src/BootcAPI.ts index 9bc5c167..9f705b0e 100644 --- a/packages/shared/src/BootcAPI.ts +++ b/packages/shared/src/BootcAPI.ts @@ -21,7 +21,8 @@ import type { ImageInfo, ImageInspectInfo, ManifestInspectInfo } from '@podman-d export abstract class BootcApi { abstract checkPrereqs(): Promise; - abstract checkVMLaunchPrereqs(folder: string, architecture: string): Promise; + abstract checkVMLaunchPrereqs(build: BootcBuildInfo): Promise; + abstract launchVM(build: BootcBuildInfo): Promise; abstract buildExists(folder: string, types: BuildType[]): Promise; abstract buildImage(build: BootcBuildInfo, overwrite?: boolean): Promise; abstract pullImage(image: string): Promise; @@ -41,7 +42,6 @@ export abstract class BootcApi { abstract getUidGid(): Promise; abstract loadLogsFromFolder(folder: string): Promise; abstract getConfigurationValue(config: string, section: string): Promise; - abstract launchVM(folder: string, architecture: string): Promise; abstract readFromClipboard(): Promise; abstract stopCurrentVM(): Promise; abstract telemetryLogUsage(eventName: string, data?: Record | undefined): Promise;