Documentation
¶
Index ¶
- Constants
- func EffectiveTLS(t string) string
- func EndpointMatchKey(ep EndpointConfig) string
- func EndpointRef(ep EndpointConfig) string
- func InjectSharedNetwork(yamlContent []byte, networkName string) ([]byte, bool, error)
- func NormalizeProtocol(p string) string
- func ValidPath(p string) bool
- func ValidProtocol(p string) bool
- func ValidateComposeForDeploy(cfg *AppConfig) []string
- func ValidateComposeSecurity(cfg *AppConfig) []string
- func ValidateEndpoints(eps []EndpointConfig) []string
- type AppConfig
- type EndpointConfig
- type LabelConfig
- type PortMapping
- type RateLimitLabels
- type ServiceConfig
- type VolumeMount
Constants ¶
const ( // ProtocolHTTP proxies with Caddy's default upstream transport // (HTTP/1.1 to plaintext upstreams). This is the default. ProtocolHTTP = "http" // ProtocolH2C proxies with HTTP/2 cleartext (prior knowledge) to the upstream. ProtocolH2C = "h2c" // ProtocolGRPC is h2c to the upstream, matched only for native gRPC // requests (Content-Type application/grpc*, excluding gRPC-Web). ProtocolGRPC = "grpc" )
Endpoint protocol values for simpledeploy.endpoints.N.protocol.
Variables ¶
This section is empty.
Functions ¶
func EffectiveTLS ¶ added in v1.4.0
EffectiveTLS normalizes an endpoint tls label for comparison: empty and "letsencrypt" mean the default "auto".
func EndpointMatchKey ¶ added in v1.4.0
func EndpointMatchKey(ep EndpointConfig) string
EndpointMatchKey identifies the Caddy matcher an endpoint produces. Two endpoints with the same key would shadow each other. h2c and http differ only in upstream transport, so they share a key; grpc adds a Content-Type matcher, so it does not.
func EndpointRef ¶ added in v1.4.0
func EndpointRef(ep EndpointConfig) string
EndpointRef names an endpoint by its label, e.g. `service "web" label simpledeploy.endpoints.2`.
func InjectSharedNetwork ¶
InjectSharedNetwork rewrites a compose YAML to declare the given shared external network and attach every service that has endpoint labels to it. Returns new bytes, whether any change was made, and an error.
func NormalizeProtocol ¶ added in v1.4.0
NormalizeProtocol lowercases and trims a protocol label value.
func ValidPath ¶ added in v1.4.0
ValidPath reports whether p is an acceptable endpoint path matcher.
func ValidProtocol ¶ added in v1.4.0
ValidProtocol reports whether p (already normalized) is a supported endpoint protocol. Empty means the default (http).
func ValidateComposeForDeploy ¶ added in v1.4.0
ValidateComposeForDeploy is ValidateComposeSecurity plus endpoint label validation (ValidateEndpoints). Used by paths that accept new compose files (deploy API, bundle import) so bad routing labels are rejected up front. The reconciler disk scan only warns on endpoint problems, so an existing app is never dropped from routing after an upgrade.
func ValidateComposeSecurity ¶
ValidateComposeSecurity checks a parsed compose project for dangerous directives. Returns a list of violations. Empty list means safe.
func ValidateEndpoints ¶ added in v1.4.0
func ValidateEndpoints(eps []EndpointConfig) []string
ValidateEndpoints checks protocol/path label values, rejects endpoints whose matchers collide and endpoints sharing a domain with different tls modes. Returns human-readable violations; empty = valid.
Types ¶
type AppConfig ¶
type AppConfig struct {
Name string
ComposePath string
Endpoints []EndpointConfig
BackupStrategy string
BackupSchedule string
BackupTarget string
BackupRetention string
AlertCPU string
AlertMemory string
Registries string
AccessAllow string
RateLimit RateLimitLabels
Services []ServiceConfig
Project *types.Project
}
AppConfig holds the parsed compose file config plus extracted simpledeploy labels.
func ParseFile ¶
ParseFile parses the compose file at path and returns an AppConfig with appName as the name. simpledeploy.* labels are collected across all services; the first value found wins.
func (*AppConfig) PrimaryDomain ¶
PrimaryDomain returns the domain of the first endpoint, or empty string.
type EndpointConfig ¶
type EndpointConfig struct {
Domain string `json:"domain"`
Port string `json:"port"`
TLS string `json:"tls"`
Service string `json:"service"`
Protocol string `json:"protocol,omitempty"` // "", "http", "h2c" or "grpc"
Path string `json:"path,omitempty"` // optional Caddy path matcher, e.g. "/ws*"
// Index is N from the simpledeploy.endpoints.N.* labels (per service).
// Used for deterministic ordering and error messages; not serialized.
Index int `json:"-"`
}
EndpointConfig holds config for a single endpoint (domain/port/tls bound to a service).
type LabelConfig ¶
type LabelConfig struct {
BackupStrategy string
BackupSchedule string
BackupTarget string
BackupRetention string
AlertCPU string
AlertMemory string
Registries string
AccessAllow string
RateLimit RateLimitLabels
}
LabelConfig holds all extracted simpledeploy.* labels (non-endpoint labels).
func ExtractLabels ¶
func ExtractLabels(labels map[string]string) LabelConfig
ExtractLabels extracts non-endpoint simpledeploy.* labels from the provided map.
type PortMapping ¶
type PortMapping struct {
Host, Container, Protocol string
}
PortMapping represents a host:container port binding.
type RateLimitLabels ¶
type RateLimitLabels struct {
Requests, Window, By, Burst string
}
RateLimitLabels holds simpledeploy.ratelimit.* label values.
type ServiceConfig ¶
type ServiceConfig struct {
Name string
Image string
Ports []PortMapping
Environment map[string]string
Volumes []VolumeMount
Restart string
Labels map[string]string
DependsOn []string
DeployMode string
}
ServiceConfig is a simplified representation of a compose service.
func (*ServiceConfig) ScaleEligibility ¶
func (s *ServiceConfig) ScaleEligibility() (bool, string)
ScaleEligibility reports whether the service can safely run with N>1 replicas. Returns (true, "") when scalable, (false, reason) otherwise.
Detection rules (in order):
- simpledeploy.scalable=false label forces non-scalable.
- simpledeploy.scalable=true label forces scalable (override).
- deploy.mode: global (one container per node).
- Any host-published port (would clash on the same host).
- Named volumes (typically stateful).
- Known stateful image (database, broker, etc.).
type VolumeMount ¶
type VolumeMount struct {
Source, Target, Type string
}
VolumeMount represents a service volume mount.