-
Notifications
You must be signed in to change notification settings - Fork 2
feat: support backendtrafficpolicy for Ingress #100
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
Changes from 3 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,20 +4,31 @@ import ( | |||||
| "github.com/api7/api7-ingress-controller/api/adc" | ||||||
| "github.com/api7/api7-ingress-controller/api/v1alpha1" | ||||||
| "k8s.io/apimachinery/pkg/types" | ||||||
| "k8s.io/utils/ptr" | ||||||
| gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" | ||||||
|
|
||||||
| adctypes "github.com/api7/api7-ingress-controller/api/adc" | ||||||
| ) | ||||||
|
|
||||||
| func convertBackendRef(namespace, name, kind string) gatewayv1.BackendRef { | ||||||
| backendRef := gatewayv1.BackendRef{} | ||||||
| backendRef.Name = gatewayv1.ObjectName(name) | ||||||
| backendRef.Namespace = ptr.To(gatewayv1.Namespace(namespace)) | ||||||
| backendRef.Kind = ptr.To(gatewayv1.Kind(kind)) | ||||||
| return backendRef | ||||||
| } | ||||||
|
|
||||||
| func (t *Translator) AttachBackendTrafficPolicyToUpstream(ref gatewayv1.BackendRef, policies map[types.NamespacedName]*v1alpha1.BackendTrafficPolicy, upstream *adctypes.Upstream) { | ||||||
| if len(policies) == 0 { | ||||||
| return | ||||||
| } | ||||||
| var policy *v1alpha1.BackendTrafficPolicy | ||||||
| for _, po := range policies { | ||||||
| if ref.Namespace != nil && string(*ref.Namespace) != po.Namespace { | ||||||
| continue | ||||||
| } | ||||||
| for _, targetRef := range po.Spec.TargetRefs { | ||||||
| if ref.Name == targetRef.Name && | ||||||
| (ref.Namespace != nil && string(*ref.Namespace) == po.Namespace) { | ||||||
| if ref.Name == targetRef.Name { | ||||||
|
||||||
| if ref.Name == targetRef.Name { | |
| if ref.Name == targetRef.Name && (ref.Namespace == nil || targetRef.Namespace == nil || string(*ref.Namespace) == targetRef.Namespace) { |
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.
reject.
targetRef does not have namespace
Uh oh!
There was an error while loading. Please reload this page.