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

aws: Improve platform lookup handling #757

Conversation

bwbarrett
Copy link
Contributor

This was originally just a patch to add unit tests for the regex handling, but also tagged on a commit to change the p5 match to match all p5 or later platforms, because it's a reasonable example. Ended up splitting the name into a name and regex, otherwise every time you changed the regex (like the p5 extension), you had to update the unit test, and that was just annoying. Especially during the inevitable messing up regex cycle.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Refactor the get_platform_data() call to expose the critical pieces
to allow for unit testing.

Signed-off-by: Brian Barrett <[email protected]>
Writing regexes is hard.  Making sure your regexes work without a
test is harder.  So we should have a unit test for the code
to do instance type -> config block lookup.

Signed-off-by: Brian Barrett <[email protected]>
@bwbarrett bwbarrett requested a review from a team as a code owner December 20, 2024 05:21
mozarhua
mozarhua previously approved these changes Dec 20, 2024
@a-szegel
Copy link
Contributor

bot:aws:retest

include/platform-aws.h Outdated Show resolved Hide resolved
aws-nslick
aws-nslick previously approved these changes Dec 21, 2024
Copy link
Contributor

@aws-nslick aws-nslick left a comment

Choose a reason for hiding this comment

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

nice!

Add an explicit (optional) field for the platform regex, and make the
name an id rather than a regex.  This means that we can change the
regex without having to update all the unit tests to match.

Signed-off-by: Brian Barrett <[email protected]>
Add a regex to match all instances p5 or later in the p-series.  Moved
to extended regex compilation to make the regex slightly more sane.

Signed-off-by: Brian Barrett <[email protected]>
@bwbarrett bwbarrett dismissed stale reviews from aws-nslick and mozarhua via 0fea146 December 21, 2024 00:40
@bwbarrett bwbarrett force-pushed the cleanup/platform-regex-life-is-better-with-unit-tests branch from 6d676a7 to 0fea146 Compare December 21, 2024 00:40
@bwbarrett bwbarrett merged commit b7480ed into aws:master Jan 6, 2025
23 checks passed
@bwbarrett bwbarrett deleted the cleanup/platform-regex-life-is-better-with-unit-tests branch January 6, 2025 17:34
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.

5 participants