Files
tiny-forge/internal/proxy/provider.go
T
alexei.dolgolyov 7550fe9e32 feat: CPU/RAM limits per stage, NPM access list (global + per-project)
Resource limits:
- Add cpu_limit (cores) and memory_limit (MB) fields to Stage model
- Pass limits to Docker container via NanoCPUs and Memory in HostConfig
- Add CPU/Memory fields to stage creation form in project detail
- 0 = unlimited (default)

NPM access list:
- Add npm_access_list_id to Settings (global default) and Project (per-project override)
- Per-project overrides global when > 0
- NPM provider passes access_list_id when configuring proxy hosts
- Add GET /api/settings/npm-access-lists endpoint to list NPM access lists
- Add access list picker on NPM settings page (global)
- Add access list ID field on project edit form (per-project)
- DB migrations for all new columns
2026-04-05 12:44:26 +03:00

38 lines
1.5 KiB
Go

package proxy
import "context"
// RouteOptions holds optional configuration for a proxy route.
type RouteOptions struct {
SSLCertificateID int
AccessListID int // NPM access list ID for authentication, 0 = public
ForwardScheme string // "http" or "https", defaults to "http"
}
// Provider is the interface for proxy route management.
// Implementations handle the specifics of each proxy system (NPM, Traefik, etc.).
// The "None" provider implements all methods as no-ops.
type Provider interface {
// Name returns the provider identifier (e.g., "npm", "traefik", "none").
Name() string
// ConfigureRoute creates or updates a proxy route for the given domain.
// Returns a route ID string that can be used for updates and deletes.
// For NPM, the route ID is the proxy host ID (stringified).
// For Traefik, the route ID is the router name.
// For None, returns empty string.
ConfigureRoute(ctx context.Context, domain, targetHost string, targetPort int, opts RouteOptions) (routeID string, err error)
// DeleteRoute removes a proxy route by its route ID.
// Does nothing if routeID is empty.
DeleteRoute(ctx context.Context, routeID string) error
// ContainerLabels returns Docker labels to set on containers at creation time.
// Traefik uses labels for auto-discovery; NPM and None return nil.
ContainerLabels(domain string, port int) map[string]string
// Ping checks connectivity to the proxy backend.
// Returns nil if healthy or if the provider doesn't need external connectivity (None).
Ping(ctx context.Context) error
}