Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Charlie Drage <charlie@charliedrage.com>
  • Loading branch information
cdrage committed Oct 16, 2024
1 parent c0a43de commit b314111
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions packages/backend/src/api-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export class BootcApiImpl implements BootcApi {
return checkPrereqs(await getContainerEngine());
}

async checkVMLaunchPrereqs(folder: string, architecture: string): Promise<string | undefined> {
return new VMManager(folder, architecture).checkVMLaunchPrereqs();
async checkVMLaunchPrereqs(build: BootcBuildInfo): Promise<string | undefined> {
return new VMManager(build.folder, build.arch).checkVMLaunchPrereqs();
}

async buildExists(folder: string, types: BuildType[]): Promise<boolean> {
Expand All @@ -59,9 +59,9 @@ export class BootcApiImpl implements BootcApi {
return buildDiskImage(build, this.history, overwrite);
}

async launchVM(folder: string, architecture: string): Promise<void> {
async launchVM(build: BootcBuildInfo): Promise<void> {
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) {
Expand Down
1 change: 0 additions & 1 deletion packages/frontend/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function goToHomePage(): void {
<Route path="/vm" breadcrumb="Virtual Machine">
<!-- Load after information is available since we have to wait for onMount to load the folder, image, arch. -->
{#if diskImage?.folder && diskImage?.arch}
<DiskImageDetailsVirtualMachine folderLocation={diskImage?.folder} architecture={diskImage?.arch} />
<DiskImageDetailsVirtualMachine build={diskImage} />
{/if}
</Route>
</svelte:fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<void> {
async function launchVM(build: BootcBuildInfo): Promise<void> {
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();
Expand All @@ -193,7 +193,7 @@ async function launchVM(folderLocation: string, architecture: string): Promise<v
// Reset the terminal if we are booting an arm64 VM on macOS
// see function for more information why this is necessary.
if (architecture === 'arm64' && (await bootcClient.isMac())) {
if (build.arch === 'arm64' && (await bootcClient.isMac())) {
await resetTerminalTheme();
}
}
Expand Down Expand Up @@ -245,10 +245,10 @@ onMount(async () => {
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);
}
});
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/BootcAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import type { ImageInfo, ImageInspectInfo, ManifestInspectInfo } from '@podman-d

export abstract class BootcApi {
abstract checkPrereqs(): Promise<string | undefined>;
abstract checkVMLaunchPrereqs(folder: string, architecture: string): Promise<string | undefined>;
abstract checkVMLaunchPrereqs(build: BootcBuildInfo): Promise<string | undefined>;
abstract launchVM(build: BootcBuildInfo): Promise<void>;
abstract buildExists(folder: string, types: BuildType[]): Promise<boolean>;
abstract buildImage(build: BootcBuildInfo, overwrite?: boolean): Promise<void>;
abstract pullImage(image: string): Promise<void>;
Expand All @@ -41,7 +42,6 @@ export abstract class BootcApi {
abstract getUidGid(): Promise<string>;
abstract loadLogsFromFolder(folder: string): Promise<string>;
abstract getConfigurationValue(config: string, section: string): Promise<unknown>;
abstract launchVM(folder: string, architecture: string): Promise<void>;
abstract readFromClipboard(): Promise<string>;
abstract stopCurrentVM(): Promise<void>;
abstract telemetryLogUsage(eventName: string, data?: Record<string, unknown> | undefined): Promise<void>;
Expand Down

0 comments on commit b314111

Please sign in to comment.