mirror of
https://github.com/getcompanion-ai/computer-host.git
synced 2026-04-15 05:02:05 +00:00
feat: deepen machine and storage contracts
This commit is contained in:
parent
6f0f0643fe
commit
04575d111c
5 changed files with 77 additions and 27 deletions
|
|
@ -1,7 +1,23 @@
|
||||||
package host
|
package host
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type Machine struct {
|
||||||
|
ID MachineID `json:"id"`
|
||||||
|
Artifact ArtifactRef `json:"artifact"`
|
||||||
|
SystemVolumeID VolumeID `json:"system_volume_id,omitempty"`
|
||||||
|
UserVolumeIDs []VolumeID `json:"user_volume_ids,omitempty"`
|
||||||
|
Phase MachinePhase `json:"phase"`
|
||||||
|
RuntimeHost string `json:"runtime_host,omitempty"`
|
||||||
|
Error string `json:"error,omitempty"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
StartedAt *time.Time `json:"started_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type CreateMachineRequest struct {
|
type CreateMachineRequest struct {
|
||||||
MachineID MachineID `json:"machine_id"`
|
MachineID MachineID `json:"machine_id"`
|
||||||
|
Artifact ArtifactRef `json:"artifact"`
|
||||||
|
UserVolumeIDs []VolumeID `json:"user_volume_ids,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateMachineResponse struct {
|
type CreateMachineResponse struct {
|
||||||
|
|
|
||||||
15
contract/storage.go
Normal file
15
contract/storage.go
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
package host
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type ArtifactRef struct {
|
||||||
|
ID ArtifactID `json:"id"`
|
||||||
|
Version ArtifactVersion `json:"version"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Volume struct {
|
||||||
|
ID VolumeID `json:"id"`
|
||||||
|
Kind VolumeKind `json:"kind"`
|
||||||
|
AttachedMachineID *MachineID `json:"attached_machine_id,omitempty"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package host
|
package host
|
||||||
|
|
||||||
import "time"
|
type ArtifactID string
|
||||||
|
|
||||||
|
type ArtifactVersion string
|
||||||
|
|
||||||
type MachineID string
|
type MachineID string
|
||||||
|
|
||||||
|
|
@ -23,12 +25,3 @@ const (
|
||||||
VolumeKindSystem VolumeKind = "system"
|
VolumeKindSystem VolumeKind = "system"
|
||||||
VolumeKindUser VolumeKind = "user"
|
VolumeKindUser VolumeKind = "user"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Machine struct {
|
|
||||||
ID MachineID `json:"id"`
|
|
||||||
Phase MachinePhase `json:"phase"`
|
|
||||||
RuntimeHost string `json:"runtime_host,omitempty"`
|
|
||||||
Error string `json:"error,omitempty"`
|
|
||||||
CreatedAt time.Time `json:"created_at"`
|
|
||||||
StartedAt *time.Time `json:"started_at,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,27 @@ import (
|
||||||
contracthost "github.com/getcompanion-ai/computer-host/contract"
|
contracthost "github.com/getcompanion-ai/computer-host/contract"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type StoragePool string
|
||||||
|
|
||||||
|
const (
|
||||||
|
StoragePoolArtifacts StoragePool = "artifacts"
|
||||||
|
StoragePoolMachineDisks StoragePool = "machine-disks"
|
||||||
|
StoragePoolState StoragePool = "state"
|
||||||
|
StoragePoolUserVolumes StoragePool = "user-volumes"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ArtifactRecord struct {
|
||||||
|
Ref contracthost.ArtifactRef
|
||||||
|
KernelImagePath string
|
||||||
|
RootFSPath string
|
||||||
|
CreatedAt time.Time
|
||||||
|
}
|
||||||
|
|
||||||
type MachineRecord struct {
|
type MachineRecord struct {
|
||||||
ID contracthost.MachineID
|
ID contracthost.MachineID
|
||||||
|
Artifact contracthost.ArtifactRef
|
||||||
|
SystemVolumeID contracthost.VolumeID
|
||||||
|
UserVolumeIDs []contracthost.VolumeID
|
||||||
Phase contracthost.MachinePhase
|
Phase contracthost.MachinePhase
|
||||||
RuntimeHost string
|
RuntimeHost string
|
||||||
Error string
|
Error string
|
||||||
|
|
@ -15,12 +34,11 @@ type MachineRecord struct {
|
||||||
StartedAt *time.Time
|
StartedAt *time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type StoragePool string
|
|
||||||
|
|
||||||
type VolumeRecord struct {
|
type VolumeRecord struct {
|
||||||
ID contracthost.VolumeID
|
ID contracthost.VolumeID
|
||||||
MachineID contracthost.MachineID
|
|
||||||
Kind contracthost.VolumeKind
|
Kind contracthost.VolumeKind
|
||||||
|
AttachedMachineID *contracthost.MachineID
|
||||||
|
SourceArtifact *contracthost.ArtifactRef
|
||||||
Pool StoragePool
|
Pool StoragePool
|
||||||
Path string
|
Path string
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,17 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Store interface {
|
type Store interface {
|
||||||
|
PutArtifact(context.Context, model.ArtifactRecord) error
|
||||||
|
GetArtifact(context.Context, contracthost.ArtifactRef) (*model.ArtifactRecord, error)
|
||||||
|
ListArtifacts(context.Context) ([]model.ArtifactRecord, error)
|
||||||
CreateMachine(context.Context, model.MachineRecord) error
|
CreateMachine(context.Context, model.MachineRecord) error
|
||||||
GetMachine(context.Context, contracthost.MachineID) (*model.MachineRecord, error)
|
GetMachine(context.Context, contracthost.MachineID) (*model.MachineRecord, error)
|
||||||
ListMachines(context.Context) ([]model.MachineRecord, error)
|
ListMachines(context.Context) ([]model.MachineRecord, error)
|
||||||
UpdateMachine(context.Context, model.MachineRecord) error
|
UpdateMachine(context.Context, model.MachineRecord) error
|
||||||
DeleteMachine(context.Context, contracthost.MachineID) error
|
DeleteMachine(context.Context, contracthost.MachineID) error
|
||||||
|
CreateVolume(context.Context, model.VolumeRecord) error
|
||||||
|
GetVolume(context.Context, contracthost.VolumeID) (*model.VolumeRecord, error)
|
||||||
|
ListVolumes(context.Context) ([]model.VolumeRecord, error)
|
||||||
|
UpdateVolume(context.Context, model.VolumeRecord) error
|
||||||
|
DeleteVolume(context.Context, contracthost.VolumeID) error
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue