mirror of
https://github.com/getcompanion-ai/computer-host.git
synced 2026-04-15 09:01:12 +00:00
feat: remove go sdk and write thin firecracker wrapper (#1)
* feat: remove go sdk and write thin firecracker wrapper * chore: gitignore
This commit is contained in:
parent
3585531d30
commit
58f95324f4
6 changed files with 478 additions and 190 deletions
|
|
@ -6,15 +6,18 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
const defaultSocketName = "api.socket"
|
||||
const (
|
||||
defaultChrootRootDirName = "root"
|
||||
defaultFirecrackerSocketDir = "run"
|
||||
defaultFirecrackerSocketName = "firecracker.socket"
|
||||
defaultFirecrackerSocketPath = "/run/firecracker.socket"
|
||||
)
|
||||
|
||||
type machinePaths struct {
|
||||
BaseDir string
|
||||
JailerBaseDir string
|
||||
ChrootRootDir string
|
||||
SocketName string
|
||||
SocketPath string
|
||||
FirecrackerBin string
|
||||
BaseDir string
|
||||
ChrootRootDir string
|
||||
JailerBaseDir string
|
||||
SocketPath string
|
||||
}
|
||||
|
||||
func buildMachinePaths(rootDir string, id MachineID, firecrackerBinaryPath string) (machinePaths, error) {
|
||||
|
|
@ -25,6 +28,7 @@ func buildMachinePaths(rootDir string, id MachineID, firecrackerBinaryPath strin
|
|||
if strings.TrimSpace(string(id)) == "" {
|
||||
return machinePaths{}, fmt.Errorf("machine id is required")
|
||||
}
|
||||
|
||||
binName := filepath.Base(strings.TrimSpace(firecrackerBinaryPath))
|
||||
if binName == "." || binName == string(filepath.Separator) || binName == "" {
|
||||
return machinePaths{}, fmt.Errorf("firecracker binary path is required")
|
||||
|
|
@ -32,14 +36,12 @@ func buildMachinePaths(rootDir string, id MachineID, firecrackerBinaryPath strin
|
|||
|
||||
baseDir := filepath.Join(rootDir, "machines", string(id))
|
||||
jailerBaseDir := filepath.Join(baseDir, "jailer")
|
||||
chrootRootDir := filepath.Join(jailerBaseDir, binName, string(id), "root")
|
||||
chrootRootDir := filepath.Join(jailerBaseDir, binName, string(id), defaultChrootRootDirName)
|
||||
|
||||
return machinePaths{
|
||||
BaseDir: baseDir,
|
||||
JailerBaseDir: jailerBaseDir,
|
||||
ChrootRootDir: chrootRootDir,
|
||||
SocketName: defaultSocketName,
|
||||
SocketPath: filepath.Join(chrootRootDir, defaultSocketName),
|
||||
FirecrackerBin: binName,
|
||||
BaseDir: baseDir,
|
||||
ChrootRootDir: chrootRootDir,
|
||||
JailerBaseDir: jailerBaseDir,
|
||||
SocketPath: filepath.Join(chrootRootDir, defaultFirecrackerSocketDir, defaultFirecrackerSocketName),
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue