Documentation
¶
Index ¶
- func Run(debug bool)
- type ACMEAccount
- type ACMEClientManager
- type CertificatesDomain
- type CertificatesManager
- func (m *CertificatesManager) CleanupExpiredCertificates(logger *slog.Logger, domains []CertificatesDomain)
- func (cm *CertificatesManager) Refresh(logger *slog.Logger, domains []CertificatesDomain)
- func (cm *CertificatesManager) RefreshSync(logger *slog.Logger, domains []CertificatesDomain) error
- func (m *CertificatesManager) Stop()
- type CertificatesManagerConfig
- type ChallengeServer
- type ContainerEvent
- type Deployment
- type DeploymentInstance
- type DeploymentManager
- func (dm *DeploymentManager) Deployments() map[string]Deployment
- func (dm *DeploymentManager) DiscoverContainers(ctx context.Context, logger *slog.Logger) (discovered []DiscoveredContainer, failed []FailedContainer, err error)
- func (dm *DeploymentManager) FailedDeployments() map[string]Deployment
- func (dm *DeploymentManager) GetCertificateDomains() ([]CertificatesDomain, error)
- func (dm *DeploymentManager) GetHealthCheckTargets() []healthcheck.Target
- func (dm *DeploymentManager) HealthCheckContainers(ctx context.Context, logger *slog.Logger, discovered []DiscoveredContainer) (healthy []HealthyContainer, failed []FailedContainer)
- func (dm *DeploymentManager) UpdateDeployments(healthy []HealthyContainer) (hasChanged bool)
- type DiscoveredContainer
- type FailedContainer
- type HealthConfigUpdater
- type HealthyContainer
- type TriggerReason
- type TriggeredByApp
- type UpdateResult
- type Updater
- type UpdaterConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ACMEAccount ¶
type ACMEAccount struct {
URL string `json:"url"`
PrivateKey []byte `json:"private_key"` // PEM encoded
}
ACMEAccount represents a stored ACME account
type ACMEClientManager ¶
type ACMEClientManager struct {
// contains filtered or unexported fields
}
ACMEClientManager manages ACME client and account
func NewACMEClientManager ¶
func NewACMEClientManager(certDir string, staging bool) (*ACMEClientManager, error)
NewACMEClientManager creates a new ACME client manager
func (*ACMEClientManager) GetClient ¶
GetClient returns the ACME client, initializing it if necessary
func (*ACMEClientManager) ObtainCertificate ¶
func (m *ACMEClientManager) ObtainCertificate(ctx context.Context, domains []string, challengeServer *ChallengeServer) (certPEM, keyPEM []byte, err error)
ObtainCertificate obtains a certificate for the given domains using HTTP-01 challenge
type CertificatesDomain ¶
func (*CertificatesDomain) Validate ¶
func (cm *CertificatesDomain) Validate() error
type CertificatesManager ¶
type CertificatesManager struct {
// contains filtered or unexported fields
}
func NewCertificatesManager ¶
func NewCertificatesManager(config CertificatesManagerConfig, updateSignal chan<- string) (*CertificatesManager, error)
func (*CertificatesManager) CleanupExpiredCertificates ¶
func (m *CertificatesManager) CleanupExpiredCertificates(logger *slog.Logger, domains []CertificatesDomain)
func (*CertificatesManager) Refresh ¶
func (cm *CertificatesManager) Refresh(logger *slog.Logger, domains []CertificatesDomain)
Refresh is used for periodic refreshes of certificates.
func (*CertificatesManager) RefreshSync ¶
func (cm *CertificatesManager) RefreshSync(logger *slog.Logger, domains []CertificatesDomain) error
func (*CertificatesManager) Stop ¶
func (m *CertificatesManager) Stop()
type ChallengeServer ¶
type ChallengeServer struct {
// contains filtered or unexported fields
}
ChallengeServer handles HTTP-01 ACME challenges
func NewChallengeServer ¶
func NewChallengeServer(port string) *ChallengeServer
NewChallengeServer creates a new HTTP-01 challenge server
func (*ChallengeServer) ClearChallenge ¶
func (cs *ChallengeServer) ClearChallenge(token string)
ClearChallenge removes a challenge token
func (*ChallengeServer) ServeHTTP ¶
func (cs *ChallengeServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP handles HTTP-01 challenge requests
func (*ChallengeServer) SetChallenge ¶
func (cs *ChallengeServer) SetChallenge(token, keyAuth string)
SetChallenge registers a challenge token and its key authorization
func (*ChallengeServer) Start ¶
func (cs *ChallengeServer) Start() error
Start begins listening for ACME challenges
func (*ChallengeServer) Stop ¶
func (cs *ChallengeServer) Stop() error
Stop shuts down the challenge server
type ContainerEvent ¶
type ContainerEvent struct {
Event events.Message
Container container.InspectResponse
Labels *config.ContainerLabels
}
type Deployment ¶
type Deployment struct {
Labels *config.ContainerLabels
Instances []DeploymentInstance
}
type DeploymentInstance ¶
type DeploymentManager ¶
type DeploymentManager struct {
// contains filtered or unexported fields
}
func NewDeploymentManager ¶
func NewDeploymentManager(cli *client.Client, haloydConfig *config.HaloydConfig) *DeploymentManager
func (*DeploymentManager) Deployments ¶
func (dm *DeploymentManager) Deployments() map[string]Deployment
func (*DeploymentManager) DiscoverContainers ¶
func (dm *DeploymentManager) DiscoverContainers(ctx context.Context, logger *slog.Logger) (discovered []DiscoveredContainer, failed []FailedContainer, err error)
DiscoverContainers finds all containers with haloy labels and validates their basic configuration. It returns containers that are eligible for health checking, and containers that failed validation.
func (*DeploymentManager) FailedDeployments ¶
func (dm *DeploymentManager) FailedDeployments() map[string]Deployment
func (*DeploymentManager) GetCertificateDomains ¶
func (dm *DeploymentManager) GetCertificateDomains() ([]CertificatesDomain, error)
GetCertificateDomains collects all canonical domains and their aliases for certificate management.
func (*DeploymentManager) GetHealthCheckTargets ¶
func (dm *DeploymentManager) GetHealthCheckTargets() []healthcheck.Target
GetHealthCheckTargets returns all instances as health check targets. This method is used by the HealthMonitor to know what backends to check.
func (*DeploymentManager) HealthCheckContainers ¶
func (dm *DeploymentManager) HealthCheckContainers(ctx context.Context, logger *slog.Logger, discovered []DiscoveredContainer) (healthy []HealthyContainer, failed []FailedContainer)
HealthCheckContainers performs health checks on all discovered containers. Returns healthy containers (with IPs) and failed containers with detailed error information.
func (*DeploymentManager) UpdateDeployments ¶
func (dm *DeploymentManager) UpdateDeployments(healthy []HealthyContainer) (hasChanged bool)
UpdateDeployments builds the deployment map from healthy containers and compares with previous state. Returns whether the deployment state has changed.
type DiscoveredContainer ¶
type DiscoveredContainer struct {
ContainerID string
Labels *config.ContainerLabels
ContainerInfo container.InspectResponse
Port string
}
DiscoveredContainer represents a container found with haloy labels but not yet validated as healthy/routable.
type FailedContainer ¶
type FailedContainer struct {
ContainerID string
Labels *config.ContainerLabels // May be nil if label parsing failed
Reason string // Human-readable failure reason
Err error // Underlying error
}
FailedContainer represents a container that failed discovery or health check.
type HealthConfigUpdater ¶
type HealthConfigUpdater struct {
// contains filtered or unexported fields
}
HealthConfigUpdater bridges the health monitor to the proxy configuration. When health state changes, it rebuilds the proxy config with only healthy backends.
func NewHealthConfigUpdater ¶
func NewHealthConfigUpdater( deploymentManager *DeploymentManager, proxy *proxy.Proxy, apiDomain string, logger *slog.Logger, ) *HealthConfigUpdater
NewHealthConfigUpdater creates a new health config updater.
func (*HealthConfigUpdater) OnHealthChange ¶
func (u *HealthConfigUpdater) OnHealthChange(healthyTargets []healthcheck.Target)
OnHealthChange is called when the health state of any target changes. It rebuilds the proxy configuration, filtering unhealthy backends while keeping routes.
type HealthyContainer ¶
type HealthyContainer struct {
ContainerID string
Labels *config.ContainerLabels
IP string
Port string
}
HealthyContainer is a container that passed health checks and is ready to receive traffic.
type TriggerReason ¶
type TriggerReason int
const ( TriggerReasonInitial TriggerReason = iota // Initial update at startup TriggerReasonAppUpdated // An app container was stopped, killed or removed TriggerPeriodicRefresh // Periodic refresh (e.g., every 5 minutes) )
func (TriggerReason) String ¶
func (r TriggerReason) String() string
type TriggeredByApp ¶
type TriggeredByApp struct {
// contains filtered or unexported fields
}
func (*TriggeredByApp) Validate ¶
func (tba *TriggeredByApp) Validate() error
type UpdateResult ¶
type UpdateResult struct {
// FailedContainers contains containers that failed discovery or health check.
// This is used by the caller to determine if a triggered app deployment failed.
FailedContainers []FailedContainer
}
UpdateResult contains information about the update operation.
func (*UpdateResult) GetAppFailures ¶
func (r *UpdateResult) GetAppFailures(appName string) []FailedContainer
GetAppFailures returns failures for a specific app from the update result.
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
func NewUpdater ¶
func NewUpdater(config UpdaterConfig) *Updater
func (*Updater) Update ¶
func (u *Updater) Update(ctx context.Context, logger *slog.Logger, reason TriggerReason, app *TriggeredByApp) (UpdateResult, error)
type UpdaterConfig ¶
type UpdaterConfig struct {
Cli *client.Client
DeploymentManager *DeploymentManager
CertManager *CertificatesManager
Proxy *proxy.Proxy
APIDomain string
}