Documentation
¶
Overview ¶
This file owns BackendSelector — the routing layer that maps a domain.Domain to the correct Provider implementation based on TLSStrategy.
Unlike the route BackendSelector which maps Runtime to distinct provider implementations, the domain BackendSelector maps TLSStrategy to a single KnativeProvider — strategy dispatch (platform vs custom) is handled internally by the provider. The BackendSelector exists for consistency with the application layer pattern and future extensibility (e.g. a GatewayAPI cert provider).
Unknown strategies return ErrStrategyUnknown — the resolver validates strategy at resolution time, so this is a safety fallback for malformed CRs.
BackendSelector sits in the application layer — it is called by DomainService after resolution and before provider dispatch.
This file owns Mapper — the translation layer between the resolved Domain contract and the domain.Domain aggregate consumed by the provider layer.
The Mapper enforces the resolution contract: it panics on fields the resolver guarantees to be present (Host, TLSStrategy, RouteRef.Name) so that resolver bugs surface loudly rather than silently provisioning the wrong cert chain or creating a ClusterDomainClaim for an empty host.
All other fields are mapped verbatim. MTLS is mapped from the resolved ResolvedDomainMTLS struct to the flat domain.MTLS value. RenewBefore is passed through as a raw duration string — the provider parses it.
This file owns DomainService — the application service that orchestrates the domain reconciliation pipeline.
DomainService is the single entry point called by the domain controller after resolution. It sequences four steps in order:
- Map the resolved Domain contract to a domain.Domain (Mapper).
- Select the correct provider (BackendSelector).
- Dispatch via the provider (Provider.Ensure).
- Write conditions back to the Domain CR status (StatusWriter).
DomainStatus is an opaque envelope — only Conditions is typed on the CR. Scalar fields (phase, domainReady, tlsReady, certRef) are published to the cache by the controller after Reconcile returns, via DomainCache.PublishStatus.
ErrCertProvisioning is non-terminal — returned unwrapped to the controller as a requeue signal after conditions are written.
Condition ownership:
DomainClaimReady — owned by this service CertificateReady — owned by this service DomainMappingReady — owned by the Route controller; never set here Ready — aggregate; owned by this service
This file owns StatusWriter — the dumb persister for Domain CR status.
Mirrors the Build and Route StatusWriter pattern exactly. Write takes the Domain CR and variadic conditions — it merges conditions and persists. Scalar status fields (phase, domainReady, tlsReady, certificateRef) are set directly on the CR by the caller (DomainService) before Write is invoked.
DomainMappingRef is never written here — it is owned by the Route controller.
Uses RetryOnConflict + re-fetch on each attempt — concurrent writers may bump resourceVersion between the caller's initial fetch and this write.
See also:
- pkg/apis/domain/application/service.go — sets scalar fields and calls Write
- pkg/apis/build/application/status.go — canonical pattern this mirrors
- pkg/apis/route/application/status.go — same pattern for Route
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackendSelector ¶
BackendSelector maps a domain.Domain to the correct Provider based on TLSStrategy. KnativeProvider handles both platform and custom strategies internally via its own strategy switch — the BackendSelector is the first line of defence.
func NewBackendSelector ¶
func NewBackendSelector(knative api.Provider) *BackendSelector
NewBackendSelector constructs a BackendSelector with the registered domain provider.
type DomainService ¶
type DomainService struct {
// contains filtered or unexported fields
}
DomainService orchestrates the domain reconciliation pipeline. It is stateless beyond its collaborators and safe for concurrent use.
func NewDomainService ¶
func NewDomainService(mapper *Mapper, status *StatusWriter, backend *BackendSelector) *DomainService
NewDomainService constructs a DomainService with the required collaborators.
func (*DomainService) Reconcile ¶
func (s *DomainService) Reconcile(ctx context.Context, resolved *domainResolution.ResolvedDomain) error
Reconcile executes the full domain pipeline for a resolved Domain CR. It maps, selects, dispatches, and writes conditions in sequence. Scalar status fields are published to the cache by the controller — not written here, because DomainStatus.Contract is opaque.
func (*DomainService) Teardown ¶
func (s *DomainService) Teardown(ctx context.Context, resolved *domainResolution.ResolvedDomain) error
Teardown releases whatever Reconcile provisioned for this Domain 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 cert/mapping chain. No status write: the CR is being deleted, so there is nothing left to persist status onto once this returns.
type Mapper ¶
type Mapper struct{}
Mapper translates a ResolvedDomain into a domain.Domain aggregate.
func (Mapper) MapResolvedToDomain ¶
func (Mapper) MapResolvedToDomain(rd *domainResolution.ResolvedDomain) domain.Domain
MapResolvedToDomain converts a fully resolved Domain into a domain.Domain for consumption by the provider layer.
Panics on resolver invariant violations (empty Host, nil TLSStrategy, empty RouteRef.Name) — these indicate a resolver bug, not a user error, and must not be silently swallowed. All other fields are mapped verbatim.
type StatusWriter ¶
StatusWriter persists Domain conditions to the CR status. It does NOT derive conditions, manage phase transitions, or set scalar fields. Callers set scalar fields on the CR directly; this writer merges conditions and persists via Status().Update().
func NewStatusWriter ¶
func NewStatusWriter(c client.Client, log logr.Logger) *StatusWriter
NewStatusWriter constructs a StatusWriter with the given client and logger.
func (*StatusWriter) Write ¶
func (w *StatusWriter) Write(ctx context.Context, cr *networksv1alpha1.Domain, conditions ...metav1.Condition) error
Write merges the provided conditions into the Domain CR status and persists. Uses RetryOnConflict + re-fetch on each attempt — concurrent writers may bump resourceVersion between the caller's fetch and this write. Re-fetching on every retry guarantees we always write to the latest version. Scalar fields must be set on the CR by the caller before Write is invoked — they are re-applied from the caller's version on each retry attempt since DomainStatus.Contract is opaque and conditions are the only typed field.