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: Sync annotation unmarshaling in gator #2734

Merged

Conversation

anlandu
Copy link
Member

@anlandu anlandu commented May 1, 2023

What this PR does / why we need it:
Enables unmarshaling of the sync annotation into a struct
Design Doc

Special notes for your reviewer:

Signed-off-by: Anlan Du <adu47249@gmail.com>
@anlandu anlandu force-pushed the sync-annotation-unmarshaling branch from f0fb385 to ec6a457 Compare May 1, 2023 23:23
@acpana acpana requested a review from julianKatz May 1, 2023 23:39
Signed-off-by: Anlan Du <adu47249@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented May 2, 2023

Codecov Report

Patch coverage: 91.42% and project coverage change: +0.06 🎉

Comparison is base (a5ebec1) 53.46% compared to head (491cb84) 53.53%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2734      +/-   ##
==========================================
+ Coverage   53.46%   53.53%   +0.06%     
==========================================
  Files         127      128       +1     
  Lines       11373    11408      +35     
==========================================
+ Hits         6081     6107      +26     
- Misses       4817     4824       +7     
- Partials      475      477       +2     
Flag Coverage Δ
unittests 53.53% <91.42%> (+0.06%) ⬆️

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

Impacted Files Coverage Δ
pkg/syncutil/parser/syncannotationreader.go 91.42% <91.42%> (ø)

... and 1 file with indirect coverage changes

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

pkg/gator/reader/read_constraints.go Outdated Show resolved Hide resolved
pkg/gator/reader/read_constraints.go Outdated Show resolved Hide resolved
pkg/gator/reader/read_constraints.go Outdated Show resolved Hide resolved
pkg/gator/reader/read_constraints.go Outdated Show resolved Hide resolved
pkg/gator/reader/read_constraints.go Outdated Show resolved Hide resolved
pkg/gator/reader/read_constraints.go Outdated Show resolved Hide resolved
@julianKatz
Copy link
Contributor

What this PR does / why we need it: Enables unmarshaling of the sync annotation into a struct 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):

Special notes for your reviewer:

Plz remove unneeded text and include a link to the doc. Or perhaps we need a meta-issue to link all the work to.

@@ -1,6 +1,7 @@
package reader
Copy link
Contributor

Choose a reason for hiding this comment

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

Overall generally LGTM but needs unit tests.

Some things we should test:

  1. converting a "compact representation" to an "expended representation". The pure function will make this test clearer.
  2. converting actual text on a fake template into a full SyncRequirements
  3. Some error scenarios where the annotation is malformed (someone's bound to mess up the formatting, particularly if the annotation picks up steam in the community)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! Added tests--I think adding tests for ExpandCompactRequirements would be pretty redundant but lmk what you think

Signed-off-by: Anlan Du <adu47249@gmail.com>
Signed-off-by: Anlan Du <adu47249@gmail.com>
@anlandu anlandu force-pushed the sync-annotation-unmarshaling branch from 5bf981e to 6f20882 Compare May 4, 2023 00:58
Signed-off-by: Anlan Du <adu47249@gmail.com>
@anlandu anlandu force-pushed the sync-annotation-unmarshaling branch from 44f9bb7 to 1968f4c Compare May 10, 2023 03:27
Signed-off-by: Anlan Du <adu47249@gmail.com>
@anlandu anlandu marked this pull request as ready for review May 10, 2023 03:48
Copy link
Contributor

@acpana acpana left a comment

Choose a reason for hiding this comment

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

This LGTM for now, thanks for working on this!

I'd love to see this being used in gator to either generate SyncSets (probably going to happen later) or validate that a (constraint_template, constraint, config object) tuple satisfies the requirements. This could help iron out any kinks and provide immediate value to gator users.

pkg/syncutil/syncannotationreader.go 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! Sorry for the slow review cycle

Copy link
Member

@sozercan sozercan left a comment

Choose a reason for hiding this comment

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

see suggestions, otherwise LGTM

anlandu and others added 2 commits May 19, 2023 17:47
Co-authored-by: Sertaç Özercan <852750+sozercan@users.noreply.github.com>
Signed-off-by: Anlan Du <adu47249@gmail.com>
Co-authored-by: Sertaç Özercan <852750+sozercan@users.noreply.github.com>
Signed-off-by: Anlan Du <adu47249@gmail.com>
@sozercan sozercan merged commit 3801633 into open-policy-agent:master May 20, 2023
Hy3n4 pushed a commit to Hy3n4/gatekeeper that referenced this pull request Jun 8, 2023
Signed-off-by: Anlan Du <adu47249@gmail.com>
Co-authored-by: Sertaç Özercan <852750+sozercan@users.noreply.github.com>
Signed-off-by: Hy3n4 <hy3nk4@gmail.com>
julianKatz added a commit to julianKatz/gatekeeper-library that referenced this pull request Jun 8, 2023
In open-policy-agent/gatekeeper#2734 (comment)
the decision was made to change the sync data anotation casing from
`requiresSyncData` to `requires-sync-data`.  This better fits k8s
standards.

This PR updates gatekeeper-library templates with the new annotation
key.

Signed-off-by: juliankatz <juliankatz@google.com>
@anlandu anlandu deleted the sync-annotation-unmarshaling branch June 10, 2023 00:14
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.

7 participants