Repository: traefik/traefik
File: pkg/provider/kubernetes/crd/traefikio/v1alpha1/ingressroutetcp.go (Go)

Code before:
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/util/intstr"
)

// IngressRouteTCPSpec defines the desired state of IngressRouteTCP.
type IngressRouteTCPSpec struct {
	// Routes defines the list of routes.
	Routes []RouteTCP `json:"routes"`
	// EntryPoints defines the list of entry point names to bind to.
	// Entry points have to be configured in the static configuration.
	// More info: https://doc.traefik.io/traefik/v3.2/routing/entrypoints/
	// Default: all.
	EntryPoints []string `json:"entryPoints,omitempty"`
	// TLS defines the TLS configuration on a layer 4 / TCP Route.
	// More info: https://doc.traefik.io/traefik/v3.2/routing/routers/#tls_1
	TLS *TLSTCP `json:"tls,omitempty"`
}

// RouteTCP holds the TCP route configuration.
type RouteTCP struct {
	// Match defines the router's rule.
	// More info: https://doc.traefik.io/traefik/v3.2/routing/routers/#rule_1
	Match string `json:"match"`
	// Priority defines the router's priority.
	// More info: https://doc.traefik.io/traefik/v3.2/routing/routers/#priority_1
	// +kubebuilder:validation:Minimum=0
	Priority int `json:"priority,omitempty"`
	// Syntax defines the router's rule syntax.
	// More info: https://doc.traefik.io/traefik/v3.2/routing/routers/#rulesyntax_1
	// +kubebuilder:validation:Enum=v3;v2
	Syntax string `json:"syntax,omitempty"`
	// Services defines the list of TCP services.
	Services []ServiceTCP `json:"services,omitempty"`
	// Middlewares defines the list of references to MiddlewareTCP resources.
	Middlewares []ObjectReference `json:"middlewares,omitempty"`
}

// TLSTCP holds the TLS configuration for an IngressRouteTCP.
// More info: https://doc.traefik.io/traefik/v3.2/routing/routers/#tls_1
type TLSTCP struct {
	// SecretName is the name of the referenced Kubernetes Secret to specify the certificate details.
	SecretName string `json:"secretName,omitempty"`
	// Passthrough defines whether a TLS router will terminate the TLS connection.
	Passthrough bool `json:"passthrough,omitempty"`
	// Options defines the reference to a TLSOption, that specifies the parameters of the TLS connection.
	// If not defined, the `default` TLSOption is used.
	// More info: https://doc.traefik.io/traefik/v3.2/https/tls/#tls-options
	Options *ObjectReference `json:"options,omitempty"`
	// Store defines the reference to the TLSStore, that will be used to store certificates.
	// Please note that only `default` TLSStore can be used.
	// Deprecated: this reference is not needed.

Review comment (suggestion):
```suggestion
	// +kubebuilder:validation:Maximum=9223372036854774807
```

There is no enforcement on the minimum value and negative value are allowed, but the max is `const maxUserPriority = math.MaxInt - 1000`.

Code after:
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/util/intstr"
)

// IngressRouteTCPSpec defines the desired state of IngressRouteTCP.
type IngressRouteTCPSpec struct {
	// Routes defines the list of routes.
	Routes []RouteTCP `json:"routes"`
	// EntryPoints defines the list of entry point names to bind to.
	// Entry points have to be configured in the static configuration.
	// More info: https://doc.traefik.io/traefik/v3.3/routing/entrypoints/
	// Default: all.
	EntryPoints []string `json:"entryPoints,omitempty"`
	// TLS defines the TLS configuration on a layer 4 / TCP Route.
	// More info: https://doc.traefik.io/traefik/v3.3/routing/routers/#tls_1
	TLS *TLSTCP `json:"tls,omitempty"`
}

// RouteTCP holds the TCP route configuration.
type RouteTCP struct {
	// Match defines the router's rule.
	// More info: https://doc.traefik.io/traefik/v3.3/routing/routers/#rule_1
	Match string `json:"match"`
	// Priority defines the router's priority.
	// More info: https://doc.traefik.io/traefik/v3.3/routing/routers/#priority_1
	// +kubebuilder:validation:Maximum=9223372036854774807
	Priority int `json:"priority,omitempty"`
	// Syntax defines the router's rule syntax.
	// More info: https://doc.traefik.io/traefik/v3.3/routing/routers/#rulesyntax_1
	// +kubebuilder:validation:Enum=v3;v2
	Syntax string `json:"syntax,omitempty"`
	// Services defines the list of TCP services.
	Services []ServiceTCP `json:"services,omitempty"`
	// Middlewares defines the list of references to MiddlewareTCP resources.
	Middlewares []ObjectReference `json:"middlewares,omitempty"`
}

// TLSTCP holds the TLS configuration for an IngressRouteTCP.
// More info: https://doc.traefik.io/traefik/v3.3/routing/routers/#tls_1
type TLSTCP struct {
	// SecretName is the name of the referenced Kubernetes Secret to specify the certificate details.
	SecretName string `json:"secretName,omitempty"`
	// Passthrough defines whether a TLS router will terminate the TLS connection.
	Passthrough bool `json:"passthrough,omitempty"`
	// Options defines the reference to a TLSOption, that specifies the parameters of the TLS connection.
	// If not defined, the `default` TLSOption is used.
	// More info: https://doc.traefik.io/traefik/v3.3/https/tls/#tls-options
	Options *ObjectReference `json:"options,omitempty"`
	// Store defines the reference to the TLSStore, that will be used to store certificates.
	// Please note that only `default` TLSStore can be used.
	Store *ObjectReference `json:"store,omitempty"`