Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RenderResult ¶
type RenderResult struct {
// HAProxyConfig is the rendered HAProxy configuration.
HAProxyConfig string
// AuxiliaryFiles contains all rendered auxiliary files (maps, certs, general).
AuxiliaryFiles *dataplane.AuxiliaryFiles
// StatusPatches contains status patches registered by templates during rendering.
// Each patch targets a Kubernetes resource and contains outcome-keyed variants.
StatusPatches []templating.StatusPatch
// RenderedResources contains full Kubernetes resources the templates declared
// the controller should own and reconcile (e.g. an auxiliary Service or other
// object a template emits alongside the HAProxy config). The applier compares
// each against the last-applied checksum and skips unchanged entries to avoid
// hammering the API server.
RenderedResources []templating.RenderedResource
// DurationMs is the total render duration in milliseconds.
DurationMs int64
// AuxFileCount is the total number of auxiliary files.
AuxFileCount int
}
RenderResult contains the output of a render operation.
type RenderService ¶
type RenderService struct {
// contains filtered or unexported fields
}
RenderService is a pure service that transforms stores into HAProxy configuration.
This service uses absolute paths from the config's Dataplane settings to ensure rendered configs reference files at the correct locations where DataPlane API stores auxiliary files.
Resources in stores are already converted (floats to ints) at storage time, so the service simply passes through store data without additional processing.
func NewRenderService ¶
func NewRenderService(cfg *RenderServiceConfig) *RenderService
NewRenderService creates a new RenderService.
The service uses relative paths derived from the config's Dataplane settings. The directory names are extracted using path.Base() to get just the final directory component (e.g., /etc/haproxy/maps → maps).
These relative paths are resolved by HAProxy using the `default-path origin <baseDir>` directive in the global section, which makes HAProxy resolve paths from the specified base directory regardless of where the config file is located. This works for:
- Local validation: ValidationService replaces baseDir with temp directory
- DataPlane API deployment: baseDir points to where files are stored (e.g., /etc/haproxy)
func (*RenderService) ClearVMPool ¶
func (s *RenderService) ClearVMPool()
ClearVMPool releases pooled template engine VMs. Call after rendering completes to reduce memory from parallel rendering spikes.
func (*RenderService) Render ¶
func (s *RenderService) Render(ctx context.Context, provider stores.StoreProvider) (*RenderResult, error)
Render transforms the stores into HAProxy configuration.
The render mode (production vs validation) is determined automatically:
- If provider is *OverlayStoreProvider with HTTP overlay: validation mode
- Otherwise: production mode
Parameters:
- ctx: Context for cancellation
- provider: StoreProvider for accessing resource stores
Returns:
- RenderResult containing the rendered configuration and auxiliary files
- Error if rendering fails
type RenderServiceConfig ¶
type RenderServiceConfig struct {
// Engine is the template engine to use for rendering.
Engine templating.Engine
// Config is the controller configuration.
Config *config.Config
// Logger is the structured logger for logging.
Logger *slog.Logger
// Capabilities defines HAProxy version capabilities.
Capabilities dataplane.Capabilities
// HAProxyPodStore is the store containing HAProxy pods (optional).
HAProxyPodStore stores.Store
// HTTPStoreComponent is the HTTP store for dynamic content (optional).
HTTPStoreComponent *httpstore.Component
// CurrentConfigStore is the store for current deployed config (optional).
CurrentConfigStore *currentconfigstore.Store
// TypedResourceTypes carries the generated Go types produced
// by pkg/controller/typebootstrap at iteration start. The
// renderer emits one *[]*<generated-struct> top-level context
// entry per type at render time, matching the typed-global
// declarations the engine constructor received.
//
// Optional. nil or empty means typed-resource access isn't
// available and templates fall back to the untyped
// resources["<name>"] path.
TypedResourceTypes map[string]reflect.Type
}
RenderServiceConfig contains configuration for creating a RenderService.