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: cutpath for ../ paths #2498

Merged
merged 3 commits into from
Jan 6, 2023

Conversation

acpana
Copy link
Contributor

@acpana acpana commented Jan 6, 2023

Signed-off-by: Alex Pana 8968914+acpana@users.noreply.github.com

I missed specifying the prev dir relatively in my original cut trick: #2443 and this was raised in #2495. Fixes #2495 .

The issue was the cut didn't work w paths prefixed w ../. Added tests for that now.

Also, if you want to see it in action now for these kinds of paths:

# prev dir relative
$ gator verify ../gatekeeper/test/gator/verify/suite.yaml
ok      ../gatekeeper/test/gator/verify/suite.yaml      0.011s
PASS

# prev dir relative specified explicitly
$ gator verify ./../gatekeeper/test/gator/verify/suite.yaml
ok      ./../gatekeeper/test/gator/verify/suite.yaml      0.011s
PASS

# prev dir relative, recurse
$ gator verify ../gatekeeper/test/gator/verify/...
ok      ../gatekeeper/test/gator/verify/more_suites/suite copy.yaml     0.011s
ok      ../gatekeeper/test/gator/verify/more_suites/suite.yaml  0.007s
ok      ../gatekeeper/test/gator/verify/suite.yaml      0.009s
PASS

Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
// .Cut call below to actually work with the absolute path
// contained in the file var.
cutPath := strings.TrimPrefix(originalPath, "/")
cutPath = strings.TrimPrefix(cutPath, "./")
for strings.HasPrefix(cutPath, "../") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'm not too concerned about an infinite loop here since specifying an arbitrarily large number of prev directories has to happen for that

@codecov-commenter
Copy link

codecov-commenter commented Jan 6, 2023

Codecov Report

Base: 53.35% // Head: 53.38% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (c6790df) compared to base (7bdb64f).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2498      +/-   ##
==========================================
+ Coverage   53.35%   53.38%   +0.02%     
==========================================
  Files         116      116              
  Lines       10270    10272       +2     
==========================================
+ Hits         5480     5484       +4     
+ Misses       4370     4368       -2     
  Partials      420      420              
Flag Coverage Δ
unittests 53.38% <100.00%> (+0.02%) ⬆️

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

Impacted Files Coverage Δ
pkg/gator/verify/read_suites.go 87.17% <100.00%> (+0.22%) ⬆️
...onstrainttemplate/constrainttemplate_controller.go 58.61% <0.00%> (-1.20%) ⬇️
pkg/readiness/object_tracker.go 83.98% <0.00%> (+1.06%) ⬆️
pkg/readiness/list.go 91.17% <0.00%> (+11.76%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

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

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

@ritazh ritazh merged commit 923a183 into open-policy-agent:master Jan 6, 2023
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 CLI can't doesn't resolve relative paths
5 participants