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

chore: remove dependency on serde_json #102

Merged
merged 3 commits into from
Apr 20, 2023
Merged

chore: remove dependency on serde_json #102

merged 3 commits into from
Apr 20, 2023

Conversation

RomainMuller
Copy link
Contributor

Since all valid JSON is also valid YAML, the serde_yaml library can be used to parse all kinds of input, without requiring user selection. Also changes the initial internal representation to be a YAML value instead of a JSON value, which is a little more expressive (although it's not clear whether this is a good thing in this particular case; but at least it reduces the dependency surface).

@iph
Copy link
Collaborator

iph commented Apr 17, 2023

huh...didn't think about it that yaml is a superset (structure-wise). So true.

Copy link
Collaborator

@iph iph left a comment

Choose a reason for hiding this comment

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

Most of my stuff are nitpicks, but dunno about removing !Ref/!Condition. Take a look at those fellas.

Cargo.toml Outdated Show resolved Hide resolved
)
.get_matches();

if matches.is_present("inputFormat") {
eprintln!("--inputFormat (-f) is a no-op and will be removed in a future version. All input is treated as YAML");
eprintln!("as it is a strict super-set of JSON (all valid JSON is valid YAML).");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note: YAML was added last month, and isn't actually published in a new release. Not sure we need the deprecation notice, but it is a good exercise.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this works for both json and yaml if I'm not mistaken

Comment on lines 176 to 186
"!Condition" | "Condition" => {
Some("Condition") => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The sample here says that !Condition is real:

  CreateBucketPolicy: !And 
    - !Condition IsProduction
    - !Condition CreateBucket

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html#conditions-section-structure-examples

Comment on lines 473 to 480
"!Ref" | "Ref" => {
Some("Ref") => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes... I made a boo-boo here... Because I changed approaches in the middle of doing this and since those aren't Fn:: intrinsics I forgot about them...

Comment on lines 196 to 197
}
"!Ref" | "Ref" => {
Some("Ref") => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@HBobertz
Copy link
Collaborator

had to fix some merge conflicts so I messed with the branch a bit. All good now

@HBobertz HBobertz merged commit cc91e5e into main Apr 20, 2023
@HBobertz HBobertz deleted the rmuller/only-yaml branch April 20, 2023 17:58
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.

3 participants