@@ -18,7 +18,6 @@ package support
18
18
19
19
import (
20
20
"github.com/onsi/gomega"
21
-
22
21
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23
22
kueuev1beta1 "sigs.k8s.io/kueue/apis/kueue/v1beta1"
24
23
)
@@ -65,7 +64,25 @@ func CreateKueueClusterQueue(t Test, clusterQueueSpec kueuev1beta1.ClusterQueueS
65
64
return clusterQueue
66
65
}
67
66
68
- func CreateKueueLocalQueue (t Test , namespace , clusterQueueName string , annotations map [string ]string ) * kueuev1beta1.LocalQueue {
67
+ func LocalQueueWithNamespace (namespace string ) LocalQueueOption {
68
+ return func (lq * kueuev1beta1.LocalQueue ) {
69
+ lq .ObjectMeta .Namespace = namespace
70
+ }
71
+ }
72
+
73
+ func LocalQueuewithClusterQueue (clusterQueueName string ) LocalQueueOption {
74
+ return func (lq * kueuev1beta1.LocalQueue ) {
75
+ lq .Spec .ClusterQueue = kueuev1beta1 .ClusterQueueReference (clusterQueueName )
76
+ }
77
+ }
78
+
79
+ func LocalQueuewithAnnotations (annotations map [string ]string ) LocalQueueOption {
80
+ return func (lq * kueuev1beta1.LocalQueue ) {
81
+ lq .ObjectMeta .Annotations = annotations
82
+ }
83
+ }
84
+
85
+ func CreateKueueLocalQueue (t Test , options ... LocalQueueOption ) * kueuev1beta1.LocalQueue {
69
86
t .T ().Helper ()
70
87
71
88
localQueue := & kueuev1beta1.LocalQueue {
@@ -75,15 +92,16 @@ func CreateKueueLocalQueue(t Test, namespace, clusterQueueName string, annotatio
75
92
},
76
93
ObjectMeta : metav1.ObjectMeta {
77
94
GenerateName : "lq-" ,
78
- Namespace : namespace ,
79
- Annotations : annotations ,
80
- },
81
- Spec : kueuev1beta1.LocalQueueSpec {
82
- ClusterQueue : kueuev1beta1 .ClusterQueueReference (clusterQueueName ),
83
95
},
96
+ Spec : kueuev1beta1.LocalQueueSpec {},
97
+ }
98
+
99
+ //Apply options
100
+ for _ , opt := range options {
101
+ opt (localQueue )
84
102
}
85
103
86
- localQueue , err := t .Client ().Kueue ().KueueV1beta1 ().LocalQueues (namespace ).Create (t .Ctx (), localQueue , metav1.CreateOptions {})
104
+ localQueue , err := t .Client ().Kueue ().KueueV1beta1 ().LocalQueues (localQueue . Namespace ).Create (t .Ctx (), localQueue , metav1.CreateOptions {})
87
105
t .Expect (err ).NotTo (gomega .HaveOccurred ())
88
106
t .T ().Logf ("Created Kueue LocalQueue %s/%s successfully" , localQueue .Namespace , localQueue .Name )
89
107
0 commit comments