Documentation
¶
Overview ¶
Package ctrlplane provides a composable control plane library for deploying and managing SaaS instances at scale. It offers a unified API for provisioning, deployment, health monitoring, and lifecycle management across multiple cloud providers and orchestrators.
CtrlPlane is designed as a library-first package that can be used standalone or mounted into a Forge application as an extension.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound indicates the requested resource does not exist. ErrNotFound = errors.New("ctrlplane: resource not found") // ErrAlreadyExists indicates a resource with the same identity already exists. ErrAlreadyExists = errors.New("ctrlplane: resource already exists") // ErrInvalidState indicates an invalid state transition was attempted. ErrInvalidState = errors.New("ctrlplane: invalid state transition") // ErrProviderNotFound indicates the named provider is not registered. ErrProviderNotFound = errors.New("ctrlplane: provider not registered") ErrUnauthorized = errors.New("ctrlplane: unauthorized") // ErrForbidden indicates the authenticated identity lacks permission. ErrForbidden = errors.New("ctrlplane: forbidden") // ErrQuotaExceeded indicates the tenant has exceeded their resource quota. ErrQuotaExceeded = errors.New("ctrlplane: quota exceeded") ErrProviderUnavail = errors.New("ctrlplane: provider unavailable") // ErrDeploymentFailed indicates a deployment operation failed. ErrDeploymentFailed = errors.New("ctrlplane: deployment failed") // ErrHealthCheckFailed indicates a health check did not pass. ErrHealthCheckFailed = errors.New("ctrlplane: health check failed") // ErrRollbackFailed indicates a rollback operation failed. ErrRollbackFailed = errors.New("ctrlplane: rollback failed") // ErrInvalidConfig indicates the provided configuration is invalid. ErrInvalidConfig = errors.New("ctrlplane: invalid configuration") )
Sentinel errors returned by ctrlplane operations. Use errors.Is to check for these values.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// DatabaseURL is the database connection string.
DatabaseURL string `env:"CP_DATABASE_URL" json:"database_url"`
// DefaultProvider is the provider name used when none is specified.
DefaultProvider string `env:"CP_DEFAULT_PROVIDER" json:"default_provider"`
// HealthInterval is the default health check interval for all instances.
HealthInterval time.Duration `default:"30s" env:"CP_HEALTH_INTERVAL" json:"health_interval"`
// TelemetryFlushInterval is how often telemetry data is flushed.
TelemetryFlushInterval time.Duration `default:"10s" env:"CP_TELEMETRY_FLUSH" json:"telemetry_flush_interval"`
// MaxInstancesPerTenant is the default quota for instances per tenant.
// A value of 0 means unlimited.
MaxInstancesPerTenant int `default:"0" env:"CP_MAX_INSTANCES" json:"max_instances_per_tenant"`
// AuditEnabled controls whether audit logging is active.
AuditEnabled bool `default:"true" env:"CP_AUDIT_ENABLED" json:"audit_enabled"`
}
Config holds global configuration for the CtrlPlane.
type Entity ¶
type Entity struct {
ID id.ID `db:"id" json:"id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}
Entity is the base type embedded by all ctrlplane domain objects. It provides a unique identifier and creation/update timestamps.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package admin provides system-level and tenant-level management for the ctrlplane.
|
Package admin provides system-level and tenant-level management for the ctrlplane. |
|
Package api provides Forge-style HTTP handlers and middleware for the ctrlplane REST API.
|
Package api provides Forge-style HTTP handlers and middleware for the ctrlplane REST API. |
|
Package app provides the CtrlPlane root orchestrator that wires all subsystems together.
|
Package app provides the CtrlPlane root orchestrator that wires all subsystems together. |
|
Package auth provides the authentication and authorization abstraction for the control plane.
|
Package auth provides the authentication and authorization abstraction for the control plane. |
|
cmd
|
|
|
controlplane
command
|
|
|
Package deploy defines the deployment and release domain entities, the deployment service interface, strategy abstraction, and persistence store for tracking deployments and immutable release snapshots.
|
Package deploy defines the deployment and release domain entities, the deployment service interface, strategy abstraction, and persistence store for tracking deployments and immutable release snapshots. |
|
strategies
Package strategies provides built-in deployment strategy implementations.
|
Package strategies provides built-in deployment strategy implementations. |
|
Package event provides the event bus abstraction for lifecycle hooks and asynchronous communication between ctrlplane subsystems.
|
Package event provides the event bus abstraction for lifecycle hooks and asynchronous communication between ctrlplane subsystems. |
|
examples
|
|
|
saas-platform
command
Package main demonstrates a complete SaaS management platform built with Ctrl Plane and Forge.
|
Package main demonstrates a complete SaaS management platform built with Ctrl Plane and Forge. |
|
Package extension provides a Forge extension adapter for the ctrlplane.
|
Package extension provides a Forge extension adapter for the ctrlplane. |
|
Package health defines the health checking subsystem including check configuration, result tracking, aggregate instance health, and the pluggable Checker interface for custom check types.
|
Package health defines the health checking subsystem including check configuration, result tracking, aggregate instance health, and the pluggable Checker interface for custom check types. |
|
Package id provides the primary identifier type for all ctrlplane entities.
|
Package id provides the primary identifier type for all ctrlplane entities. |
|
Package instance defines the Instance domain entity, lifecycle management service interface, persistence store interface, and state machine for instance state transitions.
|
Package instance defines the Instance domain entity, lifecycle management service interface, persistence store interface, and state machine for instance state transitions. |
|
Package network manages routing, custom domains, TLS certificates, and service discovery for ctrlplane instances.
|
Package network manages routing, custom domains, TLS certificates, and service discovery for ctrlplane instances. |
|
Package provider defines the unified interface for infrastructure operations.
|
Package provider defines the unified interface for infrastructure operations. |
|
docker
Package docker implements a Docker-based infrastructure provider for the ctrlplane.
|
Package docker implements a Docker-based infrastructure provider for the ctrlplane. |
|
Package secrets manages encrypted secrets for ctrlplane instances.
|
Package secrets manages encrypted secrets for ctrlplane instances. |
|
Package store defines the aggregate persistence interface that composes all domain-specific store interfaces.
|
Package store defines the aggregate persistence interface that composes all domain-specific store interfaces. |
|
badger
Package badger provides a Badger DB implementation of the store.Store interface.
|
Package badger provides a Badger DB implementation of the store.Store interface. |
|
bun
Package bun provides a Bun ORM implementation of the store.Store interface.
|
Package bun provides a Bun ORM implementation of the store.Store interface. |
|
memory
Package memory provides an in-memory implementation of the store.Store interface.
|
Package memory provides an in-memory implementation of the store.Store interface. |
|
mongo
Package mongo provides a MongoDB implementation of the store.Store interface.
|
Package mongo provides a MongoDB implementation of the store.Store interface. |
|
postgres
Package postgres implements the ctrlplane store interface using PostgreSQL.
|
Package postgres implements the ctrlplane store interface using PostgreSQL. |
|
sqlite
Package sqlite implements the ctrlplane store interface using SQLite.
|
Package sqlite implements the ctrlplane store interface using SQLite. |
|
Package telemetry defines the telemetry subsystem for metrics, logs, traces, and resource snapshots.
|
Package telemetry defines the telemetry subsystem for metrics, logs, traces, and resource snapshots. |
|
Package worker provides background task scheduling for the control plane.
|
Package worker provides background task scheduling for the control plane. |