11import { Architecture , ExecResult } from "@/types" ;
22import { ExecOptions , ShellString , exec } from "shelljs" ;
3- import { RmCommandFlags , RunCommandFlags } from "@/types/container" ;
3+ import {
4+ LogsCommandFlags ,
5+ RmCommandFlags ,
6+ RunCommandFlags ,
7+ } from "@/types/container" ;
48
59import { ChildProcess } from "child_process" ;
610import { GlobalFlags } from "@/types/global" ;
@@ -14,25 +18,19 @@ export default abstract class BaseBackend {
1418 protected readonly arch : Architecture ;
1519 protected readonly platform : string = platform ;
1620
17- protected readonly vm = "limactl" ;
18- protected readonly runtime = "nerdctl" ;
21+ protected readonly vm : string = "limactl" ;
22+ protected readonly instance : string = "default" ;
23+ protected readonly runtime : string = "nerdctl" ;
1924
20- constructor ( arch : Architecture ) {
25+ constructor ( arch : Architecture , instance : string = "default" ) {
2126 this . arch = arch ;
27+ this . instance = instance ;
2228 }
2329
2430 get container ( ) {
2531 return `${ this . vm } shell ${ this . instance } ${ this . runtime } ` ;
2632 }
2733
28- #instance = "default" ;
29- get instance ( ) {
30- return this . #instance;
31- }
32- set instance ( instance : string ) {
33- this . #instance = instance ;
34- }
35-
3634 protected async exec (
3735 command : string ,
3836 options ?: ExecOptions
@@ -68,8 +66,10 @@ export default abstract class BaseBackend {
6866 return params ;
6967 }
7068
71- abstract init ( ) : Promise < void > ;
72- abstract start ( ) : Promise < void > ;
69+ abstract initVM ( ) : Promise < boolean > ;
70+ abstract startVM ( ) : Promise < ChildProcess > ;
71+ abstract stopVM ( ) : Promise < void > ;
72+ abstract deleteVM ( ) : Promise < void > ;
7373
7474 abstract login (
7575 flags ?: LoginCommandFlags ,
@@ -87,6 +87,11 @@ export default abstract class BaseBackend {
8787 flags ?: RmCommandFlags
8888 ) : Promise < ShellString > ;
8989
90+ abstract logs (
91+ container : string ,
92+ flags ?: LogsCommandFlags
93+ ) : Promise < ChildProcess > ;
94+
9095 abstract pullImage ( image : string ) : Promise < ChildProcess > ;
9196 abstract getImages ( ) : Promise < ImageResult [ ] > ;
9297}
0 commit comments