Documentation
¶
Overview ¶
This file owns BackendSelector — the routing layer that maps a domain.Route to the correct Provider implementation based on the Runtime field.
Unlike the build selector — which falls back to Buildah for unrecognised strategy names — an unknown route runtime is a malformed CR, not a soft default. ErrRuntimeUnknown is returned so the controller surfaces it as a Failed condition rather than silently materialising the wrong backend.
Registered runtimes:
RuntimeKnativeService → KnativeProvider (Knative DomainMapping via Kourier) RuntimeKubernetesContainer → IngressProvider (networking.k8s.io/v1 Ingress via nginx) RuntimeGatewayAPI → not yet registered — returns ErrRuntimeUnknown
BackendSelector sits in the application layer — it is called by RouteService after resolution and before provider dispatch.
This file owns Mapper — the translation layer between the resolved Route contract and the domain Route aggregate consumed by the provider layer.
The Mapper enforces the resolution contract: it panics on fields the resolver guarantees to be present (Host, Runtime, ServiceUnitRef) so that resolver bugs surface loudly rather than silently producing an empty DomainMapping or Ingress.
ServiceRef is derived directly from spec.ServiceUnitRef.Name — the resolver validates this as a required field. The controller convention enforces:
ksvc name == ServiceUnit name
No label lookup, no API server read, no status lookup required.
This file owns RouteService — the application service that orchestrates the route reconciliation pipeline.
RouteService is the single entry point called by the route controller after resolution. It sequences four steps in order:
- Map the resolved Route contract to a domain Route (Mapper).
- Select the correct provider for the runtime (BackendSelector).
- Dispatch via the provider (Provider.Ensure).
- Write the outcome back to the Route CR status (StatusWriter).
RouteService does not own retry logic, predicate evaluation, or status persistence — those belong to the controller and writer layers respectively.
Condition derivation lives here: the service knows what Ready/Pending/Failed mean for all registered runtimes. The Ready message is runtime-agnostic — providers return a ResolvedAddress and the service constructs the condition. The StatusWriter is a dumb persister.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackendSelector ¶
BackendSelector routes a domain.Route to the correct Provider implementation based on the Runtime field. All registered providers must be non-nil at construction time.
func NewBackendSelector ¶
func NewBackendSelector(knative api.Provider, ingress api.Provider) *BackendSelector
NewBackendSelector constructs a BackendSelector with the registered route providers. Knative and KubernetesIngress are registered at v1. GatewayAPI is added here when it lands.
type Mapper ¶
type Mapper struct{}
Mapper translates a ResolvedRoute into a domain.Route.
func (Mapper) MapResolvedToDomain ¶
func (Mapper) MapResolvedToDomain(rr *routeResolution.ResolvedRoute) domain.Route
MapResolvedToDomain converts a fully resolved Route into a domain Route for consumption by the provider layer.
Panics on resolver invariant violations (empty Host, nil Runtime, nil ServiceUnitRef) — these indicate a resolver bug, not a user error, and must not be silently swallowed. All other fields are mapped verbatim.
ServiceRef is derived from spec.ServiceUnitRef.Name by convention:
ksvc name == ServiceUnit name
The provider layer guards an empty ServiceRef with ErrServiceRefEmpty at Ensure time as a final safety net.
type RouteService ¶
type RouteService struct {
// contains filtered or unexported fields
}
RouteService orchestrates the route reconciliation pipeline. It is stateless beyond its collaborators and safe for concurrent use.
func NewRouteService ¶
func NewRouteService(mapper *Mapper, status *StatusWriter, backend *BackendSelector) *RouteService
NewRouteService constructs a RouteService with the required collaborators.
func (*RouteService) Reconcile ¶
func (s *RouteService) Reconcile(ctx context.Context, resolved *routeResolution.ResolvedRoute) error
Reconcile executes the full route pipeline for a resolved Route CR. It maps, selects, dispatches, and writes status in sequence. An error from any stage is converted to conditions and forwarded to StatusWriter so the Route CR always reflects the latest outcome, even on failure.
func (*RouteService) Teardown ¶
func (s *RouteService) Teardown(ctx context.Context, resolved *routeResolution.ResolvedRoute) error
Teardown deletes whatever Reconcile applied for this Route CR. It maps and selects the backend exactly as Reconcile does, so it tears down the same provider that would have been (or was) used to materialize the route. No status write: the CR is being deleted, so there is nothing left to persist status onto once this returns.
type StatusWriter ¶
StatusWriter persists Route conditions to the CR status. It does NOT derive conditions, manage contract state, or preserve domain flags. Callers pass the Route CR with conditions already set; this writer merges and persists.
func NewStatusWriter ¶
func NewStatusWriter(c client.Client, log logr.Logger) *StatusWriter
NewStatusWriter constructs a StatusWriter.
func (*StatusWriter) Write ¶
func (w *StatusWriter) Write(ctx context.Context, route *networksv1alpha1.Route, conditions ...metav1.Condition) error
Write merges the provided conditions into the Route CR status and persists. Uses RetryOnConflict + re-fetch on each attempt — concurrent writers (e.g. domain observer) may bump resourceVersion between the reconciler's initial fetch and this write. Re-fetching guarantees we always write to the latest version.