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

Translate ResourceValue to ResourceIr to add metadata #25

Merged
merged 1 commit into from
Nov 12, 2021

Conversation

iph
Copy link
Collaborator

@iph iph commented Nov 10, 2021

Resources in intermediate representation was the last holdover
to a working program without manual manipulation of typescript.

This change adds "Complexity", a concept to help translate CDK
interfaces appropriately for L1s, and adds this decoration to
ResourceIr. This change also adds a few other bells and whistles
along the way while debugging final output (like AWS::AccountId)

Resources in intermediate representation was the last holdover
to a working program without manual manipulation of typescript.

This change adds "Complexity", a concept to help translate CDK
interfaces appropriately for L1s, and adds this decoration to
ResourceIr. This change also adds a few other bells and whistles
along the way while debugging final output (like AWS::AccountId)
let spec = spec();
let mut resource_instructions = Vec::new();
for resource in parse_tree.resources.resources.iter() {
let resource_spec = spec
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This is more of an optimization question. Does this need to be done for every iteration? Can we save resource_spec after the first time we see the type?

Copy link
Collaborator Author

@iph iph Nov 12, 2021

Choose a reason for hiding this comment

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

I'm a bit confused, as each resource is more than likely unique, and the lookup is O(1) already (as it's backed by a hashmap in spec).

Comment on lines +142 to +152
let opt = match property_rule.get_complexity() {
Complexity::Simple(_) => Option::None,
Complexity::Complex(x) => {
let mut ret =
format!("{}.{}", resource_translator.resource_type, x);
if x == "Tag" {
ret = "Tag".to_string();
}
Option::Some(ret)
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth moving to its own method since it's re-used in two places?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah. I'ma push so we got a working application but will then update to clean this up.

@iph iph merged commit d012882 into main Nov 12, 2021
@iph iph deleted the resource-resolution branch November 12, 2021 20:46
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