@@ -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
+ type DefaultLocalQueueOption struct {
68
+ namespace string
69
+ clusterQueueName string
70
+ annotations map [string ]string
71
+ }
72
+
73
+ func (d DefaultLocalQueueOption ) applyTo (to * kueuev1beta1.LocalQueue ) error {
74
+ to .Namespace = d .namespace
75
+ to .Spec .ClusterQueue = kueuev1beta1 .ClusterQueueReference (d .clusterQueueName )
76
+ if to .Annotations == nil {
77
+ to .Annotations = make (map [string ]string )
78
+ }
79
+ for key , value := range d .annotations {
80
+ to .Annotations [key ] = value
81
+ }
82
+ return nil
83
+ }
84
+
85
+ func CreateKueueLocalQueue (t Test , options ... Option [* kueuev1beta1.LocalQueue ]) * 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
+ t .Expect (opt .applyTo (localQueue )).To (gomega .Succeed ())
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