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

feat: Allow wildcard at start string and end together #2130

Merged

Conversation

erezo9
Copy link
Contributor

@erezo9 erezo9 commented Jun 29, 2022

What this PR does / why we need it:
add support for wild card at the end and start of a namespace
for example -dev-

Which issue(s) this PR fixes (optional, using fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when the PR gets merged):
Fixes #2128

Special notes for your reviewer:
With the help of @maxsmythe was able to complete the PR

@erezo9 erezo9 changed the title Allow wildcard at start string feat: Allow wildcard at start string and end together Jun 29, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jun 29, 2022

Codecov Report

Merging #2130 (3cfa568) into master (92b3b7d) will decrease coverage by 0.08%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #2130      +/-   ##
==========================================
- Coverage   54.38%   54.30%   -0.09%     
==========================================
  Files         111      111              
  Lines        9478     9504      +26     
==========================================
+ Hits         5155     5161       +6     
- Misses       3933     3946      +13     
- Partials      390      397       +7     
Flag Coverage Δ
unittests 54.30% <100.00%> (-0.09%) ⬇️

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

Impacted Files Coverage Δ
pkg/target/match_schema.go 100.00% <ø> (ø)
pkg/util/wildcard.go 100.00% <100.00%> (ø)
pkg/gator/runner.go 87.44% <0.00%> (-9.42%) ⬇️
pkg/readiness/object_tracker.go 82.91% <0.00%> (-1.07%) ⬇️
...onstrainttemplate/constrainttemplate_controller.go 55.87% <0.00%> (+0.95%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 92b3b7d...3cfa568. Read the comment docs.

@maxsmythe
Copy link
Contributor

Looks like lint is failing... running gofmt -s -w against the files should fix that

pkg/util/wildcard_test.go Outdated Show resolved Hide resolved
pkg/util/wildcard_test.go Outdated Show resolved Hide resolved
@erezo9 erezo9 requested a review from maxsmythe June 29, 2022 05:16
Copy link
Member

@chewong chewong left a comment

Choose a reason for hiding this comment

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

Can you revert the changes in charts/ folder? They should not be reflected in charts/ since that folder is reserved for versioned charts only.

@erezo9
Copy link
Contributor Author

erezo9 commented Jun 29, 2022

also for the deploy folder? which has the manifest?

@erezo9 erezo9 force-pushed the allow-wildcard-at-start-string branch from 4c6ad81 to 569bb16 Compare June 29, 2022 16:55
@erezo9 erezo9 requested a review from chewong June 29, 2022 16:58
@maxsmythe
Copy link
Contributor

yep, for deploy folder as well

matches: false,
},
{
name: "wild card at suffix and prefix, multiple hyphens",
Copy link
Contributor

Choose a reason for hiding this comment

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

can we have a double-wildcard and no match, just to make sure that code path gets tested?

@sozercan sozercan added this to the v3.9.0 milestone Jun 29, 2022
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, thank you for the PR!

@chewong chewong force-pushed the allow-wildcard-at-start-string branch from 3cfa568 to 169e785 Compare June 30, 2022 05:06
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

erezo9 added 11 commits June 30, 2022 08:59
Signed-off-by: Erez Tamam <erezo9@gmail.com>
Signed-off-by: Erez Tamam <erezo9@gmail.com>
Signed-off-by: Erez Tamam <erezo9@gmail.com>
Signed-off-by: Erez Tamam <erezo9@gmail.com>
Signed-off-by: Erez Tamam <erezo9@gmail.com>
Signed-off-by: Erez Tamam <erezo9@gmail.com>
Signed-off-by: Erez Tamam <erezo9@gmail.com>
Signed-off-by: Erez Tamam <erezo9@gmail.com>
Signed-off-by: Erez Tamam <erezo9@gmail.com>
Signed-off-by: Erez Tamam <erezo9@gmail.com>
Signed-off-by: Erez Tamam <erezo9@gmail.com>
@chewong chewong force-pushed the allow-wildcard-at-start-string branch from 169e785 to 17d3f61 Compare June 30, 2022 15:59
@chewong chewong merged commit 92ccd80 into open-policy-agent:master Jun 30, 2022
ChrisFraun pushed a commit to ChrisFraun/gatekeeper that referenced this pull request Jul 4, 2022
…ent#2130)

* Change all roles to support extra rules

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add astrix on start and end

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add check of wild card, for both prefix and suffix

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* remove rules from this pr

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* remove new line

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* lint files

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add test, fix misspelling

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add test for mutltiple hyphens

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* remove change deploy and charts

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add 2 more tests

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* change test name

Signed-off-by: Erez Tamam <erezo9@gmail.com>
Signed-off-by: Christoph Fraundorfer <christoph.fraundorfer@allianzdirect.de>
ChrisFraun pushed a commit to ChrisFraun/gatekeeper that referenced this pull request Jul 6, 2022
…ent#2130)

* Change all roles to support extra rules

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add astrix on start and end

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add check of wild card, for both prefix and suffix

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* remove rules from this pr

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* remove new line

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* lint files

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add test, fix misspelling

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add test for mutltiple hyphens

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* remove change deploy and charts

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add 2 more tests

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* change test name

Signed-off-by: Erez Tamam <erezo9@gmail.com>
Signed-off-by: Christoph Fraundorfer <christoph.fraundorfer@allianzdirect.de>
davis-haba pushed a commit to davis-haba/gatekeeper that referenced this pull request Jul 11, 2022
…ent#2130)

* Change all roles to support extra rules

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add astrix on start and end

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add check of wild card, for both prefix and suffix

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* remove rules from this pr

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* remove new line

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* lint files

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add test, fix misspelling

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add test for mutltiple hyphens

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* remove change deploy and charts

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add 2 more tests

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* change test name

Signed-off-by: Erez Tamam <erezo9@gmail.com>
davis-haba pushed a commit to davis-haba/gatekeeper that referenced this pull request Jul 19, 2022
…ent#2130)

* Change all roles to support extra rules

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add astrix on start and end

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add check of wild card, for both prefix and suffix

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* remove rules from this pr

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* remove new line

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* lint files

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add test, fix misspelling

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add test for mutltiple hyphens

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* remove change deploy and charts

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* add 2 more tests

Signed-off-by: Erez Tamam <erezo9@gmail.com>

* change test name

Signed-off-by: Erez Tamam <erezo9@gmail.com>
Signed-off-by: davis-haba <davishaba@google.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.

Add wild card match based on astrix at end and start
6 participants