Documentation
¶
Index ¶
- func CheckCrossNamespaceRef(ctx context.Context, cl client.Client, obj client.Object, ...) error
- func IsEntityScopedFailure(err error) bool
- func RenderDBLessYAML(doc *aigw.Document, opts convert.Options) ([]byte, []convert.ConversionIssue, error)
- type EntityStatus
- type ModelAliasConflictError
- type ReferencedEntityExcludedError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckCrossNamespaceRef ¶
func CheckCrossNamespaceRef(ctx context.Context, cl client.Client, obj client.Object, gw types.NamespacedName) error
CheckCrossNamespaceRef reports whether obj may reference the on-prem gateway gw: an entity outside the gateway's namespace needs a KongReferenceGrant in the gateway's namespace that allows its kind, from its namespace, to reference the OnPremAIGateway. An entity in the gateway's own namespace needs none. The on-prem reconcilers use it too, so that the ResolvedRefs condition and the translation agree.
func IsEntityScopedFailure ¶
IsEntityScopedFailure reports whether err only excludes its entity from the document and is not a gateway-level translation failure. The entity reports err on its own status, and the gateway's aggregated ConfigurationTranslated condition treats it as a warning, so the rest of the configuration is still pushed and the gateway, and its data planes, become Ready. This applies to a model alias conflict, to a cross-namespace reference that no KongReferenceGrant allows, and to the entities that reference an entity excluded for one of these.
func RenderDBLessYAML ¶
func RenderDBLessYAML(doc *aigw.Document, opts convert.Options) ([]byte, []convert.ConversionIssue, error)
RenderDBLessYAML converts the translated AI Gateway document into the flattened db-less YAML payload understood by Kong data planes. Alongside the payload it returns the typed conversion issues reported by the converter: a Warning issue means the converter worked around a problem (the output is valid but may not fully match the intent), while an Error issue means the offending entity was left out of the output entirely - the caller is expected to attribute those back to the entities' CRs (see the aigateway package's attributeConversionIssues).
The payload is never empty: see ensureNonEmptyConfig.
Types ¶
type EntityStatus ¶
EntityStatus is the per-entity outcome of the document translation: Err is nil for entities that were translated and included in the document, and the conversion error for the ones that were not (they are excluded from the document so that a single broken entity does not block the rest).
func BuildDocument ¶
func BuildDocument( ctx context.Context, cl client.Client, gw types.NamespacedName, opts convert.Options, ) (*aigw.Document, []EntityStatus, error)
BuildDocument assembles the aigw.Document for the given OnPremAIGateway, translating every aiconfiguration entity kind pointing at it. Alongside the document it returns the per-entity translation status (see EntityStatus), so that the caller can report each entity's outcome on the entity's status.
The statuses cover the AIGatewayConsumerCredentials embedded in the translated consumers as well: they have no document entity of their own (aigw.Consumer nests them), so the consumer's own translation reports them, and one broken credential does not fail its consumer.
Entity kinds join here as they gain their own ToAIGW* conversion; until then the rendered Document (and the dbless payload built from it) has dangling references, which RenderDBLessYAML reports as converter issues instead of errors.
The OnOnPremAIGatewayRef index extractor only matches entities whose aiGatewayRef resolves to an OnPremAIGateway, so a KonnectAIGateway sharing namespace/name with this OnPremAIGateway never collides.
NOTE: This will either stay here or be moved to a separate package where translation (building the document) will happen asynchronously as it's done for ingress-controller.
type ModelAliasConflictError ¶
type ModelAliasConflictError struct {
// Alias is the contested selector alias.
Alias string
// Route is the name of the rendered route both models land on.
Route string
// Paths are the route paths that the excluded model configures.
Paths []string
// First is the name of the AIGatewayModel that keeps the alias (the earliest created).
First string
}
ModelAliasConflictError reports a model whose selector alias (or entity name, when no selector is set) is already claimed by another model on the same route.
It is a per-entity routing conflict, not a gateway-level translation failure: the later model is excluded from the document and reports the conflict on its own status, while the rest of the configuration translated and pushed fine. The reporting layer detects this type and treats it as a warning on the gateway's aggregated ConfigurationTranslated condition, which therefore stays True and lets the gateway — and its data planes — become Ready (see ai-deck-converter#248).
Two models sharing an alias across DIFFERENT routes are not a conflict: the converter renders one shared ai_models row for them and each model keeps its own route and plugin.
func (*ModelAliasConflictError) Error ¶
func (e *ModelAliasConflictError) Error() string
type ReferencedEntityExcludedError ¶
type ReferencedEntityExcludedError struct {
// Kind is the kind of the referenced entity.
Kind string
// Name is the entity name of the referenced entity.
Name string
// Cause is the translation error of the referenced entity. It is nil when no entity
// of that name was translated.
Cause error
}
ReferencedEntityExcludedError reports an entity that references an entity excluded from the document. Unwrap returns the error of the referenced entity, so that the classification of the root cause (see IsEntityScopedFailure) applies to the referencing entity too.
func (*ReferencedEntityExcludedError) Error ¶
func (e *ReferencedEntityExcludedError) Error() string
func (*ReferencedEntityExcludedError) Unwrap ¶
func (e *ReferencedEntityExcludedError) Unwrap() error
Unwrap returns the translation error of the referenced entity.