rdev/internal/port/preview.go
jordan 9226454b85
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
feat: label-based undeploy, GC reconciliation, checkout/sessions, pool status
- Add UndeployAll() using label selectors to clean up monorepo components
  on project deletion (replaces name-based Undeploy in DeleteProject and
  the direct undeploy handler)
- Add ResourceGC background worker that periodically finds K8s resources
  whose project label has no matching DB record, deletes after 1h safety
  window
- Widen deployer client type from *kubernetes.Clientset to
  kubernetes.Interface for testability
- UndeployAll accumulates errors via errors.Join instead of failing fast
- Add checkout/checkin sidecar dev flow: temporary git tokens, branch
  checkout, review on checkin with cleanup workers
- Add interactive sessions: pod binding, command execution, SSE streaming,
  ephemeral preview URLs with session cleanup workers
- Add GET /workers/pool endpoint for aggregate capacity and queue depth
- Add sessions:read and sessions:execute auth scopes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 19:11:28 -07:00

33 lines
1.0 KiB
Go

// Package port defines interfaces (ports) for external dependencies.
package port
import "context"
// PreviewManager manages ephemeral preview URLs via K8s Service + Ingress.
type PreviewManager interface {
// CreatePreview creates a K8s Service + Ingress for the session preview.
// The service routes traffic to the target pod on the specified port.
CreatePreview(ctx context.Context, opts PreviewOptions) error
// DeletePreview removes the K8s Service + Ingress for a session preview.
DeletePreview(ctx context.Context, sessionID string) error
}
// PreviewOptions configures an ephemeral preview.
type PreviewOptions struct {
// SessionID is used as the resource name prefix (e.g., "session-{id}").
SessionID string
// Namespace is the K8s namespace (typically "rdev").
Namespace string
// PodName is the target pod to route traffic to.
PodName string
// Host is the preview hostname (e.g., "abc123.preview.threesix.ai").
Host string
// Port is the target port on the pod (default: 8080).
Port int
}