rdev/internal/port/deployer.go
jordan 8282d60c69 feat: implement composable monorepo template system with component architecture
Adds the composable monorepo template system that generates project skeletons
with pluggable components (service, worker, app-react, app-astro, cli).

Key changes:
- Monorepo skeleton templates with shared pkg/, scripts/, and git hooks
- Component templates (service, worker, app-react, app-astro, cli) with
  Dockerfiles, CI steps, and component.yaml manifests
- Component domain model with validation and dependency resolution
- Component handler endpoints for CRUD and composition
- Template provider extended with BuildComposableProject and component assembly
- Deployer extended with composable project deployment support
- Handler timeout constants (TimeoutFastLookup through TimeoutLongRunning)
- envutil package for centralized env var reads with defaults
- api.DecodeJSON helper for standardized request body decoding
- Standardized response helpers (WriteBadRequest, WriteNotFound, etc.)
- Replaced fullstack-app cookbook with composable-app cookbook
- Hardened handler timeouts, logging, and error responses across all handlers

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:11:42 -07:00

64 lines
2.9 KiB
Go

// Package port defines interfaces (ports) for external dependencies.
package port
import (
"context"
"github.com/orchard9/rdev/internal/domain"
)
// Deployer manages application deployments to Kubernetes.
type Deployer interface {
// Deploy creates or updates a deployment for a project.
// This includes creating/updating Deployment, Service, and Ingress resources.
// For monorepo projects with ComponentPath set, creates component-specific resources.
Deploy(ctx context.Context, spec domain.DeploySpec) error
// Undeploy removes all deployment resources for a project.
Undeploy(ctx context.Context, projectName string) error
// UndeployComponent removes deployment resources for a specific component.
// The componentPath is the path within the monorepo (e.g., "services/auth-api").
UndeployComponent(ctx context.Context, projectName, componentPath string) error
// GetStatus returns the current deployment status for a project.
// Returns nil if no deployment exists.
GetStatus(ctx context.Context, projectName string) (*domain.DeployStatus, error)
// GetComponentStatus returns deployment status for a specific component.
// Returns nil if no deployment exists for the component.
GetComponentStatus(ctx context.Context, projectName, componentPath string) (*domain.DeployStatus, error)
// ListComponentStatuses returns deployment status for all components in a project.
ListComponentStatuses(ctx context.Context, projectName string) (*domain.ProjectDeployStatus, error)
// Restart triggers a rolling restart of the deployment.
// This is useful for picking up new images with the same tag.
Restart(ctx context.Context, projectName string) error
// RestartComponent triggers a rolling restart of a specific component.
RestartComponent(ctx context.Context, projectName, componentPath string) error
// Scale adjusts the replica count for a deployment.
Scale(ctx context.Context, projectName string, replicas int) error
// ScaleComponent adjusts the replica count for a component.
ScaleComponent(ctx context.Context, projectName, componentPath string, replicas int) error
// GetLogs returns recent logs from the deployment pods.
// tailLines specifies how many recent lines to return.
GetLogs(ctx context.Context, projectName string, tailLines int) (string, error)
// GetComponentLogs returns recent logs from a specific component's pods.
GetComponentLogs(ctx context.Context, projectName, componentPath string, tailLines int) (string, error)
// AddIngressHost adds a new host to an existing project's ingress.
// This is used when adding domain aliases to a project.
// The host is added to both the TLS configuration and the routing rules.
AddIngressHost(ctx context.Context, projectName, host string) error
// RemoveIngressHost removes a host from an existing project's ingress.
// This is used when removing domain aliases from a project.
RemoveIngressHost(ctx context.Context, projectName, host string) error
}