Modularize the generators#702
Merged
Merged
Conversation
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
…feature/shaobo/modular-generators Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
…feature/shaobo/modular-generators Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
…r-generators Signed-off-by: Shaobo He <shaobohe@amazon.com>
cdisselkoen
approved these changes
Nov 4, 2025
cdisselkoen
left a comment
Contributor
There was a problem hiding this comment.
Seems like a reasonable refactor to me
Comment on lines
+1587
to
+1602
| Ok(u.choose( | ||
| &self | ||
| .actions_eids | ||
| .iter() | ||
| .map(|eid| { | ||
| EntityUID::from_components( | ||
| EntityType::from_normalized_str("Action") | ||
| .unwrap() | ||
| .qualify_with(self.namespace()), | ||
| eid.clone(), | ||
| None, | ||
| ) | ||
| }) | ||
| .collect::<Vec<_>>(), | ||
| )? | ||
| .clone()) |
Contributor
There was a problem hiding this comment.
Doesn't have to be addressed in this PR, but this is pretty inefficient, it builds all Action EntityUIDs and collects them all into a Vec only to clone one of its choice and throw away the whole Vec. More efficient would be to first u.choose() an EID and then only build the EntityUID for that particular chosen EID
Comment on lines
+370
to
+380
| Ok(u.choose( | ||
| &self | ||
| .core_schema | ||
| .get_entity_type(entity_type) | ||
| .expect("entity type should exist") | ||
| .attributes() | ||
| .iter() | ||
| .map(|a| a.0.clone()) | ||
| .collect::<Vec<_>>(), | ||
| )? | ||
| .clone()) |
Contributor
There was a problem hiding this comment.
nit: similar inefficiency here to one of my above comments
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
3 tasks
chaluli
approved these changes
Nov 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
Description of changes:
This PR implements a schema generator trait used by other generators like the request generator.
ValidatorSchemaand the crate'sSchemaboth implement it.So it allows the generator to generate policies/requests/hierarchies based on existing schema.