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

Fix semver validation #590

Merged
merged 3 commits into from
Sep 11, 2023
Merged

Fix semver validation #590

merged 3 commits into from
Sep 11, 2023

Conversation

riddhi89
Copy link
Contributor

The existing validation prevented from specifying a pre-release version which is also a valid semver.
The PR changes it to utilize the go-version library helper which follows the SemVer spec.

The existing validation prevented from specifying a pre-release version which
is a valid semver.
The PR changes it to utilize the go-version library helper which follows the
SemVer spec.
Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -95,8 +96,7 @@ func validateStringInSlice(valid []string, ignoreCase bool) schema.SchemaValidat
// validateSemVer ensures a specified string is a SemVer.
func validateSemVer(v interface{}, path cty.Path) diag.Diagnostics {
var diagnostics diag.Diagnostics

if !regexp.MustCompile(`^v?\d+.\d+.\d+$`).MatchString(v.(string)) {
if _, err := version.NewSemver(v.(string)); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good to me. Given that go-version is used in the provider but not for the validation I want to confirm before merging that the consul resource is okay with a user specifying a pre-release version. In other words, is there a reason why the original implementor chose only to support official release versions?

Copy link
Contributor

Choose a reason for hiding this comment

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

Disregard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want to confirm before merging that the consul resource is okay with a user specifying a pre-release version

Might have been a miss. But we do publicly release pre-release versions of our products (can be found here). On the Consul side, we optionally enable testing out these pre-release versions on HCP for certain customers to unblock their testing/validation processes.

@nywilken nywilken merged commit a14ffbf into main Sep 11, 2023
@nywilken nywilken deleted the fix-validate-semvar branch September 11, 2023 18:23
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