extension

package
v1.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TriggerTimeAnnotation   = "extensions.kuadrant.io/trigger-time"
	TriggerReasonAnnotation = "extensions.kuadrant.io/trigger-reason"
)
View Source
const KuadrantDataNamespace string = "kuadrant"

Variables

View Source
var BlockingDAG = newNilGuardedPointer[StateAwareDAG]()
View Source
var ErrNoExtensionsFound = errors.New("no extensions found")
View Source
var GlobalMutatorRegistry = &MutatorRegistry{}

Functions

func AnnotationsChanged

func AnnotationsChanged(oldAnnotations, newAnnotations map[string]string) bool

func ApplyAuthConfigMutators

func ApplyAuthConfigMutators(authConfig *authorinov1beta3.AuthConfig, path []machinery.Targetable) error

ApplyAuthConfigMutators applies all registered auth config mutators to an auth config

func ApplyWasmConfigMutators

func ApplyWasmConfigMutators(wasmConfig *wasm.Config, gateway *machinery.Gateway, topology *machinery.Topology) error

ApplyWasmConfigMutators applies all registered wasm config mutators for a specific gateway

func HashUpstreamServiceConfig added in v1.5.0

func HashUpstreamServiceConfig(svc wasm.Service) string

HashUpstreamServiceConfig produces a deterministic short hash from a wasm.Service config. Identical configurations produce the same hash, providing natural deduplication.

func Reconcile

func Reconcile(_ context.Context, _ []controller.ResourceEvent, topology *machinery.Topology, _ error, state *sync.Map) error

Types

type ChangeNotifier

type ChangeNotifier func(reason string) error

type DataProviderEntry

type DataProviderEntry struct {
	Policy     ResourceID
	Binding    string
	Expression string
	CAst       *cel.Ast
}

type DataProviderKey

type DataProviderKey struct {
	Policy           ResourceID
	TargetRefLocator string
	Domain           extpb.Domain
	Binding          string
}

type Extension

type Extension interface {
	Start() error
	Stop() error
	Name() string
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(location string, logger logr.Logger, sync io.Writer, client dynamic.Interface) (Manager, error)

func (*Manager) HasSynced

func (m *Manager) HasSynced() bool

func (*Manager) Run

func (m *Manager) Run(stopCh <-chan struct{})

func (*Manager) SetChangeNotifier

func (m *Manager) SetChangeNotifier(notifier ChangeNotifier)

func (*Manager) Start

func (m *Manager) Start() error

func (*Manager) Stop

func (m *Manager) Stop() error

func (*Manager) TriggerReconciliation

func (m *Manager) TriggerReconciliation(reason string) error

type MutatorRegistry

type MutatorRegistry struct {
	// contains filtered or unexported fields
}

func (*MutatorRegistry) ApplyAuthConfigMutators

func (r *MutatorRegistry) ApplyAuthConfigMutators(authConfig *authorinov1beta3.AuthConfig, path []machinery.Targetable) error

func (*MutatorRegistry) ApplyWasmConfigMutators

func (r *MutatorRegistry) ApplyWasmConfigMutators(wasmConfig *wasm.Config, gateway *machinery.Gateway, topology *machinery.Topology) error

func (*MutatorRegistry) RegisterAuthConfigMutator

func (r *MutatorRegistry) RegisterAuthConfigMutator(mutator AuthConfigMutator)

func (*MutatorRegistry) RegisterWasmConfigMutator

func (r *MutatorRegistry) RegisterWasmConfigMutator(mutator WasmConfigMutator)

type OOPExtension

type OOPExtension struct {
	// contains filtered or unexported fields
}

func NewOOPExtension

func NewOOPExtension(name string, location string, service extpb.ExtensionServiceServer, logger logr.Logger, sync io.Writer) (OOPExtension, error)

func (*OOPExtension) IsAlive

func (p *OOPExtension) IsAlive() bool

func (*OOPExtension) Name

func (p *OOPExtension) Name() string

func (*OOPExtension) Start

func (p *OOPExtension) Start() error

func (*OOPExtension) Stop

func (p *OOPExtension) Stop() error

func (*OOPExtension) WaitForCompletion added in v1.4.0

func (p *OOPExtension) WaitForCompletion()

type PipelineActionEntry added in v1.5.0

type PipelineActionEntry struct {
	Index        int
	ActionType   extpb.ActionType
	Predicate    string
	Phase        string // "request" or "response"
	Method       string // registered action method name (grpc_method)
	Var          string // variable name for gRPC response (grpc_method)
	WithStatus   int    // HTTP status code (deny); 0 means unset
	WithHeaders  string // CEL expression — array of [name, value] pairs (deny)
	WithBody     string // response body string (deny)
	HeadersToAdd string // CEL expression for headers (add_headers)
	LogMessage   string // error message to log (fail)
}

PipelineActionEntry represents a single stored pipeline action.

type PipelinePhase added in v1.5.0

type PipelinePhase string

PipelinePhase identifies whether actions run in the request or response phase.

const (
	PipelinePhaseRequest  PipelinePhase = "request"
	PipelinePhaseResponse PipelinePhase = "response"
)

type ProtoCache added in v1.5.0

type ProtoCache struct {
	// contains filtered or unexported fields
}

func NewProtoCache added in v1.5.0

func NewProtoCache() *ProtoCache

func (*ProtoCache) Delete added in v1.5.0

func (pc *ProtoCache) Delete(key ProtoCacheKey) bool

func (*ProtoCache) Get added in v1.5.0

func (*ProtoCache) Set added in v1.5.0

type ProtoCacheKey added in v1.5.0

type ProtoCacheKey struct {
	ClusterName string
	Service     string
}

type ReflectionClient added in v1.5.0

type ReflectionClient struct {
	// contains filtered or unexported fields
}

func NewReflectionClient added in v1.5.0

func NewReflectionClient() *ReflectionClient

func (*ReflectionClient) FetchServiceDescriptors added in v1.5.0

func (rc *ReflectionClient) FetchServiceDescriptors(ctx context.Context, url, serviceName, methodName string) (*descriptorpb.FileDescriptorSet, error)

func (*ReflectionClient) WithTimeout added in v1.5.0

func (rc *ReflectionClient) WithTimeout(timeout time.Duration) *ReflectionClient

type ReflectionFetcher added in v1.5.0

type ReflectionFetcher func(ctx context.Context, url, serviceName, methodName string) (*descriptorpb.FileDescriptorSet, error)

ReflectionFetcher fetches service descriptors via gRPC reflection.

type RegisteredDataMutator

type RegisteredDataMutator[TResource any] struct {
	// contains filtered or unexported fields
}

func NewRegisteredDataMutator

func NewRegisteredDataMutator[TResource any](store *RegisteredDataStore) *RegisteredDataMutator[TResource]

func (*RegisteredDataMutator[TResource]) Mutate

func (m *RegisteredDataMutator[TResource]) Mutate(resource TResource, targetRefs []machinery.PolicyTargetReference) error

Mutate handles registered data mutations for different resource types

type RegisteredDataStore

type RegisteredDataStore struct {
	// contains filtered or unexported fields
}

func NewRegisteredDataStore

func NewRegisteredDataStore() *RegisteredDataStore

func (*RegisteredDataStore) AppendPipelineActions added in v1.5.0

func (r *RegisteredDataStore) AppendPipelineActions(policy ResourceID, phase PipelinePhase, actions []PipelineActionEntry) int

AppendPipelineActions atomically appends actions to the given policy and phase, assigning sequential indices starting from the current counter value. Returns the index of the first appended action.

func (*RegisteredDataStore) ClearPipelineActions added in v1.5.0

func (r *RegisteredDataStore) ClearPipelineActions(policy ResourceID) int

ClearPipelineActions removes all pipeline actions for a policy across both phases and resets the index counters. Returns the number of actions cleared.

func (*RegisteredDataStore) ClearPipelinePhase added in v1.5.0

func (r *RegisteredDataStore) ClearPipelinePhase(policy ResourceID, phase PipelinePhase)

ClearPipelinePhase removes all pipeline actions for a policy in a single phase and resets the index counter.

func (*RegisteredDataStore) ClearPolicyData

func (r *RegisteredDataStore) ClearPolicyData(policy ResourceID) (clearedMutators int, clearedSubscriptions int, clearedUpstreams int, clearedPipelineActions int)

func (*RegisteredDataStore) Delete

func (r *RegisteredDataStore) Delete(policy ResourceID, targetRefLocator string, domain extpb.Domain, binding string) bool

func (*RegisteredDataStore) DeleteSubscription

func (r *RegisteredDataStore) DeleteSubscription(policy ResourceID, expression string) bool

func (*RegisteredDataStore) DeleteUpstream added in v1.5.0

func (r *RegisteredDataStore) DeleteUpstream(key RegisteredUpstreamKey) bool

func (*RegisteredDataStore) Exists

func (r *RegisteredDataStore) Exists(policy ResourceID, targetRefLocator string, domain extpb.Domain, binding string) bool

func (*RegisteredDataStore) Get

func (r *RegisteredDataStore) Get(policy ResourceID, targetRefLocator string, domain extpb.Domain, binding string) (DataProviderEntry, bool)

func (*RegisteredDataStore) GetAllForTargetRef

func (r *RegisteredDataStore) GetAllForTargetRef(targetRefLocator string, domain extpb.Domain) []DataProviderEntry

func (*RegisteredDataStore) GetAllSubscriptions

func (r *RegisteredDataStore) GetAllSubscriptions() map[SubscriptionKey]Subscription

func (*RegisteredDataStore) GetAllUpstreams added in v1.5.0

func (*RegisteredDataStore) GetPipelineActions added in v1.5.0

func (r *RegisteredDataStore) GetPipelineActions(policy ResourceID, phase PipelinePhase) []PipelineActionEntry

GetPipelineActions returns the ordered pipeline actions for a policy and phase.

func (*RegisteredDataStore) GetPipelineTargetRefs added in v1.5.1

func (r *RegisteredDataStore) GetPipelineTargetRefs(policy ResourceID) []TargetRef

func (*RegisteredDataStore) GetPoliciesWithPipelineActions added in v1.5.0

func (r *RegisteredDataStore) GetPoliciesWithPipelineActions() []ResourceID

GetPoliciesWithPipelineActions returns the set of policy IDs that have any pipeline actions (request or response phase).

func (*RegisteredDataStore) GetPoliciesWithPipelineActionsForTargetRefs added in v1.5.1

func (r *RegisteredDataStore) GetPoliciesWithPipelineActionsForTargetRefs(targetRefs []machinery.PolicyTargetReference) []ResourceID

GetPoliciesWithPipelineActionsForTargetRefs returns the set of policy IDs that have pipeline actions AND whose stored target refs overlap with the given target references.

func (*RegisteredDataStore) GetPolicySubscriptions

func (r *RegisteredDataStore) GetPolicySubscriptions(policy ResourceID) []SubscriptionKey

func (*RegisteredDataStore) GetProtoDescriptor added in v1.5.0

func (r *RegisteredDataStore) GetProtoDescriptor(cacheKey ProtoCacheKey) (*descriptorpb.FileDescriptorSet, bool)

func (*RegisteredDataStore) GetRelevantUpstreamKeys added in v1.5.0

GetRelevantUpstreamKeys returns upstream key/entry pairs whose TargetRef matches any of the given target references.

func (*RegisteredDataStore) GetRelevantUpstreams added in v1.5.0

func (r *RegisteredDataStore) GetRelevantUpstreams(targetRefs []machinery.PolicyTargetReference) []RegisteredUpstreamEntry

func (*RegisteredDataStore) GetSubscription

func (r *RegisteredDataStore) GetSubscription(policy ResourceID, expression string) (Subscription, bool)

func (*RegisteredDataStore) GetSubscriptionsForPolicyKind

func (r *RegisteredDataStore) GetSubscriptionsForPolicyKind(policyKind string) map[SubscriptionKey]Subscription

func (*RegisteredDataStore) GetUpstream added in v1.5.0

func (*RegisteredDataStore) GetUpstreamByName added in v1.5.0

func (*RegisteredDataStore) GetUpstreamsByTargetRef added in v1.5.0

func (r *RegisteredDataStore) GetUpstreamsByTargetRef(targetRef TargetRef) []RegisteredUpstreamEntry

func (*RegisteredDataStore) GetUpstreamsForPolicy added in v1.5.0

func (r *RegisteredDataStore) GetUpstreamsForPolicy(policy ResourceID) []RegisteredUpstreamEntry

func (*RegisteredDataStore) HasUpstreamName added in v1.5.0

func (r *RegisteredDataStore) HasUpstreamName(policy ResourceID, name string) bool

HasUpstreamName returns true when a registered upstream with the given name exists for the specified policy.

func (*RegisteredDataStore) IsUpstreamNameTaken added in v1.5.0

func (r *RegisteredDataStore) IsUpstreamNameTaken(key RegisteredUpstreamKey) bool

IsUpstreamNameTaken returns true when another key for the same policy already uses the given name. This is a cheap read-lock check intended as a fast-path rejection before expensive operations; the authoritative check remains in SetUpstreamIfNameAvailable.

func (*RegisteredDataStore) ReplacePipelineActions added in v1.5.0

func (r *RegisteredDataStore) ReplacePipelineActions(policy ResourceID, entries []PipelineActionEntry) error

ReplacePipelineActions atomically clears all pipeline actions for a policy and replaces them with the provided entries, grouped by their Phase field. Returns an error if any entry has an invalid phase.

func (*RegisteredDataStore) Set

func (r *RegisteredDataStore) Set(policy ResourceID, targetRefLocator string, domain extpb.Domain, binding string, entry DataProviderEntry)

func (*RegisteredDataStore) SetPipelineTargetRefs added in v1.5.1

func (r *RegisteredDataStore) SetPipelineTargetRefs(policy ResourceID, refs []TargetRef)

func (*RegisteredDataStore) SetSubscription

func (r *RegisteredDataStore) SetSubscription(policy ResourceID, expression string, subscription Subscription)

func (*RegisteredDataStore) SetUpstream added in v1.5.0

func (*RegisteredDataStore) SetUpstreamIfNameAvailable added in v1.5.0

SetUpstreamIfNameAvailable atomically checks that no other key for the same policy already uses the given name, then writes the upstream and proto cache entries. Returns true on success; false when a name conflict was detected.

func (*RegisteredDataStore) UpdateSubscriptionValue

func (r *RegisteredDataStore) UpdateSubscriptionValue(policy ResourceID, expression string, newVal ref.Val) bool

type RegisteredUpstreamEntry added in v1.5.0

type RegisteredUpstreamEntry struct {
	ClusterName     string
	Host            string
	Port            int
	TargetRef       TargetRef
	Service         string
	Method          string
	FailureMode     string
	Timeout         string
	MessageTemplate string
}

func CollectRouteUpstreams added in v1.5.0

func CollectRouteUpstreams(topology *machinery.Topology, gateway *machinery.Gateway) []RegisteredUpstreamEntry

CollectRouteUpstreams traverses the topology from a gateway through its listeners to find all attached routes (HTTPRoute and GRPCRoute), then returns registered upstreams for those routes. Routes are deduplicated by kind/namespace/name to avoid duplicate entries when a route appears under multiple listeners.

func GetRegisteredUpstreamsByTargetRef added in v1.5.0

func GetRegisteredUpstreamsByTargetRef(targetRef TargetRef) []RegisteredUpstreamEntry

GetRegisteredUpstreamsByTargetRef returns registered upstreams matching the given targetRef, aggregated across all extension data stores in the GlobalMutatorRegistry.

type RegisteredUpstreamKey added in v1.5.0

type RegisteredUpstreamKey struct {
	Policy  ResourceID
	Name    string
	URL     string
	Service string
	Method  string
}

type ResourceID

type ResourceID struct {
	Kind      string
	Namespace string
	Name      string
}

type ResourceMutator

type ResourceMutator[TResource any, TTargetRefs []machinery.PolicyTargetReference] interface {
	Mutate(resource TResource, targetRefs TTargetRefs) error
}

type StateAwareDAG

type StateAwareDAG struct {
	// contains filtered or unexported fields
}

func (*StateAwareDAG) FindGatewaysFor

func (d *StateAwareDAG) FindGatewaysFor(targetRefs []*extpb.TargetRef) ([]*extpb.Gateway, error)

func (*StateAwareDAG) FindPoliciesFor

func (d *StateAwareDAG) FindPoliciesFor(targetRefs []*extpb.TargetRef, policyType machinery.Policy) ([]*extpb.Policy, error)

type Subscription

type Subscription struct {
	CAst       *cel.Ast
	Input      map[string]any
	Val        ref.Val
	PolicyKind string
}

type SubscriptionKey

type SubscriptionKey struct {
	Policy     ResourceID
	Expression string
}

type TargetRef added in v1.5.0

type TargetRef struct {
	Group     string
	Kind      string
	Name      string
	Namespace string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL