-
Notifications
You must be signed in to change notification settings - Fork 387
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
Antctl cnp anp support #1301
Antctl cnp anp support #1301
Conversation
@GraysonWu, you must sign our contributor license agreement before your changes are merged. Click here to sign the agreement. If you are a VMware employee, read this for further instruction. |
Thanks for your PR. The following commands are available:
|
Codecov Report
@@ Coverage Diff @@
## master #1301 +/- ##
===========================================
+ Coverage 54.47% 64.63% +10.15%
===========================================
Files 119 157 +38
Lines 11240 12627 +1387
===========================================
+ Hits 6123 8161 +2038
+ Misses 4526 3620 -906
- Partials 591 846 +255
Flags with carried forward coverage won't be shown. Click here to find out more.
|
// getNetworkPolicy looks up and returns the cached NetworkPolicy. | ||
// nil is returned if the specified NetworkPolicy is not found. | ||
func (c *ruleCache) getNetworkPolicy(npName, npNamespace string) *v1beta1.NetworkPolicy { | ||
func (c *ruleCache) getNetworkPolicy(npFilter v1beta1.NetworkPolicyQueryFilter) *v1beta1.NetworkPolicy { |
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.
why do we return the first netpol matched in this case rather than returning the list of all matches?
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.
There are two functions: getNetworkPolicy
and getNetworkPolicies
.
According to my understanding, previously, before supporting CNP and ANP, getNetworkPolicy
is used to get a single NP with name and namespace. getNetworkPolicies
is used to get a list of NP in one namespace or all namespace.
After supporting CNP and ANP, with NetworkPolicyQueryFilter introduced, I want to keep the functionality of these two functions. getNetworkPolicies
still return a list of NP that match the filter. getNetworkPolicy
should accept a NetworkPolicyQueryFilter with attributes that can locate only one NP and return this NP.
BTW I'm totally ok to remove function getNetworkPolicy
since it can be covered by getNetworkPolicies
now. If users want a single NP, they can pass a proper filter into getNetworkPolicies
can get the first element of the returned list.
5d5a68b
to
a7c300b
Compare
a133bb6
to
9a7eba6
Compare
3f2fc88
to
fd4b1c6
Compare
Codecov Report
@@ Coverage Diff @@
## master #1301 +/- ##
===========================================
- Coverage 64.40% 54.28% -10.12%
===========================================
Files 159 120 -39
Lines 12681 11281 -1400
===========================================
- Hits 8167 6124 -2043
- Misses 3660 4563 +903
+ Partials 854 594 -260
Flags with carried forward coverage won't be shown. Click here to find out more.
|
fd4b1c6
to
5f3926e
Compare
e0819c0
to
c5c3c7a
Compare
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.
LGTM overall, some minor comments
c5c3c7a
to
fdc094f
Compare
cdf8ef2
to
b3119c6
Compare
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 comments, otherwise LGTM
After support CNP and ANP, some name and namespace based functions no longer work. Here add a struct called NetworkPolicyQueryFilter which can be used to query NetworkPolicies and easy to extend in future. The logic of the filter match is that if a NetworkPolicy can match all provided attributes of a filter then they are matched. Also add more info into result of antctl get netpol like sourceType, Prioriy, TierPriority. codegen and fix UT revert changes on this file, accidently submit it change response while no resource are found fix e2e test Add aliases to -r --reference option Update pkg/agent/apiserver/handlers/networkpolicy/handler.go Simplify the process of `func NewFilterFromURLQuery` Co-authored-by: Dyanngg <[email protected]>
From pkg/apis/controlplane/v1beta1/types.go To pkg/querier/querier.go
Change NetworkPolicyQueryFilter in map or argument from struct to pointer Change -r reference to -T type
b3119c6
to
9e15805
Compare
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.
LGTM
/test-all |
Make
antctl get netpol
support ACNP and ANP. Fix issue #927.After support ACNP and ANP, some name and namespace based functions no longer work. Here add a struct called NetworkPolicyQueryFilter which can be used to query NetworkPolicies and easy to extend in the future. The logic of the filter matching is that if a NetworkPolicy can match all provided attributes of a filter then they are matched.
Add type
-T [np acnp anp]
option toantctl get netpol
.Add more info into result of
antctl get netpol
like sourceType, Prioriy, TierPriority.