8000 Convert conditions to SymPy by kddejong · Pull Request #2624 · aws-cloudformation/cfn-lint · GitHub
[go: up one dir, main page]

Skip to content

Convert conditions to SymPy #2624

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

Merged
merged 11 commits into from
Mar 22, 2023

Conversation

kddejong
Copy link
Contributor
@kddejong kddejong commented Mar 13, 2023

Issue #, if available:

Description of changes:

  • Convert conditions logic to use SymPy to determine scenarios and relationship of conditions

Currently resolving conditions is bottom up. Meaning if we are determining the relationship of two conditions we look at equals and how they overlap. We then create a slew of scenarios based on the different equal scenarios. The more equals the more scenarios, the more unrelated equals the more scenarios. If you have 6 equals in a set of 2 conditions that are unrelated you have 2^6 = 64 scenarios. In the end from all those scenarios you really only have 4 max possibilities.

This new approach works the other way. It uses SymPy to validate if the 4 scenarios are satisfied. To relate equals that have 1 similar parameter (but not 2) we use Not(And(...)) which will not allow each equals to be True at the same time.


Possible remaining issues:

  • A condition that is always True/False. Sometimes a person will codify !Equals ["True", "True"]
  • A condition based on values limited by AllowedValues parameter may never create a scenario. Environments parameter may have AllowedValues: ["prod", "dev"] which means condition IsProduction and IsDevelopment can never both be False

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@kddejong kddejong force-pushed the fix/conditions/v2 branch 3 times, most recently from 609a5a8 to 0af7afd Compare March 13, 2023 19:17
@kddejong kddejong force-pushed the fix/conditions/v2 branch 2 times, most recently from f9e895d to 90c1ef0 Compare March 13, 2023 21:05
@kddejong kddejong changed the title Convert conditions to v2 Convert conditions to z3 Mar 14, 2023
@kddejong kddejong force-pushed the fix/conditions/v2 branch 14 times, most recently from 6ee9a20 to 6ed5991 Compare March 15, 2023 21:13
@kddejong
Copy link
Contributor Author

This will cause issues for installation on Alpine

@kddejong kddejong force-pushed the fix/conditions/v2 branch from 6ed5991 to f46ecf1 Compare March 21, 2023 19:01
@kddejong kddejong changed the title Convert conditions to z3 Convert conditions to SymPy Mar 21, 2023
@kddejong kddejong force-pushed the fix/conditions/v2 branch from f46ecf1 to 8784739 Compare March 21, 2023 19:07
@kddejong kddejong force-pushed the fix/conditions/v2 branch from 8784739 to 4aa9d99 Compare March 21, 2023 20:47
@kddejong kddejong merged commit f186d21 into aws-cloudformation:main Mar 22, 2023
@kddejong kddejong deleted the fix/conditions/v2 branch March 22, 2023 20:33
archlinux-github pushed a commit to archlinux/svntogit-community that referenced this pull request Apr 21, 2023
…tream [1][2]

Also switches from pytest to unittest due to test conflicts (caused by
[3]). Meanwhile, switches to git as a test requires git, and unittest
does not provide a convenient way to ignore a specific test.

[1] aws-cloudformation/cfn-lint#2624
[2] aws-cloudformation/cfn-lint#2643
[3] aws-cloudformation/cfn-lint#2646

git-svn-id: file:///srv/repos/svn-community/svn@1448141 9fca08f4-af9d-4005-b8df-a31f2cc04f65
archlinux-github pushed a commit to archlinux/svntogit-community that referenced this pull request Apr 21, 2023
…tream [1][2]

Also switches from pytest to unittest due to test conflicts (caused by
[3]). Meanwhile, switches to git as a test requires git, and unittest
does not provide a convenient way to ignore a specific test.

[1] aws-cloudformation/cfn-lint#2624
[2] aws-cloudformation/cfn-lint#2643
[3] aws-cloudformation/cfn-lint#2646


git-svn-id: file:///srv/repos/svn-community/svn@1448141 9fca08f4-af9d-4005-b8df-a31f2cc04f65
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
0