This repository has been archived by the owner on Mar 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Apply namespace selector to namespace instead of route #119
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nathancoleman
commented
Mar 8, 2022
internal/k8s/reconciler/utils.go
Outdated
Comment on lines
100
to
117
ns, err := metav1.LabelSelectorAsSelector(namespaceSelector.Selector) | ||
namespaceSelector, err := metav1.LabelSelectorAsSelector(namespaceSelector.Selector) | ||
if err != nil { | ||
return false, fmt.Errorf("error parsing label selector: %w", err) | ||
} | ||
|
||
// retrieve the route's namespace and determine whether selector matches | ||
namespace, err := c.GetNamespace(context.TODO(), types.NamespacedName{Name: route.GetNamespace()}) | ||
if err != nil { | ||
return false, fmt.Errorf("error parsing label selector: %v", err) | ||
return false, fmt.Errorf("error retrieving namespace for route: %w", err) | ||
} | ||
|
||
return ns.Matches(toNamespaceSet(route.GetNamespace(), route.GetLabels())), nil | ||
return namespaceSelector.Matches(toNamespaceSet(namespace.GetName(), namespace.GetLabels())), nil |
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.
This is the meat of the PR. Everything else is just plumbing and test updates to accommodate this.
Instead of attempting to apply namespace selector to route itself, retrieve the route's namespace and apply namespace selector to it.
mikemorris
approved these changes
Mar 9, 2022
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.
Two minor cleanup notes but overall LGTM!
2 tasks
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #117
Changes proposed in this PR:
allowedRoutes
, apply selector to route'sNamespace
instead of route itselfHow I've tested this PR:
$ kubectl apply -f
these resources.With this change in the controller, the
HTTPRoute
will successfully attach to theGateway
. Without this change, it will not and you will see the log from #117 in the controller pod.How I expect reviewers to test this PR:
Checklist: