mirror of
https://github.com/YuzuZensai/netbird-kubernetes-operator.git
synced 2026-09-13 10:49:15 +00:00
This changes the default client image from latest to a pinned digest. It also enforces that the default image version tag matches the version of the Netbird dependency. This makes testing a lot easier and also ensures that we wont get untested behavior introduced if the client makes a breaking change. Signed-off-by: Philip Laine <philip.laine@gmail.com>
34 lines
741 B
Go
34 lines
741 B
Go
package version
|
|
|
|
import (
|
|
"os"
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
|
|
"golang.org/x/mod/modfile"
|
|
|
|
"github.com/go-openapi/testify/v2/require"
|
|
)
|
|
|
|
func TestClientImage(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
b, err := os.ReadFile("../../go.mod")
|
|
require.NoError(t, err)
|
|
f, err := modfile.Parse("go.mod", b, nil)
|
|
require.NoError(t, err)
|
|
idx := slices.IndexFunc(f.Require, func(r *modfile.Require) bool {
|
|
return r.Mod.Path == "github.com/netbirdio/netbird"
|
|
})
|
|
require.GreaterT(t, idx, -1)
|
|
modVersion := strings.TrimPrefix(f.Require[idx].Mod.Version, "v")
|
|
|
|
clientImg := ClientImage()
|
|
start := strings.Index(clientImg, ":") + 1
|
|
end := strings.Index(clientImg, "@")
|
|
imgVersion := clientImg[start:end]
|
|
|
|
require.EqualT(t, modVersion, imgVersion)
|
|
}
|