Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2ab1556

Browse files
committedOct 9, 2024·
Make Option and ErrorOption public
1 parent 47f906f commit 2ab1556

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed
 

‎support/kueue.go

+3-8
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,13 @@ func CreateKueueClusterQueue(t Test, clusterQueueSpec kueuev1beta1.ClusterQueueS
6565
return clusterQueue
6666
}
6767

68-
var AsDefaultQueue = defaultLocalQueueOption{}
69-
70-
type defaultLocalQueueOption struct {
71-
}
72-
73-
func (d defaultLocalQueueOption) applyTo(to *kueuev1beta1.LocalQueue) error {
68+
var AsDefaultQueue = ErrorOption[*kueuev1beta1.LocalQueue](func(to *kueuev1beta1.LocalQueue) error {
7469
if to.Annotations == nil {
7570
to.Annotations = make(map[string]string)
7671
}
7772
to.Annotations["kueue.x-k8s.io/default-queue"] = "true"
7873
return nil
79-
}
74+
})
8075

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

9893
//Apply options
9994
for _, opt := range options {
100-
t.Expect(opt.applyTo(localQueue)).To(gomega.Succeed())
95+
t.Expect(opt.ApplyTo(localQueue)).To(gomega.Succeed())
10196
}
10297

10398
localQueue, err := t.Client().Kueue().KueueV1beta1().LocalQueues(localQueue.Namespace).Create(t.Ctx(), localQueue, metav1.CreateOptions{})

‎support/namespace.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func createTestNamespace(t Test, options ...Option[*corev1.Namespace]) *corev1.N
3838
}
3939

4040
for _, option := range options {
41-
t.Expect(option.applyTo(namespace)).To(gomega.Succeed())
41+
t.Expect(option.ApplyTo(namespace)).To(gomega.Succeed())
4242
}
4343

4444
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
6969
}
7070

7171
for _, option := range options {
72-
t.Expect(option.applyTo(namespace)).To(gomega.Succeed())
72+
t.Expect(option.ApplyTo(namespace)).To(gomega.Succeed())
7373
}
7474

7575
namespace, err := t.Client().Core().CoreV1().Namespaces().Create(t.Ctx(), namespace, metav1.CreateOptions{})

‎support/test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@ type Test interface {
4242
}
4343

4444
type Option[T any] interface {
45-
applyTo(to T) error
45+
ApplyTo(to T) error
4646
}
4747

48-
type errorOption[T any] func(to T) error
48+
type ErrorOption[T any] func(to T) error
4949

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

56-
var _ Option[any] = errorOption[any](nil)
56+
var _ Option[any] = ErrorOption[any](nil)
5757

5858
func With(t *testing.T) Test {
5959
return WithConfig(t, nil)

0 commit comments

Comments
 (0)
Please sign in to comment.