-
Notifications
You must be signed in to change notification settings - Fork 618
cleanup: deprecate Type field in BackendSpec #13071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,15 +41,17 @@ const ( | |
| ) | ||
|
|
||
| // BackendSpec defines the desired state of Backend. | ||
| // +kubebuilder:validation:XValidation:message="aws backend must be specified when type is 'AWS'",rule="self.type == 'AWS' ? has(self.aws) : true" | ||
| // +kubebuilder:validation:XValidation:message="static backend must be specified when type is 'Static'",rule="self.type == 'Static' ? has(self.static) : true" | ||
| // +kubebuilder:validation:XValidation:message="dynamicForwardProxy backend must be specified when type is 'DynamicForwardProxy'",rule="self.type == 'DynamicForwardProxy' ? has(self.dynamicForwardProxy) : true" | ||
| // +kubebuilder:validation:ExactlyOneOf=aws;static;dynamicForwardProxy | ||
| // +kubebuilder:validation:XValidation:message="exactly one of aws, static, or dynamicForwardProxy must be specified",rule="[has(self.aws), has(self.static), has(self.dynamicForwardProxy)].filter(v, v).size() == 1" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's revert back to |
||
| // +kubebuilder:validation:XValidation:message="backend configuration must match the specified type",rule="!has(self.type) || (self.type == 'AWS' && has(self.aws)) || (self.type == 'Static' && has(self.static)) || (self.type == 'DynamicForwardProxy' && has(self.dynamicForwardProxy))" | ||
| type BackendSpec struct { | ||
| // Type indicates the type of the backend to be used. | ||
| // | ||
| // Deprecated: The Type field is deprecated and will be removed in a future release. | ||
| // The backend type is inferred from the configuration. | ||
| // | ||
| // +kubebuilder:validation:Enum=AWS;Static;DynamicForwardProxy | ||
| // +required | ||
| Type BackendType `json:"type"` | ||
| // +optional | ||
| Type BackendType `json:"type,omitempty"` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Surprised the linter didn't catch this, but this should be a pointer type now. See https://github.com/kgateway-dev/kgateway/pull/12923/files for some inspiration. |
||
| // Aws is the AWS backend configuration. | ||
| // The Aws backend type is only supported with envoy-based gateways, it is not supported in agentgateway. | ||
| // +optional | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,20 @@ spec: | |
| `, | ||
| wantErrors: []string{"exactly one of the fields in [aws static dynamicForwardProxy] must be set"}, | ||
| }, | ||
| { | ||
| name: "Backend: inferred type from configuration", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need to test this, but if we do, let's migrate it over to the https://github.com/kgateway-dev/kgateway/tree/af11f9bab3cfae7d2d2d9f61df70fc97325c7348/api/tests suite. |
||
| input: `--- | ||
| apiVersion: gateway.kgateway.dev/v1alpha1 | ||
| kind: Backend | ||
| metadata: | ||
| name: backend-inferred-type | ||
| spec: | ||
| static: | ||
| hosts: | ||
| - host: example.com | ||
| port: 80 | ||
| `, | ||
| }, | ||
| { | ||
| name: "Backend: empty lambda qualifier does not match pattern", | ||
| input: `--- | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we still want these rules in place even if the Type field becomes optional.