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

PSCE-245 - Add pydantic for basic data validation of Trestle Rule #50

Merged
merged 6 commits into from
Oct 9, 2023

Conversation

jpower432
Copy link
Member

@jpower432 jpower432 commented Sep 30, 2023

Description

Adds basic data validation with pydantic and refactors transformers using a strategy pattern to make the transformers reusable and able to extend to new formats.

Blocked by #47

Type of change

  • New feature (non-breaking change which adds functionality)

How has this been tested?

  • Unit test added for validation

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Update write empty keys to write default keys
Create transformer for CSV reading and writing
Moves CSV specific logic t csv_transformer
Moves YAML specific logic to yaml_transformer and adds writing logic

Signed-off-by: Jennifer Power <[email protected]>
@jpower432
Copy link
Member Author

@afflom PTAL. This does a bit of reorganization and a couple fixes for adding pydantic for data validation. The YAML Builder is retained for its original intention of doing the CSV to YAML migration. Format specific implementations have been abstracted to the transformer. Let me know what you think!

@jpower432 jpower432 marked this pull request as draft October 4, 2023 21:20
@jpower432
Copy link
Member Author

@afflom Converted back to draft for a little bit of rework on the Transformer classes.

…former

To align with upstream trestle, the transformers are broken down into single
responsibilties and importing the Transformer Base.

Signed-off-by: Jennifer Power <[email protected]>
@jpower432 jpower432 marked this pull request as ready for review October 4, 2023 23:09
@afflom afflom merged commit e05c334 into RedHatProductSecurity:main Oct 9, 2023
7 checks passed
jpower432 added a commit to jpower432/trestle-bot that referenced this pull request Oct 9, 2023
…dHatProductSecurity#50)

* refactor: reworks csv_to_yaml for pydantic

Update write empty keys to write default keys
Create transformer for CSV reading and writing
Moves CSV specific logic t csv_transformer
Moves YAML specific logic to yaml_transformer and adds writing logic

Signed-off-by: Jennifer Power <[email protected]>

* docs: updates comment

Signed-off-by: Jennifer Power <[email protected]>

* docs: improves comment and variable naming

Signed-off-by: Jennifer Power <[email protected]>

* refactor: reduce extra code in RulesYAMLTransformer for simplicity

Signed-off-by: Jennifer Power <[email protected]>

* feat: adds Field aliases to remove underscores from YAML

Signed-off-by: Jennifer Power <[email protected]>

* refactor: breaks transformer into ToRuleTransformer and FromRuleTransformer

To align with upstream trestle, the transformers are broken down into single
responsibilties and importing the Transformer Base.

Signed-off-by: Jennifer Power <[email protected]>

---------

Signed-off-by: Jennifer Power <[email protected]>
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.

2 participants