propertyoverride

package
v1.16.3 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func Constructor

Constructor follows a specific function signature required for the extension registration. It constructs a BasicEnvoyExtender with a patch Extension from the arguments provided by ext.

func PatchStruct

func PatchStruct[K proto.Message](k K, patch Patch, debug bool) (result K, e error)

PatchStruct patches the given ProtoMessage according to the documented behavior of Patch and returns the result. If an error is returned, the returned K (which may be a partially modified copy) should be ignored.

Types

type Op

type Op string

Op is the type of JSON Patch operation being applied.

const (
	OpAdd    Op = "add"
	OpRemove Op = "remove"
)

type Patch

type Patch struct {
	// ResourceFilter determines which Envoy resource(s) will be patched. ResourceFilter and
	// its subfields are not part of the JSON Patch specification.
	// This field is required.
	ResourceFilter ResourceFilter
	// Op represents the JSON Patch operation to be applied by the patch. Supported ops are
	// `add` and `remove`:
	//   - add: Replaces a field with the current value at the specified Path. (Note that
	//     JSON Patch does not inherently support object “merges”, which must be implemented
	//     using one discrete add per changed field.)
	//   - remove: Sets the value at the given path to `nil`. As with `add`, if the target
	//     field does not exist in the corresponding schema, an error is returned; this
	//     conforms to JSON Patch semantics and is intended to avoid silent failure when a
	//     field removal is expected.
	// This field is required.
	Op Op
	// Path specifies where the patch will be applied on a target resource. Path does not
	// support array member lookups or appending (`-`).
	//
	// When an unset but schema-valid (i.e. specified in the corresponding Envoy resource
	// .proto) intermediate message field is encountered on the Path, that field will be
	// set to its non-`nil` empty (default) value and evaluation will continue. This means
	// that even if parents of a field for a given Path are unset, a single patch can set
	// deeply nested children of that parent. Subsequent patching of these initialized
	// parent field(s) may be necessary to satisfy validation or configuration requirements.
	// This field is required.
	Path string
	// Value specifies the value that will be set at the given Path in a target resource in
	// an `add` operation.
	//
	// Value must be a map with scalar values, a scalar value, or an array of scalar values.
	// (Note that this along with the Path constraints noted above imply that setting values
	// nested within non-scalar arrays is not supported.)
	//
	// In every case, the target field will be replaced entirely with the specified value;
	// this conforms to JSON Patch `add` semantics. If Value is a map, the non-`nil` empty
	// value for the target field will be placed at the specified Path, and then the fields
	// specified in the Value map will be explicitly set.
	// This field is required if the Op is compatible with a Value per JSON Patch semantics
	// (e.g. `add`), and must not be set otherwise.
	Value any
}

Patch describes a single patch operation to modify the specific field of matching Envoy resources.

The semantics of Patch closely resemble those of JSON Patch (https://jsonpatch.com/, https://datatracker.ietf.org/doc/html/rfc6902/).

type ResourceFilter

type ResourceFilter struct {
	// ResourceType specifies the Envoy resource type the patch applies to. Valid values are
	// `cluster`, `route`, `endpoint`, and `listener`.
	// This field is required.
	ResourceType ResourceType
	// TrafficDirection determines whether the patch will be applied to a service's inbound
	// or outbound resources.
	// This field is required.
	TrafficDirection extensioncommon.TrafficDirection

	// Services indicates which upstream services will have corresponding Envoy resources patched.
	// This includes directly targeted and discovery chain services. If Services is omitted or
	// empty, all resources matching the filter will be targeted (including TProxy, which
	// implicitly corresponds to any number of upstreams). Services must be omitted unless
	// TrafficDirection is set to outbound.
	Services []*ServiceName
}

ResourceFilter matches specific Envoy resources to target with a Patch operation.

type ResourceType

type ResourceType string

ResourceType is the type of Envoy resource being patched.

const (
	ResourceTypeCluster               ResourceType = "cluster"
	ResourceTypeClusterLoadAssignment ResourceType = "cluster-load-assignment"
	ResourceTypeListener              ResourceType = "listener"
	ResourceTypeRoute                 ResourceType = "route"
)

type ServiceName

type ServiceName struct {
	api.CompoundServiceName `mapstructure:",squash"`
}

Jump to

Keyboard shortcuts

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