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

Update Version regex to support ranges #359

Closed
wants to merge 1 commit into from

Conversation

tmshort
Copy link
Contributor

@tmshort tmshort commented Aug 25, 2023

Fixes #345

Add positive and negative test cases.

Description

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@tmshort tmshort requested a review from a team as a code owner August 25, 2023 17:53
@codecov
Copy link

codecov bot commented Aug 25, 2023

Codecov Report

Merging #359 (8bce29c) into main (2114da6) will increase coverage by 0.64%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #359      +/-   ##
==========================================
+ Coverage   81.46%   82.11%   +0.64%     
==========================================
  Files          21       21              
  Lines         928      928              
==========================================
+ Hits          756      762       +6     
+ Misses        119      116       -3     
+ Partials       53       50       -3     
Flag Coverage Δ
e2e 62.93% <ø> (+0.86%) ⬆️
unit 77.22% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
api/v1alpha1/operator_types.go 100.00% <ø> (ø)

... and 1 file with indirect coverage changes

@@ -69,7 +77,51 @@ var _ = Describe("Operator Spec Validations", func() {
}))

Expect(err).To(HaveOccurred(), "expected error for invalid semver %q", invalidSemver)
Expect(err.Error()).To(ContainSubstring("spec.version in body should match '^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(-(0|[1-9]\\d*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\\.(0|[1-9]\\d*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\\+([0-9a-zA-Z-]+(\\.[0-9a-zA-Z-]+)*))?$'"))
Expect(err.Error()).To(ContainSubstring("spec.version in body should match '^(\\s*(=||!=|>|<|>=|=>|<=|=<|~|~>|\\^)\\s*(v?(0|[1-9]\\d*|[x|X|\\*])(\\.(0|[1-9]\\d*|x|X|\\*]))?(\\.(0|[1-9]\\d*|x|X|\\*))?(-([0-9A-Za-z\\-]+(\\.[0-9A-Za-z\\-]+)*))?(\\+([0-9A-Za-z\\-]+(\\.[0-9A-Za-z\\-]+)*))?)\\s*)((?:\\s+|,\\s*|\\s*\\|\\|\\s*)(=||!=|>|<|>=|=>|<=|=<|~|~>|\\^)\\s*(v?(0|[1-9]\\d*|x|X|\\*])(\\.(0|[1-9]\\d*|x|X|\\*))?(\\.(0|[1-9]\\d*|x|X|\\*]))?(-([0-9A-Za-z\\-]+(\\.[0-9A-Za-z\\-]+)*))?(\\+([0-9A-Za-z\\-]+(\\.[0-9A-Za-z\\-]+)*))?)\\s*)*$'"))
Copy link
Member

Choose a reason for hiding this comment

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

Do we get anything out of including the entire regexp pattern in the assertion? I wonder if we should just check for substring spec.version in body should match?

Copy link
Contributor Author

@tmshort tmshort Aug 28, 2023

Choose a reason for hiding this comment

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

Probably not, there's only one important regex per field; it's the field name that's important.

Copy link
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

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

A few nits. But lgtm!

@tmshort
Copy link
Contributor Author

tmshort commented Aug 28, 2023

@joelanford made requested changes.

Fixes operator-framework#345

Add positive and negative test cases.

Signed-off-by: Todd Short <tshort@redhat.com>
@tmshort tmshort changed the title OPRUN-3033: Update Version regex to support ranges Update Version regex to support ranges Aug 28, 2023
@joelanford
Copy link
Member

joelanford commented Aug 29, 2023

LGTM

However, do we need to keep this PR held open until the backing implementation described in #346 is implemented? I'm guessing if we merge without masterminds in the picture, the result is that masterminds-but-not-blang ranges will result in a reconcile error instead of a validation error?

@tmshort
Copy link
Contributor Author

tmshort commented Aug 29, 2023

However, do we need to keep this PR held open until the backing implementation described in #346 is implemented? I'm guessing if we merge without masterminds in the picture, the result is that masterminds-but-not-blang ranges will result in a reconcile error instead of a validation error?

Yes, but it's necessary to be able to test ("get to") the reconcile code.

@tmshort tmshort mentioned this pull request Aug 29, 2023
4 tasks
@tmshort
Copy link
Contributor Author

tmshort commented Aug 30, 2023

@joelanford since there's a PR up for the MM code changes (updates), do you have any objections to this being merged?

@tmshort
Copy link
Contributor Author

tmshort commented Aug 31, 2023

Closing in favor of #374 (which includes this).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Version Ranges: Update CRD Regex
2 participants