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: create a policy utils package #5473

Merged
merged 4 commits into from
Nov 25, 2022
Merged

Conversation

eddycharly
Copy link
Member

Signed-off-by: Charles-Edouard Brétéché charles.edouard@nirmata.com

Explanation

This PR creates a policy utils package.
We manipulate policies a lot and this package will contain policy manipulation code we use often.
For now I added functions to marshal policies into json/yaml.

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
@eddycharly
Copy link
Member Author

cc @developer-guy

@codecov
Copy link

codecov bot commented Nov 25, 2022

Codecov Report

Merging #5473 (1a4ca20) into main (8547c8f) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #5473   +/-   ##
=======================================
  Coverage   36.42%   36.42%           
=======================================
  Files         172      172           
  Lines       19087    19087           
=======================================
  Hits         6952     6952           
  Misses      11340    11340           
  Partials      795      795           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -97,13 +96,9 @@ kyverno oci pull -i <imgref> -d policies`,
return fmt.Errorf("unmarshaling layer blob: %v", err)
}
for _, policy := range policies {
policyJsonBytes, err := json.Marshal(policy)
policyBytes, err := policyutils.ToYaml(policy)
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 add a comment here , since function name says ToYaml but we doing obj>json>yaml ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

BTW, I added the comment on the ToYaml func, not here.

eddycharly and others added 2 commits November 25, 2022 11:14
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
@eddycharly eddycharly merged commit 4984c5c into kyverno:main Nov 25, 2022
@eddycharly eddycharly deleted the policy-utils branch November 25, 2022 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants