@@ -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,21 @@ 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
+ type DefaultLocalQueueOption struct {
68
+ annotations map [string ]string
69
+ }
70
+
71
+ func (d DefaultLocalQueueOption ) applyTo (to * kueuev1beta1.LocalQueue ) error {
72
+ if to .Annotations == nil {
73
+ to .Annotations = make (map [string ]string )
74
+ }
75
+ for key , value := range d .annotations {
76
+ to .Annotations [key ] = value
77
+ }
78
+ return nil
79
+ }
80
+
81
+ func CreateKueueLocalQueue (t Test , namespace string , clusterQueueName string , options ... Option [* kueuev1beta1.LocalQueue ]) * kueuev1beta1.LocalQueue {
69
82
t .T ().Helper ()
70
83
71
84
localQueue := & kueuev1beta1.LocalQueue {
@@ -76,14 +89,18 @@ func CreateKueueLocalQueue(t Test, namespace, clusterQueueName string, annotatio
76
89
ObjectMeta : metav1.ObjectMeta {
77
90
GenerateName : "lq-" ,
78
91
Namespace : namespace ,
79
- Annotations : annotations ,
80
92
},
81
93
Spec : kueuev1beta1.LocalQueueSpec {
82
94
ClusterQueue : kueuev1beta1 .ClusterQueueReference (clusterQueueName ),
83
95
},
84
96
}
85
97
86
- localQueue , err := t .Client ().Kueue ().KueueV1beta1 ().LocalQueues (namespace ).Create (t .Ctx (), localQueue , metav1.CreateOptions {})
98
+ //Apply options
99
+ for _ , opt := range options {
100
+ t .Expect (opt .applyTo (localQueue )).To (gomega .Succeed ())
101
+ }
102
+
103
+ localQueue , err := t .Client ().Kueue ().KueueV1beta1 ().LocalQueues (localQueue .Namespace ).Create (t .Ctx (), localQueue , metav1.CreateOptions {})
87
104
t .Expect (err ).NotTo (gomega .HaveOccurred ())
88
105
t .T ().Logf ("Created Kueue LocalQueue %s/%s successfully" , localQueue .Namespace , localQueue .Name )
89
106
0 commit comments