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

Add Remap function for comparing semantic versions #143

Open
lucperkins opened this issue Dec 15, 2020 · 0 comments
Open

Add Remap function for comparing semantic versions #143

lucperkins opened this issue Dec 15, 2020 · 0 comments
Labels
type: enhancement A value-adding code change that enhances its existing functionality vrl: stdlib Changes to the standard library

Comments

@lucperkins
Copy link
Contributor

lucperkins commented Dec 15, 2020

I'm not sure I can think of an absolute must-have use case, but we should enable users to compare versions of things, like so:

semver::compare(v1, v2)

This idea is inspired by Rego's semver.compare function, which returns three possible integers:

  • 1 if v1 is later than v2
  • 0 if the two versions are the same
  • -1 if v1 is earler than v2

This would allow for constructing Boolean expressions:

if (semver::compare(.version, "1.0") == -1) {
    .deprecated = true
}

I'm open to other interfaces for this, for example:

semver::compare(v1, v2, expect = ["gt"]) // Boolean

semver::parse(v1) > semver::parse(v2)
@lucperkins lucperkins added the type: enhancement A value-adding code change that enhances its existing functionality label Dec 15, 2020
@lucperkins lucperkins self-assigned this Dec 15, 2020
@JeanMertz JeanMertz added the vrl: stdlib Changes to the standard library label Jun 8, 2022
@fuchsnj fuchsnj transferred this issue from vectordotdev/vector Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A value-adding code change that enhances its existing functionality vrl: stdlib Changes to the standard library
Projects
None yet
Development

No branches or pull requests

2 participants