diff --git a/apis/v1alpha2/httproute_types.go b/apis/v1alpha2/httproute_types.go index 3b12729a52..60f916725b 100644 --- a/apis/v1alpha2/httproute_types.go +++ b/apis/v1alpha2/httproute_types.go @@ -98,7 +98,7 @@ type HTTPRouteSpec struct { // // +optional // +kubebuilder:validation:MaxItems=16 - // +kubebuilder:default={{matches: {{path: {type: "Prefix", value: "/"}}}}} + // +kubebuilder:default={{matches: {{path: {type: "PathPrefix", value: "/"}}}}} Rules []HTTPRouteRule `json:"rules,omitempty"` } @@ -160,7 +160,7 @@ type HTTPRouteRule struct { // // +optional // +kubebuilder:validation:MaxItems=8 - // +kubebuilder:default={{path:{ type: "Prefix", value: "/"}}} + // +kubebuilder:default={{path:{ type: "PathPrefix", value: "/"}}} Matches []HTTPRouteMatch `json:"matches,omitempty"` // Filters define the filters that are applied to requests that match @@ -209,15 +209,15 @@ type HTTPRouteRule struct { // Valid PathMatchType values are: // // * "Exact" -// * "Prefix" +// * "PathPrefix" // * "RegularExpression" // -// Prefix and Exact paths must be syntactically valid: +// PathPrefix and Exact paths must be syntactically valid: // // - Must begin with the `/` character // - Must not contain consecutive `/` characters (e.g. `/foo///`, `//`). // -// +kubebuilder:validation:Enum=Exact;Prefix;RegularExpression +// +kubebuilder:validation:Enum=Exact;PathPrefix;RegularExpression type PathMatchType string const ( @@ -232,7 +232,7 @@ const ( // // For example, `/abc`, `/abc/` and `/abc/def` match the prefix // `/abc`, but `/abcd` does not. - PathMatchPrefix PathMatchType = "Prefix" + PathMatchPathPrefix PathMatchType = "PathPrefix" // Matches if the URL path matches the given regular expression with // case sensitivity. @@ -248,12 +248,12 @@ const ( type HTTPPathMatch struct { // Type specifies how to match against the path Value. // - // Support: Core (Exact, Prefix) + // Support: Core (Exact, PathPrefix) // // Support: Custom (RegularExpression) // // +optional - // +kubebuilder:default=Prefix + // +kubebuilder:default=PathPrefix Type *PathMatchType `json:"type,omitempty"` // Value of the HTTP path to match against. @@ -426,7 +426,7 @@ type HTTPRouteMatch struct { // specified, a default prefix match on the "/" path is provided. // // +optional - // +kubebuilder:default={type: "Prefix", value: "/"} + // +kubebuilder:default={type: "PathPrefix", value: "/"} Path *HTTPPathMatch `json:"path,omitempty"` // Headers specifies HTTP request header matchers. Multiple match values are diff --git a/apis/v1alpha2/policy_types.go b/apis/v1alpha2/policy_types.go index 180bb1a576..cbf96ed31a 100644 --- a/apis/v1alpha2/policy_types.go +++ b/apis/v1alpha2/policy_types.go @@ -38,12 +38,4 @@ type PolicyTargetReference struct { // // +optional Namespace *Namespace `json:"namespace,omitempty"` - - // ClassName is the name of the class this policy should apply to. When - // unspecified, the policy will apply to all classes that support it. - // - // +kubebuilder:validation:MinLength=1 - // +kubebuilder:validation:MaxLength=253 - // +optional - ClassName *string `json:"className,omitempty"` } diff --git a/apis/v1alpha2/referencepolicy_types.go b/apis/v1alpha2/referencepolicy_types.go index 149ae89b65..32738c05af 100644 --- a/apis/v1alpha2/referencepolicy_types.go +++ b/apis/v1alpha2/referencepolicy_types.go @@ -122,4 +122,11 @@ type ReferencePolicyTo struct { // // * Service Kind Kind `json:"kind"` + + // Name is the name of the referent. When unspecified or empty, this policy + // refers to all resources of the specified Group and Kind in the local + // namespace. + // + // +optional + Name *ObjectName `json:"name,omitempty"` } diff --git a/apis/v1alpha2/validation/httproute.go b/apis/v1alpha2/validation/httproute.go index 309f91b49e..33c41c14e2 100644 --- a/apis/v1alpha2/validation/httproute.go +++ b/apis/v1alpha2/validation/httproute.go @@ -113,7 +113,7 @@ func validateHTTPPathMatch(path *gatewayv1a2.HTTPPathMatch, fldPath *field.Path) } switch *path.Type { - case gatewayv1a2.PathMatchExact, gatewayv1a2.PathMatchPrefix: + case gatewayv1a2.PathMatchExact, gatewayv1a2.PathMatchPathPrefix: if !strings.HasPrefix(*path.Value, "/") { allErrs = append(allErrs, field.Invalid(fldPath.Child("path"), path, "must be an absolute path")) } @@ -132,7 +132,7 @@ func validateHTTPPathMatch(path *gatewayv1a2.HTTPPathMatch, fldPath *field.Path) } case gatewayv1a2.PathMatchRegularExpression: default: - pathTypes := []string{string(gatewayv1a2.PathMatchExact), string(gatewayv1a2.PathMatchPrefix), string(gatewayv1a2.PathMatchRegularExpression)} + pathTypes := []string{string(gatewayv1a2.PathMatchExact), string(gatewayv1a2.PathMatchPathPrefix), string(gatewayv1a2.PathMatchRegularExpression)} allErrs = append(allErrs, field.NotSupported(fldPath.Child("pathType"), *path.Type, pathTypes)) } return allErrs diff --git a/apis/v1alpha2/validation/httproute_test.go b/apis/v1alpha2/validation/httproute_test.go index ba1ce76b9f..66f9db1ca6 100644 --- a/apis/v1alpha2/validation/httproute_test.go +++ b/apis/v1alpha2/validation/httproute_test.go @@ -42,7 +42,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: pkgutils.PathMatchTypePtr("Prefix"), + Type: pkgutils.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -69,7 +69,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: pkgutils.PathMatchTypePtr("Prefix"), + Type: pkgutils.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -96,7 +96,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: pkgutils.PathMatchTypePtr("Prefix"), + Type: pkgutils.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -132,7 +132,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: pkgutils.PathMatchTypePtr("Prefix"), + Type: pkgutils.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -181,7 +181,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: pkgutils.PathMatchTypePtr("Prefix"), + Type: pkgutils.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -248,7 +248,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: pkgutils.PathMatchTypePtr("Prefix"), + Type: pkgutils.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -400,7 +400,7 @@ func TestValidateHTTPPathMatch(t *testing.T) { { name: "invalid httpRoute prefix", path: &gatewayv1a2.HTTPPathMatch{ - Type: pkgutils.PathMatchTypePtr("Prefix"), + Type: pkgutils.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/."), }, errCount: 1, @@ -416,7 +416,7 @@ func TestValidateHTTPPathMatch(t *testing.T) { { name: "invalid httpRoute prefix", path: &gatewayv1a2.HTTPPathMatch{ - Type: pkgutils.PathMatchTypePtr("Prefix"), + Type: pkgutils.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, errCount: 0, diff --git a/apis/v1alpha2/zz_generated.deepcopy.go b/apis/v1alpha2/zz_generated.deepcopy.go index e0fdf2b3f0..47651f3760 100644 --- a/apis/v1alpha2/zz_generated.deepcopy.go +++ b/apis/v1alpha2/zz_generated.deepcopy.go @@ -953,11 +953,6 @@ func (in *PolicyTargetReference) DeepCopyInto(out *PolicyTargetReference) { *out = new(Namespace) **out = **in } - if in.ClassName != nil { - in, out := &in.ClassName, &out.ClassName - *out = new(string) - **out = **in - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PolicyTargetReference. @@ -1054,7 +1049,9 @@ func (in *ReferencePolicySpec) DeepCopyInto(out *ReferencePolicySpec) { if in.To != nil { in, out := &in.To, &out.To *out = make([]ReferencePolicyTo, len(*in)) - copy(*out, *in) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } } @@ -1071,6 +1068,11 @@ func (in *ReferencePolicySpec) DeepCopy() *ReferencePolicySpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ReferencePolicyTo) DeepCopyInto(out *ReferencePolicyTo) { *out = *in + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(ObjectName) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReferencePolicyTo. diff --git a/config/crd/v1alpha2/gateway.networking.k8s.io_httproutes.yaml b/config/crd/v1alpha2/gateway.networking.k8s.io_httproutes.yaml index 551085be6c..c166a6aa1d 100644 --- a/config/crd/v1alpha2/gateway.networking.k8s.io_httproutes.yaml +++ b/config/crd/v1alpha2/gateway.networking.k8s.io_httproutes.yaml @@ -179,7 +179,7 @@ spec: default: - matches: - path: - type: Prefix + type: PathPrefix value: / description: Rules are a list of HTTP matchers, filters and actions. items: @@ -890,7 +890,7 @@ spec: matches: default: - path: - type: Prefix + type: PathPrefix value: / description: "Matches define conditions used for matching the rule against incoming HTTP requests. Each match is independent, @@ -1004,20 +1004,20 @@ spec: type: string path: default: - type: Prefix + type: PathPrefix value: / description: Path specifies a HTTP request path matcher. If this field is not specified, a default prefix match on the "/" path is provided. properties: type: - default: Prefix + default: PathPrefix description: "Type specifies how to match against - the path Value. \n Support: Core (Exact, Prefix) + the path Value. \n Support: Core (Exact, PathPrefix) \n Support: Custom (RegularExpression)" enum: - Exact - - Prefix + - PathPrefix - RegularExpression type: string value: diff --git a/config/crd/v1alpha2/gateway.networking.k8s.io_referencepolicies.yaml b/config/crd/v1alpha2/gateway.networking.k8s.io_referencepolicies.yaml index 5ddd515fca..a0de9b4d2e 100644 --- a/config/crd/v1alpha2/gateway.networking.k8s.io_referencepolicies.yaml +++ b/config/crd/v1alpha2/gateway.networking.k8s.io_referencepolicies.yaml @@ -114,6 +114,13 @@ spec: minLength: 1 pattern: ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ type: string + name: + description: Name is the name of the referent. When unspecified + or empty, this policy refers to all resources of the specified + Group and Kind in the local namespace. + maxLength: 253 + minLength: 1 + type: string required: - group - kind diff --git a/examples/v1alpha2/basic-http.yaml b/examples/v1alpha2/basic-http.yaml index 32913917b0..dfdf9a78d1 100644 --- a/examples/v1alpha2/basic-http.yaml +++ b/examples/v1alpha2/basic-http.yaml @@ -32,7 +32,7 @@ spec: rules: - matches: - path: - type: Prefix + type: PathPrefix value: /bar backendRefs: - name: my-service1 @@ -47,7 +47,7 @@ spec: name: great value: example path: - type: Prefix + type: PathPrefix value: /some/thing method: GET backendRefs: diff --git a/examples/v1alpha2/default-match-http.yaml b/examples/v1alpha2/default-match-http.yaml index a67d23772a..f4794850c0 100644 --- a/examples/v1alpha2/default-match-http.yaml +++ b/examples/v1alpha2/default-match-http.yaml @@ -17,7 +17,7 @@ spec: port: 80 --- # This HTTPRoute demonstrates patch match defaulting. If no path match is -# specified, CRD defaults adds a default prefix match on the path "/". This +# specified, CRD defaults adds a default PathPrefix match on the path "/". This # matches every HTTP request and ensures that route rules always have at # least one valid match. apiVersion: gateway.networking.k8s.io/v1alpha2 diff --git a/examples/v1alpha2/http-redirect.yaml b/examples/v1alpha2/http-redirect.yaml index 702cbb1c2a..80629c6eb8 100644 --- a/examples/v1alpha2/http-redirect.yaml +++ b/examples/v1alpha2/http-redirect.yaml @@ -60,7 +60,7 @@ spec: rules: - matches: - path: - type: Prefix + type: PathPrefix value: / backendRefs: - name: my-filter-svc1 diff --git a/examples/v1alpha2/http-routing/foo-httproute.yaml b/examples/v1alpha2/http-routing/foo-httproute.yaml index 6f3002b671..a611719ce8 100644 --- a/examples/v1alpha2/http-routing/foo-httproute.yaml +++ b/examples/v1alpha2/http-routing/foo-httproute.yaml @@ -10,7 +10,7 @@ spec: rules: - matches: - path: - type: Prefix + type: PathPrefix value: /login backendRefs: - name: foo-svc diff --git a/pkg/util/utils_test.go b/pkg/util/utils_test.go index 65345bdee9..9622232a87 100644 --- a/pkg/util/utils_test.go +++ b/pkg/util/utils_test.go @@ -83,8 +83,8 @@ func Test_PathMatchTypePtr(t *testing.T) { { name: "valid path prefix match", - pathType: "Prefix", - expectedPath: gatewayv1a2.PathMatchPrefix, + pathType: "PathPrefix", + expectedPath: gatewayv1a2.PathMatchPathPrefix, }, { name: "valid path regular expression match", diff --git a/site-src/geps/gep-713.md b/site-src/geps/gep-713.md index 5320f2a6d6..33f0d6f708 100644 --- a/site-src/geps/gep-713.md +++ b/site-src/geps/gep-713.md @@ -127,14 +127,6 @@ type PolicyTargetReference struct { // +kubebuilder:validation:MaxLength=253 // +optional Namespace string `json:"namespace,omitempty"` - - // ClassName is the name of the class this policy should apply to. When - // unspecified, the policy will apply to all classes that support it. - // - // +kubebuilder:validation:MinLength=1 - // +kubebuilder:validation:MaxLength=253 - // +optional - ClassName string `json:"className,omitempty"` } ``` @@ -401,7 +393,7 @@ spec: - name: bar matches: - path: - type: Prefix + type: PathPrefix value: /bar forwardTo: - serviceName: my-service1