Open
Conversation
s4kh
reviewed
Feb 13, 2026
|
|
||
| // https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string | ||
| // Modified to work with semver range operators (>=, >, <, <=) by removing ^ and $ anchors | ||
| var semverRegex = regexp.MustCompile(`(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?`) |
Contributor
There was a problem hiding this comment.
What do you think of this regex https://github.com/grafana/grafana/pull/118090/changes?
Contributor
There was a problem hiding this comment.
isn't it better to use a semver library for this? there are some, more complex ranges out there like this
Contributor
There was a problem hiding this comment.
If we were to validate with semver lib, shouldn't we include it in the metadatavalid check? Remove the grafanaDependency object from the schema so schema validation passes and validate the actual value of grafanaDependency with SemVer lib.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new
grafanadependencyanalyzer that checks that thegrafanaDependencyvalue in plugin.json is valid.For now, the analyzer only has one rule that will result in a warning if the grafanaDependency has no pre-release value:
12.4.012.4.0-0This ensures the plugin can be installed in Grafana Cloud.
Since this is usually only an issue with Grafana Labs plugins, the rule is evaluated only for Grafana Labs plugins for now.