package ports import ( "context" "time" "github.com/dtoro/oikos/internal/core/domain" ) // Target is a resolved execution endpoint (mirrors remote.ExecTarget; the // remote adapter maps between them). Wrap rewrites a plain command for // transport: identity for a host, pct/qm wrapping for guests. type Target struct { Host string User string Wrap func(cmd string) string } // ExecOpts carries execution options; Sink, when non-nil, receives output // chunks as they arrive (streaming path). type ExecOpts struct { Timeout time.Duration Sink func(stream string, chunk []byte) } // ExecResult is the outcome of one command execution. type ExecResult struct { Output string Duration time.Duration Err error } // CommandExecutor runs a command on a resolved target over SSH. Implemented // by the ssh adapter wrapping internal/actuator (dial pool + breaker). type CommandExecutor interface { Run(ctx context.Context, target Target, command string, opts ExecOpts) ExecResult } // TargetResolver resolves entity slugs/IDs to execution endpoints. // Implemented by the remote adapter on top of EntityRepository. type TargetResolver interface { ResolveExecTarget(ctx context.Context, targetSlug string) (Target, error) ResolveForCheck(ctx context.Context, targetID domain.UUID, targetType string) (Target, error) ResolveHost(ctx context.Context, hostSlug, fallbackUser string) (addr, user string, err error) // IsGuest reports whether an entity type is reached via pct/qm exec // through a Proxmox host rather than by direct SSH. IsGuest(entityType string) bool } // Provisioner creates guests via pct/qm on a Proxmox host (Phase 7 fills // the input payloads in; signatures firm up with ProvisioningService). type Provisioner interface { CreateLXC(ctx context.Context, host domain.UUID, input LXCInput) (domain.UUID, error) CreateVM(ctx context.Context, host domain.UUID, input VMInput) (domain.UUID, error) } // LXCInput is a placeholder until ProvisioningService (Phase 7) fixes the // create payloads; declared now so the port surface is complete. type LXCInput struct { Name string Template string Cores int MemoryMB int DiskGB int } // VMInput mirrors LXCInput for VM creation via qm. type VMInput struct { Name string TemplateID int Cores int MemoryMB int DiskGB int }