Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/server/primarykinds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for clarification: we determine which kinds to use at runtime?

Copy link
Copy Markdown
Contributor Author

@enekofb enekofb Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes they are resolved at startup here and here2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a bit of an anti-pattern...


// 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.
Expand Down
16 changes: 15 additions & 1 deletion core/server/primarykinds_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package server

import (
. "github.com/onsi/gomega"
"reflect"
"testing"

. "github.com/onsi/gomega"

"k8s.io/apimachinery/pkg/runtime/schema"
)

Expand All @@ -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
Expand Down Expand Up @@ -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"}))
})
}