builder

package
v2.2.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// KongPathRegexPrefix is the reserved prefix string that instructs Kong 3.0+ to interpret a path as a regex.
	KongPathRegexPrefix = "~"
	// KongHeaderRegexPrefix is a reserved prefix string that Kong uses to determine if it should parse a header value
	// as a regex.
	KongHeaderRegexPrefix = "~*"
)
View Source
const (
	// KongServiceProtocolHTTP stands for http protocol in Kong Service.
	KongServiceProtocolHTTP = "http"
	// KongServiceProtocolTCP stands for tcp protocol in Kong Service.
	KongServiceProtocolTCP = "tcp"
	// KongServiceProtocolTLS stands for tls protocol in Kong Service.
	KongServiceProtocolTLS = "tls"
)

Variables

This section is empty.

Functions

func GenerateKongRoutePathFromHTTPRouteMatch

func GenerateKongRoutePathFromHTTPRouteMatch(pathMatch *gatewayv1.HTTPPathMatch, setCaptureGroup bool) (paths []string, regexPriority *int64)

GenerateKongRoutePathFromHTTPRouteMatch translates the value in HTTPRoute's path match to the path used in KongRoute and returns any RegexPriority needed for the KongRoute. RegexPriority is set for Exact and non-root PathPrefix translations whose generated regex paths must preserve Gateway API path precedence in Kong's traditional-compatible router. Root capture-group translations and user-supplied RegularExpression matches keep Kong's default priority because they remain catch-all or implementation-specific cases.

Types

type KongCertificateBuilder

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

KongCertificateBuilder is a builder for configurationv1alpha1.KongCertificate resources.

func NewKongCertificate

func NewKongCertificate() *KongCertificateBuilder

NewKongCertificate creates and returns a new KongCertificateBuilder instance.

func (*KongCertificateBuilder) Build

Build returns the constructed KongCertificate resource and any accumulated errors.

func (*KongCertificateBuilder) MustBuild

MustBuild returns the constructed KongCertificate resource, panicking on any errors. Useful for tests or when you're certain the build will succeed.

func (*KongCertificateBuilder) WithAnnotations

func (b *KongCertificateBuilder) WithAnnotations(gateway *gwtypes.Gateway) *KongCertificateBuilder

WithAnnotations sets the annotations for the KongCertificate being built.

func (*KongCertificateBuilder) WithAnnotationsForRoute added in v2.2.0

func (b *KongCertificateBuilder) WithAnnotationsForRoute(route client.Object, pRef *gwtypes.ParentReference) *KongCertificateBuilder

WithAnnotationsForRoute sets annotations on the KongCertificate derived from a route object and its parent reference. This is the route-driven equivalent of WithAnnotations(gateway) used for listener TLS certs.

func (*KongCertificateBuilder) WithControlPlaneRef

WithControlPlaneRef sets the ControlPlaneRef for the KongCertificate being built.

func (*KongCertificateBuilder) WithLabels

func (b *KongCertificateBuilder) WithLabels(gateway *gwtypes.Gateway, listener *gwtypes.Listener) *KongCertificateBuilder

WithLabels sets the labels for the KongCertificate being built.

func (*KongCertificateBuilder) WithLabelsForRoute added in v2.2.0

WithLabelsForRoute sets labels on the KongCertificate derived from a route object and its parent reference. This is the route-driven equivalent of WithLabels(gateway, listener) used for listener TLS certs.

func (*KongCertificateBuilder) WithName

WithName sets the name for the KongCertificate being built.

func (*KongCertificateBuilder) WithNamespace

func (b *KongCertificateBuilder) WithNamespace(namespace string) *KongCertificateBuilder

WithNamespace sets the namespace for the KongCertificate being built.

func (*KongCertificateBuilder) WithOwner

WithOwner sets the owner reference for the KongCertificate to the given Gateway.

func (*KongCertificateBuilder) WithSecretRef

func (b *KongCertificateBuilder) WithSecretRef(name, namespace string) *KongCertificateBuilder

WithSecretRef sets the secret reference for the KongCertificate.

type KongPluginBindingBuilder

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

KongPluginBindingBuilder is a builder for configurationv1alpha1.KongPluginBinding resources.

func NewKongPluginBinding

func NewKongPluginBinding() *KongPluginBindingBuilder

NewKongPluginBinding creates and returns a new KongPluginBindingBuilder instance.

func (*KongPluginBindingBuilder) Build

Build returns the constructed KongPluginBinding resource and any accumulated errors.

func (*KongPluginBindingBuilder) MustBuild

MustBuild returns the constructed KongPluginBinding resource, panicking on any errors. Useful for tests or when you're certain the build will succeed.

func (*KongPluginBindingBuilder) WithAnnotations

WithAnnotations sets the annotations for the KongPluginBinding resource based on the given HTTPRoute and parent reference.

func (*KongPluginBindingBuilder) WithControlPlaneRef

WithControlPlaneRef sets the ControlPlaneRef for the KongPluginBinding being built.

func (*KongPluginBindingBuilder) WithLabels

WithLabels sets the labels for the KongPluginBinding resource based on the given HTTPRoute.

func (*KongPluginBindingBuilder) WithName

WithName sets the name for the KongPluginBinding being built.

func (*KongPluginBindingBuilder) WithNamespace

func (b *KongPluginBindingBuilder) WithNamespace(namespace string) *KongPluginBindingBuilder

WithNamespace sets the namespace for the KongPluginBinding being built.

func (*KongPluginBindingBuilder) WithOwner

WithOwner sets the owner reference for the KongPluginBinding to the given HTTPRoute.

func (*KongPluginBindingBuilder) WithPluginRef

WithPluginRef sets the plugin reference for the KongPluginBinding.

func (*KongPluginBindingBuilder) WithRouteRef

WithRouteRef sets the KongRoute reference for the KongPluginBinding.

func (*KongPluginBindingBuilder) WithServiceRef

func (b *KongPluginBindingBuilder) WithServiceRef(name string) *KongPluginBindingBuilder

WithServiceRef sets the KongService reference for the KongPluginBinding.

type KongPluginBuilder

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

KongPluginBuilder is a builder for configurationv1.KongPlugin resources.

func NewKongPlugin

func NewKongPlugin() *KongPluginBuilder

NewKongPlugin creates and returns a new KongPluginBuilder instance.

func (*KongPluginBuilder) Build

Build returns the constructed KongPlugin resource and any accumulated errors.

func (*KongPluginBuilder) MustBuild

MustBuild returns the constructed KongPlugin resource, panicking on any errors. Useful for tests or when you're certain the build will succeed.

func (*KongPluginBuilder) WithAnnotations

func (b *KongPluginBuilder) WithAnnotations(route *gwtypes.HTTPRoute, parentRef *gwtypes.ParentReference) *KongPluginBuilder

WithAnnotations sets the annotations for the KongPlugin resource based on the given HTTPRoute and parent reference.

func (*KongPluginBuilder) WithLabels

func (b *KongPluginBuilder) WithLabels(route *gwtypes.HTTPRoute, parentRef *gwtypes.ParentReference) *KongPluginBuilder

WithLabels sets the labels for the KongPlugin resource based on the given HTTPRoute.

func (*KongPluginBuilder) WithName

func (b *KongPluginBuilder) WithName(name string) *KongPluginBuilder

WithName sets the name for the KongPlugin being built.

func (*KongPluginBuilder) WithNamespace

func (b *KongPluginBuilder) WithNamespace(namespace string) *KongPluginBuilder

WithNamespace sets the namespace for the KongPlugin being built.

func (*KongPluginBuilder) WithOwner

func (b *KongPluginBuilder) WithOwner(owner *gwtypes.HTTPRoute) *KongPluginBuilder

WithOwner sets the owner reference for the KongPlugin to the given HTTPRoute.

func (*KongPluginBuilder) WithPluginConfig

func (b *KongPluginBuilder) WithPluginConfig(config json.RawMessage) *KongPluginBuilder

WithPluginConfig sets the plugin config for the KongPlugin being built.

func (*KongPluginBuilder) WithPluginName

func (b *KongPluginBuilder) WithPluginName(name string) *KongPluginBuilder

WithPluginName sets the plugin name for the KongPlugin being built.

type KongRouteBuilder

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

KongRouteBuilder is a builder for configurationv1alpha1.KongRoute resources.

func NewKongRoute

func NewKongRoute() *KongRouteBuilder

NewKongRoute creates and returns a new KongRouteBuilder instance.

func (*KongRouteBuilder) Build

Build returns the constructed KongRoute resource and any accumulated errors.

func (*KongRouteBuilder) MustBuild

MustBuild returns the constructed KongRoute resource, panicking on any errors. Useful for tests or when you're certain the build will succeed.

func (*KongRouteBuilder) WithAnnotations

func (b *KongRouteBuilder) WithAnnotations(route client.Object, parentRef *gwtypes.ParentReference) *KongRouteBuilder

WithAnnotations sets the annotations for the KongRoute resource based on the given route and parent reference.

func (*KongRouteBuilder) WithHTTPRouteMatch

func (b *KongRouteBuilder) WithHTTPRouteMatch(match gwtypes.HTTPRouteMatch, setCaptureGroup bool) *KongRouteBuilder

WithHTTPRouteMatch sets the match criteria (path, method, headers) for the KongRoute.

func (*KongRouteBuilder) WithHosts

func (b *KongRouteBuilder) WithHosts(hosts []string) *KongRouteBuilder

WithHosts sets the hosts for the KongRoute being built.

func (*KongRouteBuilder) WithKongService

func (b *KongRouteBuilder) WithKongService(name string) *KongRouteBuilder

WithKongService sets the KongService reference for the KongRoute.

func (*KongRouteBuilder) WithLabels

func (b *KongRouteBuilder) WithLabels(route client.Object, parentRef *gwtypes.ParentReference) *KongRouteBuilder

WithLabels sets the labels for the KongRoute resource based on the given route.

func (*KongRouteBuilder) WithName

func (b *KongRouteBuilder) WithName(name string) *KongRouteBuilder

WithName sets the name field of the KongRoute resource.

func (*KongRouteBuilder) WithNamespace

func (b *KongRouteBuilder) WithNamespace(namespace string) *KongRouteBuilder

WithNamespace sets the namespace field of the KongRoute resource.

func (*KongRouteBuilder) WithOwner

func (b *KongRouteBuilder) WithOwner(owner client.Object) *KongRouteBuilder

WithOwner sets the owner reference for the KongRoute to the given route.

func (*KongRouteBuilder) WithPreserveHost

func (b *KongRouteBuilder) WithPreserveHost(preserveHost bool) *KongRouteBuilder

WithPreserveHost sets the preserve host option for the KongRoute.

func (*KongRouteBuilder) WithProtocols added in v2.1.4

func (b *KongRouteBuilder) WithProtocols(protocols ...sdkkonnectcomp.RouteJSONProtocols) *KongRouteBuilder

WithProtocols sets the allowed protocols for the KongRoute being built.

func (*KongRouteBuilder) WithSNIs added in v2.2.0

func (b *KongRouteBuilder) WithSNIs(snis []string) *KongRouteBuilder

WithSNIs sets the SNIs for the KongRoute.

func (*KongRouteBuilder) WithSpecName

func (b *KongRouteBuilder) WithSpecName(name string) *KongRouteBuilder

WithSpecName sets the name field in the KongRoute spec.

func (*KongRouteBuilder) WithStripPath

func (b *KongRouteBuilder) WithStripPath(stripPath bool) *KongRouteBuilder

WithStripPath sets the strip path option for the KongRoute.

type KongSNIBuilder

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

KongSNIBuilder is a builder for configurationv1alpha1.KongSNI resources.

func NewKongSNI

func NewKongSNI() *KongSNIBuilder

NewKongSNI creates and returns a new KongSNIBuilder instance.

func (*KongSNIBuilder) Build

Build returns the constructed KongSNI resource and any accumulated errors.

func (*KongSNIBuilder) MustBuild

MustBuild returns the constructed KongSNI resource, panicking on any errors. Useful for tests or when you're certain the build will succeed.

func (*KongSNIBuilder) WithAnnotations

func (b *KongSNIBuilder) WithAnnotations(gateway *gwtypes.Gateway) *KongSNIBuilder

WithAnnotations sets the annotations for the KongSNI being built.

func (*KongSNIBuilder) WithCertificateRef

func (b *KongSNIBuilder) WithCertificateRef(certName string) *KongSNIBuilder

WithCertificateRef sets the certificate reference for the KongSNI.

func (*KongSNIBuilder) WithLabels

func (b *KongSNIBuilder) WithLabels(gateway *gwtypes.Gateway, listener *gwtypes.Listener) *KongSNIBuilder

WithLabels sets the labels for the KongSNI being built.

func (*KongSNIBuilder) WithName

func (b *KongSNIBuilder) WithName(name string) *KongSNIBuilder

WithName sets the name for the KongSNI being built.

func (*KongSNIBuilder) WithNamespace

func (b *KongSNIBuilder) WithNamespace(namespace string) *KongSNIBuilder

WithNamespace sets the namespace for the KongSNI being built.

func (*KongSNIBuilder) WithOwner

func (b *KongSNIBuilder) WithOwner(owner *gwtypes.Gateway) *KongSNIBuilder

WithOwner sets the owner reference for the KongSNI using controllerutil.SetControllerReference.

func (*KongSNIBuilder) WithSNIName

func (b *KongSNIBuilder) WithSNIName(hostname string) *KongSNIBuilder

WithSNIName sets the SNI name (hostname) in the spec.

type KongServiceBuilder

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

KongServiceBuilder is a builder for configurationv1alpha1.KongService resources.

func NewKongService

func NewKongService() *KongServiceBuilder

NewKongService creates and returns a new KongServiceBuilder instance.

func (*KongServiceBuilder) Build

Build returns the constructed KongService resource and any accumulated errors.

func (*KongServiceBuilder) MustBuild

MustBuild returns the constructed KongService resource, panicking on any errors. Useful for tests or when you're certain the build will succeed.

func (*KongServiceBuilder) WithAnnotations

func (b *KongServiceBuilder) WithAnnotations(route client.Object, parentRef *gwtypes.ParentReference) *KongServiceBuilder

WithAnnotations sets the annotations for the KongService being built.

func (*KongServiceBuilder) WithClientCertificateRef added in v2.2.0

func (b *KongServiceBuilder) WithClientCertificateRef(name string) *KongServiceBuilder

WithClientCertificateRef sets the clientCertificateRef on the KongService. name is the metadata.name of the KongCertificate in the same namespace. No-op when name is empty.

func (*KongServiceBuilder) WithConnectTimeout added in v2.2.0

func (b *KongServiceBuilder) WithConnectTimeout(v *int64) *KongServiceBuilder

WithConnectTimeout sets the connect timeout (milliseconds) for the KongService being built. A nil pointer leaves the field unset.

func (*KongServiceBuilder) WithControlPlaneRef

WithControlPlaneRef sets the ControlPlaneRef for the KongService being built.

func (*KongServiceBuilder) WithLabels

func (b *KongServiceBuilder) WithLabels(route client.Object, parentRef *gwtypes.ParentReference) *KongServiceBuilder

WithLabels sets the labels for the KongService being built.

func (*KongServiceBuilder) WithName

func (b *KongServiceBuilder) WithName(name string) *KongServiceBuilder

WithName sets the name for the KongService being built.

func (*KongServiceBuilder) WithNamespace

func (b *KongServiceBuilder) WithNamespace(namespace string) *KongServiceBuilder

WithNamespace sets the namespace for the KongService being built.

func (*KongServiceBuilder) WithOwner

func (b *KongServiceBuilder) WithOwner(owner client.Object) *KongServiceBuilder

WithOwner sets the owner reference for the KongService to the given route.

func (*KongServiceBuilder) WithPath added in v2.2.0

func (b *KongServiceBuilder) WithPath(path string) *KongServiceBuilder

WithPath sets the path for the KongService being built. An empty path leaves Spec.Path unset.

func (*KongServiceBuilder) WithProtocol

func (b *KongServiceBuilder) WithProtocol(protocol string) *KongServiceBuilder

WithProtocol sets the protocol for the KongService being built. Supported protocols match the Kong Gateway upstream protocol set.

func (*KongServiceBuilder) WithReadTimeout added in v2.2.0

func (b *KongServiceBuilder) WithReadTimeout(v *int64) *KongServiceBuilder

WithReadTimeout sets the read timeout (milliseconds) for the KongService being built. A nil pointer leaves the field unset.

func (*KongServiceBuilder) WithRetries added in v2.2.0

func (b *KongServiceBuilder) WithRetries(v *int64) *KongServiceBuilder

WithRetries sets the retries count for the KongService being built. A nil pointer leaves the field unset.

func (*KongServiceBuilder) WithSpecHost

func (b *KongServiceBuilder) WithSpecHost(host string) *KongServiceBuilder

WithSpecHost sets the host field in the KongService spec.

func (*KongServiceBuilder) WithSpecName

func (b *KongServiceBuilder) WithSpecName(name string) *KongServiceBuilder

WithSpecName sets the name field in the KongService spec.

func (*KongServiceBuilder) WithTLSVerify added in v2.2.0

func (b *KongServiceBuilder) WithTLSVerify(v *bool) *KongServiceBuilder

WithTLSVerify sets the tls-verify flag for the KongService being built. Nil leaves the field unset.

func (*KongServiceBuilder) WithTLSVerifyDepth added in v2.2.0

func (b *KongServiceBuilder) WithTLSVerifyDepth(v *int64) *KongServiceBuilder

WithTLSVerifyDepth sets the TLS verify depth for the KongService being built. Nil leaves the field unset.

func (*KongServiceBuilder) WithWriteTimeout added in v2.2.0

func (b *KongServiceBuilder) WithWriteTimeout(v *int64) *KongServiceBuilder

WithWriteTimeout sets the write timeout (milliseconds) for the KongService being built. A nil pointer leaves the field unset.

type KongTargetBuilder

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

KongTargetBuilder is a builder for configurationv1alpha1.KongTarget resources.

func NewKongTarget

func NewKongTarget() *KongTargetBuilder

NewKongTarget creates and returns a new KongTargetBuilder instance.

func (*KongTargetBuilder) Build

Build returns the constructed KongTarget resource and any accumulated errors.

func (*KongTargetBuilder) MustBuild

MustBuild returns the constructed KongTarget resource, panicking on any errors. Useful for tests or when you're certain the build will succeed.

func (*KongTargetBuilder) WithAnnotations

func (b *KongTargetBuilder) WithAnnotations(route client.Object, parentRef *gwtypes.ParentReference) *KongTargetBuilder

WithAnnotations sets the annotations for the KongTarget being built.

func (*KongTargetBuilder) WithLabels

func (b *KongTargetBuilder) WithLabels(route client.Object, parentRef *gwtypes.ParentReference) *KongTargetBuilder

WithLabels sets the labels for the KongTarget being built.

func (*KongTargetBuilder) WithName

func (b *KongTargetBuilder) WithName(name string) *KongTargetBuilder

WithName sets the name for the KongTarget being built.

func (*KongTargetBuilder) WithNamespace

func (b *KongTargetBuilder) WithNamespace(namespace string) *KongTargetBuilder

WithNamespace sets the namespace for the KongTarget being built.

func (*KongTargetBuilder) WithOwner

func (b *KongTargetBuilder) WithOwner(owner client.Object) *KongTargetBuilder

WithOwner sets the owner reference for the KongTarget to the given route.

func (*KongTargetBuilder) WithTarget

func (b *KongTargetBuilder) WithTarget(host string, port int) *KongTargetBuilder

WithTarget sets the target address for the KongTarget. It combines the host and port into a single target string in the format "host:port". The host can be an IP address, hostname, or FQDN, and the port must be a valid port number.

func (*KongTargetBuilder) WithUpstreamRef

func (b *KongTargetBuilder) WithUpstreamRef(upstreamRef string) *KongTargetBuilder

WithUpstreamRef sets the upstream reference for the KongTarget.

func (*KongTargetBuilder) WithWeight

func (b *KongTargetBuilder) WithWeight(weight *int32) *KongTargetBuilder

WithWeight sets the weight for the KongTarget, which determines the proportion of traffic this target will receive relative to other targets in the same upstream. If weight is nil, it defaults to 100. Higher weights receive more traffic.

type KongUpstreamBuilder

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

KongUpstreamBuilder is a builder for configurationv1alpha1.KongUpstream resources.

func NewKongUpstream

func NewKongUpstream() *KongUpstreamBuilder

NewKongUpstream returns a new KongUpstreamBuilder.

func (*KongUpstreamBuilder) Build

Build returns the constructed KongUpstream resource and any accumulated errors.

func (*KongUpstreamBuilder) MustBuild

MustBuild returns the constructed KongUpstream resource, panicking if there are any errors.

func (*KongUpstreamBuilder) WithAnnotations

func (b *KongUpstreamBuilder) WithAnnotations(route client.Object, parentRef *gwtypes.ParentReference) *KongUpstreamBuilder

WithAnnotations sets the annotations for the KongUpstream being built.

func (*KongUpstreamBuilder) WithControlPlaneRef

WithControlPlaneRef sets the control plane reference for the KongUpstream.

func (*KongUpstreamBuilder) WithHostHeader added in v2.2.0

func (b *KongUpstreamBuilder) WithHostHeader(v *string) *KongUpstreamBuilder

WithHostHeader sets the host-header field in the KongUpstream spec. A nil pointer leaves the field unset.

func (*KongUpstreamBuilder) WithLabels

func (b *KongUpstreamBuilder) WithLabels(route client.Object, parentRef *gwtypes.ParentReference) *KongUpstreamBuilder

WithLabels sets the labels for the KongUpstream being built.

func (*KongUpstreamBuilder) WithName

func (b *KongUpstreamBuilder) WithName(name string) *KongUpstreamBuilder

WithName sets the name for the KongUpstream being built.

func (*KongUpstreamBuilder) WithNamespace

func (b *KongUpstreamBuilder) WithNamespace(namespace string) *KongUpstreamBuilder

WithNamespace sets the namespace for the KongUpstream being built.

func (*KongUpstreamBuilder) WithOwner

WithOwner sets the owner reference for the KongUpstream to the given route.

func (*KongUpstreamBuilder) WithSpecName

func (b *KongUpstreamBuilder) WithSpecName(name string) *KongUpstreamBuilder

WithSpecName sets the name field in the KongUpstream spec.

Jump to

Keyboard shortcuts

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