Skip to content

Commit

Permalink
Merge pull request #252 from jpeach/update-validation
Browse files Browse the repository at this point in the history
Update validation rules.
  • Loading branch information
k8s-ci-robot authored Aug 13, 2020
2 parents e603534 + b6c148c commit c357a6b
Show file tree
Hide file tree
Showing 9 changed files with 290 additions and 172 deletions.
1 change: 0 additions & 1 deletion apis/v1alpha1/forwarding_target_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ type ForwardToTarget struct {
//
// +optional
// +kubebuilder:default=1
// +optional
Weight TargetWeight `json:"weight" protobuf:"bytes,3,opt,name=weight"`
}

Expand Down
26 changes: 23 additions & 3 deletions apis/v1alpha1/gateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ type GatewaySpec struct {
// defined protocols. If an implementation does not support a
// specified protocol, it should raise a "ConditionUnsupportedProtocol"
// condition for the affected Listener.
//
// Valid ProtocolType values are:
//
// * "HTTP"
// * "HTTPS"
// * "TLS"
// * "TCP"
//
// +kubebuilder:validation:Enum=HTTP;HTTPS;TLS;TCP
type ProtocolType string

const (
Expand All @@ -135,6 +144,13 @@ const (

// HostnameMatchType specifies the types of matches that are valid
// for host names.
// Valid match types are:
//
// * "Domain"
// * "Exact"
// * "Any"
//
// +kubebuilder:validation:Enum=Domain;Exact;Any
type HostnameMatchType string

const (
Expand Down Expand Up @@ -172,7 +188,6 @@ type HostnameMatch struct {
// matched against the given value.
//
// +optional
// +kubebuilder:validation:Enum=Domain;Exact;Any
// +kubebuilder:default=Exact
Match HostnameMatchType `json:"match" protobuf:"bytes,1,name=match"`

Expand Down Expand Up @@ -242,7 +257,6 @@ type Listener struct {
// Support: Core
//
// +required
// +kubebuilder:validation:Enum=HTTP;HTTPS;TLS;TCP
Protocol ProtocolType `json:"protocol,omitempty" protobuf:"bytes,3,opt,name=protocol"`

// TLS is the TLS configuration for the Listener. This field
Expand Down Expand Up @@ -274,6 +288,12 @@ type Listener struct {
}

// AddressType defines how a network address is represented as a text string.
// Valid AddressType values are:
//
// * "IPAddress"
// * "NamedAddress"
//
// +kubebuilder:validation:Enum=IPAddress;NamedAddress
type AddressType string

const (
Expand All @@ -287,6 +307,7 @@ const (
//
// Support: Extended.
IPAddressType AddressType = "IPAddress"

// NamedAddressType is an address selected by name. The interpretation of
// the name is dependent on the controller.
//
Expand All @@ -301,7 +322,6 @@ type GatewayAddress struct {
// Support: Extended
//
// +optional
// +kubebuilder:validation:Enum=IPAddress;NamedAddress
// +kubebuilder:default=IPAddress
Type AddressType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=AddressType"`

Expand Down
294 changes: 147 additions & 147 deletions apis/v1alpha1/generated.pb.go

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions apis/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 26 additions & 6 deletions apis/v1alpha1/httproute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ type HTTPRouteHost struct {
Hostnames []string `json:"hostnames,omitempty" protobuf:"bytes,1,opt,name=hostnames"`

// Rules are a list of HTTP matchers, filters and actions.
//
// +kubebuilder:validation:MinItems=1
Rules []HTTPRouteRule `json:"rules" protobuf:"bytes,2,rep,name=rules"`

// ExtensionRef is an optional, implementation-specific extension to the
Expand Down Expand Up @@ -107,23 +109,40 @@ type HTTPRouteRule struct {
}

// PathMatchType specifies the semantics of how HTTP paths should be compared.
// Valid PathMatchType values are:
//
// * "Exact"
// * "Prefix"
// * "RegularExpression"
// * "ImplementationSpecific"
//
// +kubebuilder:validation:Enum=Exact;Prefix;RegularExpression;ImplementationSpecific
type PathMatchType string

// PathType constants.
// PathMatchType constants.
const (
PathMatchExact PathMatchType = "Exact"
PathMatchPrefix PathMatchType = "Prefix"
PathMatchRegularExpression PathMatchType = "RegularExpression"
PathMatchImplementationSpecific PathMatchType = "ImplementationSpecific"
)

// HeaderMatchType specifies the semantics of how HTTP headers should be compared.
// Valid HeaderMatchType values are:
//
// * "Exact"
// * "ImplementationSpecific"
//
// +kubebuilder:validation:Enum=Exact;ImplementationSpecific
type HeaderMatchType string

// HeaderMatchType constants.
const (
// HeaderMatchTypeExact matches HTTP request-header fields.
// Field names matches are case-insensitive while field values matches
// are case-sensitive.
HeaderMatchTypeExact = "Exact"
HeaderMatchTypeImplementationSpecific = "ImplementationSpecific"
HeaderMatchExact HeaderMatchType = "Exact"
HeaderMatchImplementationSpecific HeaderMatchType = "ImplementationSpecific"
)

// HTTPRouteMatch defines the predicate used to match requests to a
Expand All @@ -146,9 +165,9 @@ type HTTPRouteMatch struct {
// Default: "Prefix"
//
// +optional
// +kubebuilder:validation:Enum=Exact;Prefix;RegularExpression;ImplementationSpecific
// +kubebuilder:default=Prefix
PathMatchType PathMatchType `json:"pathMatchType" protobuf:"bytes,1,opt,name=pathMatchType"`

// Path is the value of the HTTP path as interpreted via
// PathType.
//
Expand All @@ -163,9 +182,9 @@ type HTTPRouteMatch struct {
// Default: "Exact"
//
// +optional
// +kubebuilder:validation:Enum=Exact;ImplementationSpecific
// +kubebuilder:default=Exact
HeaderMatchType *string `json:"headerMatchType" protobuf:"bytes,3,opt,name=headerMatchType"`
HeaderMatchType *HeaderMatchType `json:"headerMatchType" protobuf:"bytes,3,opt,name=headerMatchType"`

// Headers are the HTTP Headers to match as interpreted via
// HeaderMatchType. Multiple headers are ANDed together, meaning, a request
// must contain all the headers specified in order to select this route.
Expand Down Expand Up @@ -269,6 +288,7 @@ type HTTPRouteAction struct {
//
// +kubebuilder:validation:MinItems=1
ForwardTo []ForwardToTarget `json:"forwardTo" protobuf:"bytes,1,rep,name=forwardTo"`

// ExtensionRef is an optional, implementation-specific extension to the
// "action" behavior. The resource may be "configmaps" (use the empty
// string for the group) or an implementation-defined resource (for
Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/crd/bases/networking.x-k8s.io_httproutes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ spec:
type: object
type: array
type: object
minItems: 1
type: array
required:
- rules
Expand Down
49 changes: 45 additions & 4 deletions docs-src/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,12 @@ TCPRouteStatus
<a href="#networking.x-k8s.io/v1alpha1.GatewayAddress">GatewayAddress</a>)
</p>
<p>
<p>AddressType defines how a network address is represented as a text string.</p>
<p>AddressType defines how a network address is represented as a text string.
Valid AddressType values are:</p>
<ul>
<li>&ldquo;IPAddress&rdquo;</li>
<li>&ldquo;NamedAddress&rdquo;</li>
</ul>
</p>
<h3 id="networking.x-k8s.io/v1alpha1.ConfigMapsDefaultLocalObjectReference">ConfigMapsDefaultLocalObjectReference
</h3>
Expand Down Expand Up @@ -1642,7 +1647,9 @@ PathType.</p>
<td>
<code>headerMatchType</code></br>
<em>
string
<a href="#networking.x-k8s.io/v1alpha1.HeaderMatchType">
HeaderMatchType
</a>
</em>
</td>
<td>
Expand Down Expand Up @@ -1832,6 +1839,20 @@ HTTPRouteAction
</tr>
</tbody>
</table>
<h3 id="networking.x-k8s.io/v1alpha1.HeaderMatchType">HeaderMatchType
(<code>string</code> alias)</p></h3>
<p>
(<em>Appears on:</em>
<a href="#networking.x-k8s.io/v1alpha1.HTTPRouteMatch">HTTPRouteMatch</a>)
</p>
<p>
<p>HeaderMatchType specifies the semantics of how HTTP headers should be compared.
Valid HeaderMatchType values are:</p>
<ul>
<li>&ldquo;Exact&rdquo;</li>
<li>&ldquo;ImplementationSpecific&rdquo;</li>
</ul>
</p>
<h3 id="networking.x-k8s.io/v1alpha1.HostnameMatch">HostnameMatch
</h3>
<p>
Expand Down Expand Up @@ -1899,7 +1920,13 @@ preferred name syntax defined in
</p>
<p>
<p>HostnameMatchType specifies the types of matches that are valid
for host names.</p>
for host names.
Valid match types are:</p>
<ul>
<li>&ldquo;Domain&rdquo;</li>
<li>&ldquo;Exact&rdquo;</li>
<li>&ldquo;Any&rdquo;</li>
</ul>
</p>
<h3 id="networking.x-k8s.io/v1alpha1.Listener">Listener
</h3>
Expand Down Expand Up @@ -2185,7 +2212,14 @@ status of all such Listeners.</p>
<a href="#networking.x-k8s.io/v1alpha1.HTTPRouteMatch">HTTPRouteMatch</a>)
</p>
<p>
<p>PathMatchType specifies the semantics of how HTTP paths should be compared.</p>
<p>PathMatchType specifies the semantics of how HTTP paths should be compared.
Valid PathMatchType values are:</p>
<ul>
<li>&ldquo;Exact&rdquo;</li>
<li>&ldquo;Prefix&rdquo;</li>
<li>&ldquo;RegularExpression&rdquo;</li>
<li>&ldquo;ImplementationSpecific&rdquo;</li>
</ul>
</p>
<h3 id="networking.x-k8s.io/v1alpha1.ProtocolType">ProtocolType
(<code>string</code> alias)</p></h3>
Expand All @@ -2199,6 +2233,13 @@ Listener. Implementations are not required to accept all the
defined protocols. If an implementation does not support a
specified protocol, it should raise a &ldquo;ConditionUnsupportedProtocol&rdquo;
condition for the affected Listener.</p>
<p>Valid ProtocolType values are:</p>
<ul>
<li>&ldquo;HTTP&rdquo;</li>
<li>&ldquo;HTTPS&rdquo;</li>
<li>&ldquo;TLS&rdquo;</li>
<li>&ldquo;TCP&rdquo;</li>
</ul>
</p>
<h3 id="networking.x-k8s.io/v1alpha1.RouteBindingSelector">RouteBindingSelector
</h3>
Expand Down
Loading

0 comments on commit c357a6b

Please sign in to comment.