feat: phase 1

This commit is contained in:
Harivansh Rathi 2026-04-12 22:47:51 +00:00
parent 4a9dc91ebf
commit 6489e270ce
9 changed files with 194 additions and 13 deletions

View file

@ -15,6 +15,7 @@ type Service interface {
GetMachine(context.Context, contracthost.MachineID) (*contracthost.GetMachineResponse, error)
ListMachines(context.Context) (*contracthost.ListMachinesResponse, error)
StartMachine(context.Context, contracthost.MachineID) (*contracthost.GetMachineResponse, error)
EnsureExecRelay(context.Context, contracthost.MachineID) (*contracthost.GetMachineResponse, error)
StopMachine(context.Context, contracthost.MachineID) error
DeleteMachine(context.Context, contracthost.MachineID) error
Health(context.Context) (*contracthost.HealthResponse, error)
@ -166,6 +167,20 @@ func (h *Handler) handleMachine(w http.ResponseWriter, r *http.Request) {
return
}
if len(parts) == 2 && parts[1] == "exec-relay" {
if r.Method != http.MethodPost {
writeMethodNotAllowed(w)
return
}
response, err := h.service.EnsureExecRelay(r.Context(), machineID)
if err != nil {
writeError(w, statusForError(err), err)
return
}
writeJSON(w, http.StatusOK, response)
return
}
if len(parts) == 2 && parts[1] == "snapshots" {
switch r.Method {
case http.MethodGet: