Skip to content

Commit

Permalink
api: enforce at least one service entry per route & tcpproxy
Browse files Browse the repository at this point in the history
Fixes projectcontour#2270

Signed-off-by: Dave Cheney <dave@cheney.net>
  • Loading branch information
davecheney committed Feb 23, 2020
1 parent abf82cb commit 9e231f1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion apis/projectcontour/v1/httpproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ type Route struct {
// +optional
Conditions []Condition `json:"conditions,omitempty"`
// Services are the services to proxy traffic.
Services []Service `json:"services,omitempty"`
// +kubebuilder:validation:MinItems=1
Services []Service `json:"services"`
// Enables websocket support for the route.
// +optional
EnableWebsockets bool `json:"enableWebsockets,omitempty"`
Expand Down Expand Up @@ -173,6 +174,7 @@ type TCPProxy struct {
// +optional
LoadBalancerPolicy *LoadBalancerPolicy `json:"loadBalancerPolicy,omitempty"`
// Services are the services to proxy traffic
// +kubebuilder:validation:MinItems=1
Services []Service `json:"services,omitempty"`
// Include specifies that this tcpproxy should be delegated to another HTTPProxy.
// +optional
Expand Down
4 changes: 4 additions & 0 deletions examples/contour/01-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ spec:
- name
- port
type: object
minItems: 1
type: array
timeoutPolicy:
description: The timeout policy for this route.
Expand All @@ -878,6 +879,8 @@ spec:
the timeout duration is undefined.
type: string
type: object
required:
- services
type: object
type: array
tcpproxy:
Expand Down Expand Up @@ -1043,6 +1046,7 @@ spec:
- name
- port
type: object
minItems: 1
type: array
type: object
virtualhost:
Expand Down
8 changes: 6 additions & 2 deletions examples/render/contour.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ spec:
to the backing cluster.
type: boolean
secretName:
description: required, the name of a secret in the current namespace
description: required, the name of a secret in the current namespace.
type: string
type: object
required:
Expand Down Expand Up @@ -936,6 +936,7 @@ spec:
- name
- port
type: object
minItems: 1
type: array
timeoutPolicy:
description: The timeout policy for this route.
Expand All @@ -952,6 +953,8 @@ spec:
the timeout duration is undefined.
type: string
type: object
required:
- services
type: object
type: array
tcpproxy:
Expand Down Expand Up @@ -1117,6 +1120,7 @@ spec:
- name
- port
type: object
minItems: 1
type: array
type: object
virtualhost:
Expand All @@ -1142,7 +1146,7 @@ spec:
to the backing cluster.
type: boolean
secretName:
description: required, the name of a secret in the current namespace
description: required, the name of a secret in the current namespace.
type: string
type: object
required:
Expand Down

0 comments on commit 9e231f1

Please sign in to comment.