Documentation
¶
Index ¶
- Constants
- Variables
- func KuadrantMetricBinding(binding string) string
- type Action
- type ActionMethodConfig
- type ActionType
- type AddHeadersAction
- type DenyAction
- type Domain
- type ExtensionBase
- type FailAction
- type GRPCMethodAction
- type KuadrantCtx
- type MutateFn
- type Pipeline
- type Policy
- type ReconcileFn
Constants ¶
const ( // PolicyConditionEnforced mirrors the internal kuadrant enforced condition // type for convenience to extension authors. PolicyConditionEnforced = kuadrant.PolicyConditionEnforced // KuadrantMetricsPrefix is the prefix applied to metric bindings injected // via AddDataTo / KuadrantMetricBinding. KuadrantMetricsPrefix = "metrics.labels" )
Variables ¶
var ErrUpstreamUnreachable = errors.New("upstream unreachable")
ErrUpstreamUnreachable is returned by RegisterActionMethod when the operator cannot establish a gRPC connection to the provided URL.
Functions ¶
func KuadrantMetricBinding ¶
KuadrantMetricBinding creates a fully qualified binding name for metrics enrichment.
Types ¶
type Action ¶ added in v1.5.0
type Action interface {
CelExpressions() []string
PopulateProtobuf(entry *extpb.ActionEntry)
// contains filtered or unexported methods
}
Action is the interface implemented by all pipeline action types. Actions can be used in either the request or response phase.
type ActionMethodConfig ¶ added in v1.5.0
type ActionMethodConfig struct {
Name string // Per-policy unique identifier for this action method
URL string // e.g. "grpc://my-service:8081"
Service string // gRPC service name
Method string // gRPC method name
MessageTemplate string // Opaque template string for building the gRPC request message
}
ActionMethodConfig holds the configuration for an external gRPC service that an extension wants to register with the data plane.
type ActionType ¶ added in v1.5.0
type ActionType string
ActionType discriminates how the wasm-shim dispatches an action.
const ( ActionTypeGRPCMethod ActionType = "grpc_method" ActionTypeDeny ActionType = "deny" ActionTypeFail ActionType = "fail" ActionTypeAddHeaders ActionType = "add_headers" )
type AddHeadersAction ¶ added in v1.5.0
type AddHeadersAction struct {
Predicate string // CEL — if true, add the headers
HeadersToAdd string // CEL expression evaluating to a map of headers
}
AddHeadersAction adds headers to the request or response depending on the phase in which it is used, when the predicate evaluates to true.
Phase semantics:
- Request phase: headers added to the request before it reaches the backend
- Response phase: headers added to the response before it reaches the client
func (AddHeadersAction) CelExpressions ¶ added in v1.5.0
func (a AddHeadersAction) CelExpressions() []string
func (AddHeadersAction) PopulateProtobuf ¶ added in v1.5.0
func (a AddHeadersAction) PopulateProtobuf(entry *extpb.ActionEntry)
type DenyAction ¶ added in v1.5.0
type DenyAction struct {
Predicate string // CEL — if true, deny
WithStatus int // HTTP status code (e.g. 403); optional
WithHeaders string // CEL expression — array of [name, value] pairs; optional
WithBody string // CEL expression; optional
}
DenyAction denies the request or response when the predicate evaluates to true. All response fields are optional.
Phase semantics:
- Request phase: deny sends the response to the origin (request never reaches backend)
- Response phase: deny sends the response to the destination (backend response replaced before reaching client)
func (DenyAction) CelExpressions ¶ added in v1.5.0
func (a DenyAction) CelExpressions() []string
func (DenyAction) PopulateProtobuf ¶ added in v1.5.0
func (a DenyAction) PopulateProtobuf(entry *extpb.ActionEntry)
type Domain ¶
type Domain int
Domain enumerates the supported logical domains for mutator injected data.
type ExtensionBase ¶
ExtensionBase is a base struct for the extension controllers. ExtensionBase is an embeddable struct providing common fields (logger, client, scheme) and a helper Configure method for extension controllers.
type FailAction ¶ added in v1.5.0
type FailAction struct {
Predicate string // CEL — if true, fail with log message
LogMessage string // Error message to log
}
FailAction logs an error message and terminates the action chain when the predicate evaluates to true. Maps to the wasm-shim's "fail" type.
func (FailAction) CelExpressions ¶ added in v1.5.0
func (a FailAction) CelExpressions() []string
func (FailAction) PopulateProtobuf ¶ added in v1.5.0
func (a FailAction) PopulateProtobuf(entry *extpb.ActionEntry)
type GRPCMethodAction ¶ added in v1.5.0
type GRPCMethodAction struct {
Predicate string // CEL — if true, call the gRPC method
Method string // Name of a registered ActionMethod
Var string // Variable name to store gRPC response (optional)
}
GRPCMethodAction invokes a registered gRPC action method and optionally stores the response in a named variable for use by subsequent actions.
func (GRPCMethodAction) CelExpressions ¶ added in v1.5.0
func (a GRPCMethodAction) CelExpressions() []string
func (GRPCMethodAction) PopulateProtobuf ¶ added in v1.5.0
func (a GRPCMethodAction) PopulateProtobuf(entry *extpb.ActionEntry)
type KuadrantCtx ¶
type KuadrantCtx interface {
Resolve(context.Context, Policy, string, bool) (celref.Val, error)
ResolvePolicy(context.Context, Policy, string, bool) (Policy, error)
AddDataTo(context.Context, Policy, Domain, string, string) error
ReconcileObject(context.Context, client.Object, client.Object, MutateFn) (client.Object, error)
RegisterActionMethod(ctx context.Context, policy Policy, svc ActionMethodConfig) error
NewPipeline(policy Policy) Pipeline
}
KuadrantCtx is passed to ReconcileFn providing access to CEL resolution, mutator registration, object reconciliation helpers and action method registration.
type MutateFn ¶
MutateFn is a function that mutates the existing object into it's desired state. MutateFn mutates the existing object into the desired state. It returns true when a change was applied requiring an update.
type Pipeline ¶ added in v1.5.0
type Pipeline interface {
OnHTTPRequest(actions ...Action) error
OnHTTPResponse(actions ...Action) error
Commit(ctx context.Context) error
}
Pipeline provides a builder for composing ordered actions on HTTP request and response phases. Actions accumulate locally with immediate ordering validation. Commit sends all actions atomically to the operator.
type Policy ¶
type Policy interface {
GetName() string
GetNamespace() string
GetObjectKind() schema.ObjectKind
GetTargetRefs() []gatewayapiv1alpha2.LocalPolicyTargetReferenceWithSectionName
}
Policy is an interface for the policy object to be implemented by the extension policy. Policy is the common interface a policy object must implement for the extension controller. Implementations are usually thin adapters over generated protobuf or Kubernetes types.
type ReconcileFn ¶
type ReconcileFn func(ctx context.Context, request reconcile.Request, kuadrant KuadrantCtx) (reconcile.Result, error)
ReconcileFn defines the signature of an extension reconcile function.