mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-17 20:19:55 +00:00
* Refactor to use a common checker for development version
* Adds commit sha to development version for cobra command only
Leave dashboard unaffected
* Adjust for "v0.31.1-dev" test case
which must be considered pre-release
* Drop synthetic "dev"/"0.50.0-dev" firewall feature-gate fixtures
These test cases encoded the loose strings.Contains(v, "dev")
semantics inherited from peerSupportedFirewallFeatures, but
NetbirdVersion() never produces those values — only the literal
"development" (and now "development-<sha>[-dirty]") ever flows
through the wire. The agent owns the semantics of an ephemeral
development build, so the tests should exercise the strings we
actually emit.
Replaced with development, development-<sha> and
development-<sha>-dirty cases that match the HasPrefix("development")
predicate introduced upstream.
* Remove unexistent tests on wire format
The sha / dirty flag are added only when the CLI asks the version.
Account versions is unaffacted and can only strictly match "development"
* Adds tests for IsDevelopmentVersion
44 lines
929 B
Go
44 lines
929 B
Go
package lazyconn
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/hashicorp/go-version"
|
|
|
|
nbversion "github.com/netbirdio/netbird/version"
|
|
)
|
|
|
|
var (
|
|
minVersion = version.Must(version.NewVersion("0.45.0"))
|
|
)
|
|
|
|
func IsSupported(agentVersion string) bool {
|
|
if nbversion.IsDevelopmentVersion(agentVersion) {
|
|
return true
|
|
}
|
|
|
|
// filter out versions like this: a6c5960, a7d5c522, d47be154
|
|
if !strings.Contains(agentVersion, ".") {
|
|
return false
|
|
}
|
|
|
|
normalizedVersion := normalizeVersion(agentVersion)
|
|
inputVer, err := version.NewVersion(normalizedVersion)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
|
|
return inputVer.GreaterThanOrEqual(minVersion)
|
|
}
|
|
|
|
func normalizeVersion(version string) string {
|
|
// Remove prefixes like 'v' or 'a'
|
|
if len(version) > 0 && (version[0] == 'v' || version[0] == 'a') {
|
|
version = version[1:]
|
|
}
|
|
|
|
// Remove any suffixes like '-dirty', '-dev', '-SNAPSHOT', etc.
|
|
parts := strings.Split(version, "-")
|
|
return parts[0]
|
|
}
|