Skip to content

Commit

Permalink
Add API for GEP-3171 (#3283)
Browse files Browse the repository at this point in the history
* Create index.md

* Create metadata.yaml

* Update index.md

* Update metadata.yaml

* Remove 'omitempty' from Fraction fields

* Split MirrorPercent into two fields: MirrorPercent and MirrorFraction.

* Update index.md

* Add config examples.

* Add Existing Support Table

* Update field names to avoid 'stuttering' in names.

* Update geps/gep-3171/index.md

Co-authored-by: Rob Scott <[email protected]>

* Add Fraction type

* Add percent and fraction to HTTPRequestMirrorFilter

* Update apis/v1/httproute_types.go

Co-authored-by: Rob Scott <[email protected]>

* Update apis/v1/shared_types.go

Co-authored-by: Rob Scott <[email protected]>

* Add CEL validation to Fraction type

* Add CEL validation to HttpRequestMirrorFilter

Also updated field descriptions to match the validation. Removed the default value for Percent.

* Add CEL validation test for HTTPRequestMirrorFilter

* Ran /hack/update-codegen.sh

* Update httproute_experimental_test.go

* Update httproute_experimental_test.go

* Update httproute_experimental_test.go

* Update httproute_types.go

* Reran /hack/update-codegen.sh

* Update httproute_experimental_test.go

* Make Denominator field a pointer to distinguish between 0 and unset

Co-authored-by: Rob Scott <[email protected]>

* Change Percent to be a pointer to distinguish between 0 and unset

Co-authored-by: Rob Scott <[email protected]>

* Update httproute_experimental_test.go

* Update httproute_experimental_test.go

* Format httproute_types.go

* Make Fraction a pointer

* Update httproute_experimental_test.go

* Reran hack/update-codegen.sh

* Updating to test CEL validation

* Updating to test CEL validation

* Update httproute_types.go

* Update httproute_experimental_test.go

* Update httproute_experimental_test.go

* Update httproute_experimental_test.go

* Update httproute_types.go

* Update httproute_experimental_test.go

* Update httproute_types.go

* Update httproute_types.go

* testing

* Update httproute_types.go

* Ran hack/update-codegen.sh

* format shared_types.go

* Update httproute_types.go

* Update httproute_experimental_test.go

* Update httproute_types.go

* Update httproute_types.go

* reran hack/update-codegen.sh

* Update httproute_types.go

* Update httproute_experimental_test.go

* Reran hack/update-codegen.sh

* Added RequestMirror validation to GRPCRoute

* Create grcproute_experimental_test.go

* Update grcproute_experimental_test.go

* Update grpcroute_types.go

* Update grcproute_experimental_test.go

* Ran hack/update-codegen.sh

* Update grcproute_experimental_test.go

* Update grcproute_experimental_test.go

* Update Copyright Year

* Update pkg/test/cel/grcproute_experimental_test.go

Co-authored-by: Rob Scott <[email protected]>

* Update httproute_experimental_test.go

* Update grcproute_experimental_test.go

---------

Co-authored-by: Rob Scott <[email protected]>
  • Loading branch information
jakebennert and robscott authored Aug 27, 2024
1 parent 689c1cf commit 45ab52e
Show file tree
Hide file tree
Showing 15 changed files with 744 additions and 19 deletions.
48 changes: 48 additions & 0 deletions apis/applyconfiguration/apis/v1/fraction.go

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

18 changes: 18 additions & 0 deletions apis/applyconfiguration/apis/v1/httprequestmirrorfilter.go

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

17 changes: 17 additions & 0 deletions apis/applyconfiguration/internal/internal.go

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

2 changes: 2 additions & 0 deletions apis/applyconfiguration/utils.go

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

2 changes: 2 additions & 0 deletions apis/v1/grpcroute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,8 @@ type GRPCRouteFilter struct {
// Support: Extended
//
// +optional
//
// <gateway:experimental:validation:XValidation:message="Only one of percent or fraction may be specified in HTTPRequestMirrorFilter",rule="!(has(self.percent) && has(self.fraction))">
RequestMirror *HTTPRequestMirrorFilter `json:"requestMirror,omitempty"`

// ExtensionRef is an optional, implementation-specific extension to the
Expand Down
25 changes: 25 additions & 0 deletions apis/v1/httproute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,8 @@ type HTTPRouteFilter struct {
// Support: Extended
//
// +optional
//
// <gateway:experimental:validation:XValidation:message="Only one of percent or fraction may be specified in HTTPRequestMirrorFilter",rule="!(has(self.percent) && has(self.fraction))">
RequestMirror *HTTPRequestMirrorFilter `json:"requestMirror,omitempty"`

// RequestRedirect defines a schema for a filter that responds to the
Expand Down Expand Up @@ -1153,6 +1155,29 @@ type HTTPRequestMirrorFilter struct {
//
// Support: Implementation-specific for any other resource
BackendRef BackendObjectReference `json:"backendRef"`

// Percent represents the percentage of requests that should be
// mirrored to BackendRef. Its minimum value is 0 (indicating 0% of
// requests) and its maximum value is 100 (indicating 100% of requests).
//
// Only one of Fraction or Percent may be specified. If neither field
// is specified, 100% of requests will be mirrored.
//
// +optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=100
// <gateway:experimental>
Percent *int32 `json:"percent,omitempty"`

// Fraction represents the fraction of requests that should be
// mirrored to BackendRef.
//
// Only one of Fraction or Percent may be specified. If neither field
// is specified, 100% of requests will be mirrored.
//
// +optional
// <gateway:experimental>
Fraction Fraction `json:"fraction,omitempty"`
}

// HTTPBackendRef defines how a HTTPRoute forwards a HTTP request.
Expand Down
11 changes: 11 additions & 0 deletions apis/v1/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,3 +855,14 @@ const (
// Support: Extended
PermanentCookieLifetimeType CookieLifetimeType = "Permanent"
)

// +kubebuilder:validation:XValidation:message="numerator must be less than or equal to denominator",rule="self.numerator <= self.denominator"
type Fraction struct {
// +kubebuilder:validation:Minimum=0
Numerator int32 `json:"numerator"`

// +optional
// +kubebuilder:default=100
// +kubebuilder:validation:Minimum=1
Denominator *int32 `json:"denominator,omitempty"`
}
26 changes: 26 additions & 0 deletions apis/v1/zz_generated.deepcopy.go

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

Loading

0 comments on commit 45ab52e

Please sign in to comment.