diff --git a/core/server/primarykinds.go b/core/server/primarykinds.go index aed9a22e15..ef508a6ef0 100644 --- a/core/server/primarykinds.go +++ b/core/server/primarykinds.go @@ -25,7 +25,7 @@ const ( // It's multiplied with the digit following the "beta" suffix. // Beta versions are more stable than alpha versions but might still contain bugs. // They are given a higher weight than alpha versions. - betaWeight = 500 + betaWeight = 50 // stableWeight is a weight assigned to stable versions (those without an "alpha" or "beta" suffix). // Stable versions are the final, production-ready releases of software, hence they have the highest weight. diff --git a/core/server/primarykinds_test.go b/core/server/primarykinds_test.go index 2bef7b63e2..f0cde3fecb 100644 --- a/core/server/primarykinds_test.go +++ b/core/server/primarykinds_test.go @@ -1,10 +1,11 @@ package server import ( - . "github.com/onsi/gomega" "reflect" "testing" + . "github.com/onsi/gomega" + "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -16,8 +17,11 @@ func TestVersionRank(t *testing.T) { gvk2 schema.GroupVersionKind expected int }{ + {schema.GroupVersionKind{Version: "v1"}, schema.GroupVersionKind{Version: "v1alpha1"}, 1}, {schema.GroupVersionKind{Version: "v1"}, schema.GroupVersionKind{Version: "v1beta1"}, 1}, + {schema.GroupVersionKind{Version: "v1"}, schema.GroupVersionKind{Version: "v1beta2"}, 1}, + {schema.GroupVersionKind{Version: "v1"}, schema.GroupVersionKind{Version: "v1beta10"}, 1}, {schema.GroupVersionKind{Version: "v2"}, schema.GroupVersionKind{Version: "v1"}, 1}, {schema.GroupVersionKind{Version: "v2beta1"}, schema.GroupVersionKind{Version: "v1beta1"}, 1}, // Additional test cases @@ -79,3 +83,13 @@ func TestGetPrimaryKinds(t *testing.T) { g.Expect(primaryKinds.kinds["Node"]).To(Equal(schema.GroupVersionKind{Group: "core", Version: "v1beta2", Kind: "Node"})) }) } + +func TestDefaultPrimaryKinds(t *testing.T) { + g := NewGomegaWithT(t) + primaryKinds, err := DefaultPrimaryKinds() + g.Expect(err).NotTo(HaveOccurred()) + + t.Run("should return v1 GitRepository", func(t *testing.T) { + g.Expect(primaryKinds.kinds["GitRepository"]).To(Equal(schema.GroupVersionKind{Group: "source.toolkit.fluxcd.io", Version: "v1", Kind: "GitRepository"})) + }) +}