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
11 changes: 3 additions & 8 deletions support/kueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,13 @@ func CreateKueueClusterQueue(t Test, clusterQueueSpec kueuev1beta1.ClusterQueueS
return clusterQueue
}

var AsDefaultQueue = defaultLocalQueueOption{}

type defaultLocalQueueOption struct {
}

func (d defaultLocalQueueOption) applyTo(to *kueuev1beta1.LocalQueue) error {
var AsDefaultQueue = ErrorOption[*kueuev1beta1.LocalQueue](func(to *kueuev1beta1.LocalQueue) error {
if to.Annotations == nil {
to.Annotations = make(map[string]string)
}
to.Annotations["kueue.x-k8s.io/default-queue"] = "true"
return nil
}
})

func CreateKueueLocalQueue(t Test, namespace string, clusterQueueName string, options ...Option[*kueuev1beta1.LocalQueue]) *kueuev1beta1.LocalQueue {
t.T().Helper()
Expand All @@ -97,7 +92,7 @@ func CreateKueueLocalQueue(t Test, namespace string, clusterQueueName string, op

//Apply options
for _, opt := range options {
t.Expect(opt.applyTo(localQueue)).To(gomega.Succeed())
t.Expect(opt.ApplyTo(localQueue)).To(gomega.Succeed())
}

localQueue, err := t.Client().Kueue().KueueV1beta1().LocalQueues(localQueue.Namespace).Create(t.Ctx(), localQueue, metav1.CreateOptions{})
Expand Down
4 changes: 2 additions & 2 deletions support/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func createTestNamespace(t Test, options ...Option[*corev1.Namespace]) *corev1.N
}

for _, option := range options {
t.Expect(option.applyTo(namespace)).To(gomega.Succeed())
t.Expect(option.ApplyTo(namespace)).To(gomega.Succeed())
}

namespace, err := t.Client().Core().CoreV1().Namespaces().Create(t.Ctx(), namespace, metav1.CreateOptions{})
Expand Down Expand Up @@ -69,7 +69,7 @@ func CreateTestNamespaceWithName(t Test, namespaceName string, options ...Option
}

for _, option := range options {
t.Expect(option.applyTo(namespace)).To(gomega.Succeed())
t.Expect(option.ApplyTo(namespace)).To(gomega.Succeed())
}

namespace, err := t.Client().Core().CoreV1().Namespaces().Create(t.Ctx(), namespace, metav1.CreateOptions{})
Expand Down
8 changes: 4 additions & 4 deletions support/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ type Test interface {
}

type Option[T any] interface {
applyTo(to T) error
ApplyTo(to T) error
}

type errorOption[T any] func(to T) error
type ErrorOption[T any] func(to T) error

// nolint: unused
// To be removed when the false-positivity is fixed.
func (o errorOption[T]) applyTo(to T) error {
func (o ErrorOption[T]) ApplyTo(to T) error {
return o(to)
}

var _ Option[any] = errorOption[any](nil)
var _ Option[any] = ErrorOption[any](nil)

func With(t *testing.T) Test {
return WithConfig(t, nil)
Expand Down