diff --git a/support/kueue.go b/support/kueue.go index e5bd2a5..3b79a25 100644 --- a/support/kueue.go +++ b/support/kueue.go @@ -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() @@ -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{}) diff --git a/support/namespace.go b/support/namespace.go index cba87a3..9397568 100644 --- a/support/namespace.go +++ b/support/namespace.go @@ -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{}) @@ -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{}) diff --git a/support/test.go b/support/test.go index 4a991ab..88d288b 100644 --- a/support/test.go +++ b/support/test.go @@ -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)