|
| 1 | +// Copyright Envoy Gateway Authors |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | +// The full text of the Apache license is available in the LICENSE file at |
| 4 | +// the root of the repo. |
| 5 | + |
| 6 | +package v1alpha1 |
| 7 | + |
| 8 | +import ( |
| 9 | + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" |
| 10 | +) |
| 11 | + |
| 12 | +// DynamicModuleEntry defines a dynamic module that is registered and allowed |
| 13 | +// for use by EnvoyExtensionPolicy resources. |
| 14 | +type DynamicModuleEntry struct { |
| 15 | + // Name is the logical name for this module. EnvoyExtensionPolicy resources |
| 16 | + // reference modules by this name. |
| 17 | + // |
| 18 | + // +kubebuilder:validation:MinLength=1 |
| 19 | + // +kubebuilder:validation:MaxLength=253 |
| 20 | + // +kubebuilder:validation:Pattern=`^[a-z0-9]([a-z0-9.-]*[a-z0-9])?$` |
| 21 | + Name string `json:"name"` |
| 22 | + |
| 23 | + // LibraryName is the name of the shared library file that Envoy will load. |
| 24 | + // Envoy searches for lib${libraryName}.so in the path specified by the |
| 25 | + // ENVOY_DYNAMIC_MODULES_SEARCH_PATH environment variable. |
| 26 | + // If not specified, defaults to the value of Name. |
| 27 | + // |
| 28 | + // +optional |
| 29 | + // +kubebuilder:validation:MaxLength=253 |
| 30 | + // +kubebuilder:validation:Pattern=`^[a-zA-Z0-9_]([a-zA-Z0-9_.-]*[a-zA-Z0-9_])?$` |
| 31 | + LibraryName *string `json:"libraryName,omitempty"` |
| 32 | + |
| 33 | + // DoNotClose prevents the module from being unloaded with dlclose when no |
| 34 | + // more references exist. This is useful for modules that maintain global |
| 35 | + // state that should not be destroyed on configuration updates. |
| 36 | + // Defaults to false. |
| 37 | + // |
| 38 | + // +optional |
| 39 | + // +kubebuilder:default=false |
| 40 | + DoNotClose *bool `json:"doNotClose,omitempty"` |
| 41 | + |
| 42 | + // LoadGlobally loads the dynamic module with the RTLD_GLOBAL flag. |
| 43 | + // By default, modules are loaded with RTLD_LOCAL to avoid symbol conflicts. |
| 44 | + // Set this to true when the module needs to share symbols with other |
| 45 | + // dynamic libraries it loads. |
| 46 | + // Defaults to false. |
| 47 | + // |
| 48 | + // +optional |
| 49 | + // +kubebuilder:default=false |
| 50 | + LoadGlobally *bool `json:"loadGlobally,omitempty"` |
| 51 | +} |
| 52 | + |
| 53 | +// DynamicModule defines a dynamic module HTTP filter to be loaded by Envoy. |
| 54 | +// The module must be registered in the EnvoyProxy resource's dynamicModules |
| 55 | +// allowlist by the infrastructure operator. |
| 56 | +type DynamicModule struct { |
| 57 | + // Name references a dynamic module registered in the EnvoyProxy resource's |
| 58 | + // dynamicModules list. The referenced module must exist in the registry; |
| 59 | + // otherwise, the policy will be rejected. |
| 60 | + // |
| 61 | + // +kubebuilder:validation:MinLength=1 |
| 62 | + // +kubebuilder:validation:MaxLength=253 |
| 63 | + // +kubebuilder:validation:Pattern=`^[a-z0-9]([a-z0-9.-]*[a-z0-9])?$` |
| 64 | + Name string `json:"name"` |
| 65 | + |
| 66 | + // FilterName identifies a specific filter implementation within the dynamic |
| 67 | + // module. A single shared library can contain multiple filter implementations. |
| 68 | + // This value is passed to the module's HTTP filter config init function to |
| 69 | + // select the appropriate implementation. |
| 70 | + // If not specified, defaults to an empty string. |
| 71 | + // |
| 72 | + // +optional |
| 73 | + // +kubebuilder:validation:MaxLength=253 |
| 74 | + FilterName *string `json:"filterName,omitempty"` |
| 75 | + |
| 76 | + // Config is the configuration for the dynamic module filter. |
| 77 | + // This is serialized as JSON and passed to the module's initialization function. |
| 78 | + // |
| 79 | + // +optional |
| 80 | + Config *apiextensionsv1.JSON `json:"config,omitempty"` |
| 81 | + |
| 82 | + // TerminalFilter indicates that this dynamic module handles requests without |
| 83 | + // requiring an upstream backend. The module is responsible for generating and |
| 84 | + // sending the response to downstream directly. |
| 85 | + // Defaults to false. |
| 86 | + // |
| 87 | + // +optional |
| 88 | + // +kubebuilder:default=false |
| 89 | + TerminalFilter *bool `json:"terminalFilter,omitempty"` |
| 90 | +} |
0 commit comments