## Changes
### port.Deployer interface
- Add PatchProjectSecrets(ctx, projectName, patch) to merge key-value pairs
into all K8s secrets labeled project={projectName}
- Add RestartAll(ctx, projectName) to trigger rolling restart of all deployments
for a project, picking up fresh secrets without waiting for CI
### deployer adapter
- Implement PatchProjectSecrets: lists secrets by label, merges patch into Data,
writes each secret back
- Implement RestartAll: lists deployments by label, sets restartedAt annotation
### domain/credential.go
- Add CredentialCategoryCache = "cache" constant
- Use constant in component_infra.go (was raw string "cache")
### handlers/cache.go (new)
- POST /projects/{projectID}/cache/reprovision
- Calls CreateProjectCache (which handles delete+recreate with new password)
- Updates credential store (REDIS_URL, REDIS_URL_STAGING, REDIS_PREFIX)
- Patches all K8s secrets for the project immediately
- Triggers RestartAll so pods pick up new credentials without waiting for deploy
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
87 lines
4.2 KiB
Go
87 lines
4.2 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 by exact name.
|
|
Undeploy(ctx context.Context, projectName string) error
|
|
|
|
// UndeployAll removes all deployment resources matching the project label.
|
|
// This handles monorepo components (e.g., {project}-{component}) that Undeploy misses.
|
|
UndeployAll(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
|
|
|
|
// AddIngressPath adds or updates a path rule in the project's unified Ingress.
|
|
// For monorepo projects, all components share a single Ingress with path-based routing.
|
|
// The path is the URL prefix (e.g., "/api/auth", "/").
|
|
AddIngressPath(ctx context.Context, projectName, host, path, serviceName string, servicePort int) error
|
|
|
|
// RemoveIngressPath removes a path rule from the project's unified Ingress.
|
|
// If no paths remain for a host, the host rule is removed.
|
|
// If no rules remain, the Ingress is deleted.
|
|
RemoveIngressPath(ctx context.Context, projectName, host, path string) error
|
|
|
|
// PatchProjectSecrets merges the given key-value pairs into all K8s secrets
|
|
// belonging to the project (labeled project={projectName}). Existing keys not
|
|
// present in patch are left untouched.
|
|
PatchProjectSecrets(ctx context.Context, projectName string, patch map[string]string) error
|
|
|
|
// RestartAll triggers a rolling restart of all deployments belonging to the project
|
|
// (labeled project={projectName}). Used after credential rotation to pick up new secrets.
|
|
RestartAll(ctx context.Context, projectName string) error
|
|
}
|