Skip to content
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

fix: rework ns check, refactor: bubble up match err for mut #2812

Merged
merged 17 commits into from
Aug 8, 2023

Conversation

acpana
Copy link
Contributor

@acpana acpana commented Jun 3, 2023

This patch relaxes the namespace check in the expansion system to support
expansion that happens when no namespace selector is specified.

It also has a small refactor to propagate any matching errors from the mutation system's Matches() calls.

Fixes #2575

Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
@codecov-commenter
Copy link

codecov-commenter commented Jun 3, 2023

Codecov Report

Patch coverage: 38.70% and project coverage change: +0.04% 🎉

Comparison is base (1e68843) 53.07% compared to head (ba1d4a0) 53.12%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2812      +/-   ##
==========================================
+ Coverage   53.07%   53.12%   +0.04%     
==========================================
  Files         135      135              
  Lines       11790    11806      +16     
==========================================
+ Hits         6258     6272      +14     
- Misses       5046     5048       +2     
  Partials      486      486              
Flag Coverage Δ
unittests 53.12% <38.70%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
...tation/mutators/assignimage/assignimage_mutator.go 38.26% <0.00%> (ø)
...mutation/mutators/assignmeta/assignmeta_mutator.go 35.92% <0.00%> (+0.34%) ⬆️
.../mutation/mutators/modifyset/modify_set_mutator.go 52.34% <0.00%> (ø)
pkg/mutation/types/mutator.go 33.33% <ø> (ø)
pkg/mutation/system.go 77.30% <16.66%> (-4.94%) ⬇️
pkg/expansion/system.go 71.25% <70.00%> (-0.80%) ⬇️
pkg/mutation/mutators/assign/assign_mutator.go 29.49% <100.00%> (ø)
pkg/target/matcher.go 89.09% <100.00%> (ø)

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@maxsmythe maxsmythe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To support cluster-scoped objects and maintain simplicity, I'd probably just drop the requirement that namespaces exist and assume the resource is cluster-scoped if NS is nil.

@davis-haba Any reason that approach would be breaking?

pkg/gator/expand/expand.go Outdated Show resolved Hide resolved
pkg/expansion/system.go Outdated Show resolved Hide resolved
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
@acpana acpana requested a review from maxsmythe July 18, 2023 19:35
@acpana acpana changed the title feat: opt to relax ns check fix: rework ns check Jul 27, 2023
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
pkg/expansion/system.go Outdated Show resolved Hide resolved
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
Signed-off-by: alex <8968914+acpana@users.noreply.github.com>
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
@acpana acpana requested a review from maxsmythe August 2, 2023 01:02
@acpana
Copy link
Contributor Author

acpana commented Aug 2, 2023

@maxsmythe @davis-haba per our offline chat, I pushed a commit to propagate the error from the mutation interface on Matches(). Let me know what y'all think

@acpana acpana changed the title fix: rework ns check fix: rework ns check, refactor: bubble up match err for mut Aug 2, 2023
test/gator/expand/test.bats Outdated Show resolved Hide resolved
test/gator/test/test.bats Outdated Show resolved Hide resolved
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
@acpana acpana added this to the v3.13.0 milestone Aug 3, 2023
@davis-haba
Copy link
Contributor

Great job!

Commented with 1 question about the fail message for constraints, but otherwise LGTM.

pkg/expansion/system.go Show resolved Hide resolved
test/gator/test/test.bats Outdated Show resolved Hide resolved
Copy link
Contributor

@maxsmythe maxsmythe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@maxsmythe maxsmythe requested a review from ritazh August 4, 2023 19:59
@acpana
Copy link
Contributor Author

acpana commented Aug 4, 2023

@sozercan / @ritazh PTAL when you have a chance! 🙏🏼

pkg/expansion/system.go Outdated Show resolved Hide resolved
pkg/expansion/system_test.go Outdated Show resolved Hide resolved
Co-authored-by: Rita Zhang <rita.z.zhang@gmail.com>
Signed-off-by: alex <8968914+acpana@users.noreply.github.com>
pkg/expansion/system_test.go Outdated Show resolved Hide resolved
pkg/expansion/system_test.go Outdated Show resolved Hide resolved
Signed-off-by: alex <8968914+acpana@users.noreply.github.com>
@acpana acpana requested a review from ritazh August 7, 2023 17:35
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
Copy link
Member

@ritazh ritazh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@acpana acpana merged commit 5c49294 into open-policy-agent:master Aug 8, 2023
15 checks passed
salaxander pushed a commit to salaxander/gatekeeper that referenced this pull request Sep 13, 2023
…icy-agent#2812)

Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
Signed-off-by: alex <8968914+acpana@users.noreply.github.com>
Co-authored-by: Davis Haba <52938648+davis-haba@users.noreply.github.com>
Co-authored-by: Rita Zhang <rita.z.zhang@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gator fails to test manifest using expansionTemplate
6 participants