Add build version to NetBird client user agent. (#248)

This also fix the runtime import aliases to avoid conflicts with stdlib
runtime.
This commit is contained in:
Philip Laine
2026-05-13 12:43:46 +02:00
committed by GitHub
parent 0ef20e5dc3
commit 360ef52aa3
4 changed files with 45 additions and 14 deletions
+30
View File
@@ -2,6 +2,36 @@
package version
import (
"runtime/debug"
)
func ClientImage() string {
return "ghcr.io/netbirdio/netbird:0.70.4@sha256:3a28b9f7f32875c6a35f952ca7e9cb688b1e610365365ff55f6e790da3950f55"
}
func BuildVersion() string {
bi, ok := debug.ReadBuildInfo()
if !ok {
return "unknown"
}
modified := true
for _, s := range bi.Settings {
if s.Key == "vcs.modified" {
if s.Value == "false" {
modified = false
}
break
}
}
develVersion := "devel"
if modified {
return develVersion
}
if bi.Main.Version == "" {
return develVersion
}
return bi.Main.Version
}
+2 -2
View File
@@ -16,7 +16,7 @@ import (
. "github.com/onsi/gomega"
admissionv1 "k8s.io/api/admission/v1"
corev1 "k8s.io/api/core/v1"
apimachineryruntime "k8s.io/apimachinery/pkg/runtime"
kruntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/rest"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -53,7 +53,7 @@ var _ = BeforeSuite(func() {
ctx, cancel = context.WithCancel(context.TODO())
var err error
scheme := apimachineryruntime.NewScheme()
scheme := kruntime.NewScheme()
err = corev1.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())