@@ -60,7 +60,7 @@ var _ = Describe("CRDUtil", func() {
6060 Describe ("ProcessCRDsWithConfig" , func () {
6161 It ("should create CRDs from a directory" , func () {
6262 // Apply CRDs from the crds directory
63- err := ProcessCRDsWithConfig (ctx , cfg , [] string { crdsDir }, CRDOperationApply )
63+ err := ProcessCRDsWithConfig (ctx , cfg , CRDOperationApply , crdsDir )
6464 Expect (err ).NotTo (HaveOccurred ())
6565
6666 // Verify CRDs were created
@@ -77,7 +77,7 @@ var _ = Describe("CRDUtil", func() {
7777
7878 It ("should update existing CRDs when applying updated versions" , func () {
7979 // First, create the initial CRDs
80- err := ProcessCRDsWithConfig (ctx , cfg , [] string { crdsDir }, CRDOperationApply )
80+ err := ProcessCRDsWithConfig (ctx , cfg , CRDOperationApply , crdsDir )
8181 Expect (err ).NotTo (HaveOccurred ())
8282
8383 // Get the initial resource versions
@@ -90,7 +90,7 @@ var _ = Describe("CRDUtil", func() {
9090 initialBarResourceVersion := initialBar .ResourceVersion
9191
9292 // Now apply the updated CRDs
93- err = ProcessCRDsWithConfig (ctx , cfg , [] string { updatedCRDsDir }, CRDOperationApply )
93+ err = ProcessCRDsWithConfig (ctx , cfg , CRDOperationApply , updatedCRDsDir )
9494 Expect (err ).NotTo (HaveOccurred ())
9595
9696 // Verify CRDs were updated by checking resource version changed
@@ -105,11 +105,11 @@ var _ = Describe("CRDUtil", func() {
105105
106106 It ("should delete CRDs from a directory" , func () {
107107 // Apply CRDs
108- err := ProcessCRDsWithConfig (ctx , cfg , [] string { crdsDir }, CRDOperationApply )
108+ err := ProcessCRDsWithConfig (ctx , cfg , CRDOperationApply , crdsDir )
109109 Expect (err ).NotTo (HaveOccurred ())
110110
111111 // Delete CRDs
112- err = ProcessCRDsWithConfig (ctx , cfg , [] string { crdsDir }, CRDOperationDelete )
112+ err = ProcessCRDsWithConfig (ctx , cfg , CRDOperationDelete , crdsDir )
113113 Expect (err ).NotTo (HaveOccurred ())
114114
115115 // Verify CRDs were deleted
@@ -126,21 +126,21 @@ var _ = Describe("CRDUtil", func() {
126126
127127 It ("should handle apply and delete operations idempotently" , func () {
128128 // Apply twice
129- err := ProcessCRDsWithConfig (ctx , cfg , [] string { crdsDir }, CRDOperationApply )
129+ err := ProcessCRDsWithConfig (ctx , cfg , CRDOperationApply , crdsDir )
130130 Expect (err ).NotTo (HaveOccurred ())
131131
132- err = ProcessCRDsWithConfig (ctx , cfg , [] string { crdsDir }, CRDOperationApply )
132+ err = ProcessCRDsWithConfig (ctx , cfg , CRDOperationApply , crdsDir )
133133 Expect (err ).NotTo (HaveOccurred ())
134134
135135 // Verify CRDs exist
136136 _ , err = testCRDClient .Get (ctx , "foos.example.com" , metav1.GetOptions {})
137137 Expect (err ).NotTo (HaveOccurred ())
138138
139139 // Delete twice
140- err = ProcessCRDsWithConfig (ctx , cfg , [] string { crdsDir }, CRDOperationDelete )
140+ err = ProcessCRDsWithConfig (ctx , cfg , CRDOperationDelete , crdsDir )
141141 Expect (err ).NotTo (HaveOccurred ())
142142
143- err = ProcessCRDsWithConfig (ctx , cfg , [] string { crdsDir }, CRDOperationDelete )
143+ err = ProcessCRDsWithConfig (ctx , cfg , CRDOperationDelete , crdsDir )
144144 Expect (err ).NotTo (HaveOccurred ())
145145
146146 // Verify CRDs are deleted
@@ -151,7 +151,7 @@ var _ = Describe("CRDUtil", func() {
151151 })
152152
153153 It ("should recursively walk directories and apply CRDs from nested subdirectories" , func () {
154- err := ProcessCRDsWithConfig (ctx , cfg , [] string { nestedDir }, CRDOperationApply )
154+ err := ProcessCRDsWithConfig (ctx , cfg , CRDOperationApply , nestedDir )
155155 Expect (err ).NotTo (HaveOccurred ())
156156
157157 // Verify CRDs were created
@@ -166,7 +166,7 @@ var _ = Describe("CRDUtil", func() {
166166 Expect (crd2 .ResourceVersion ).NotTo (BeEmpty ())
167167
168168 // Clean up
169- err = ProcessCRDsWithConfig (ctx , cfg , [] string { nestedDir }, CRDOperationDelete )
169+ err = ProcessCRDsWithConfig (ctx , cfg , CRDOperationDelete , nestedDir )
170170 Expect (err ).NotTo (HaveOccurred ())
171171
172172 // Verify deletion
@@ -184,7 +184,7 @@ var _ = Describe("CRDUtil", func() {
184184 It ("should accept individual file paths and apply CRDs" , func () {
185185 // Apply a single CRD file
186186 singleFilePath := filepath .Join (crdsDir , "test-crds.yaml" )
187- err := ProcessCRDsWithConfig (ctx , cfg , [] string { singleFilePath }, CRDOperationApply )
187+ err := ProcessCRDsWithConfig (ctx , cfg , CRDOperationApply , singleFilePath )
188188 Expect (err ).NotTo (HaveOccurred ())
189189
190190 // Verify CRDs were created
@@ -197,7 +197,7 @@ var _ = Describe("CRDUtil", func() {
197197 Expect (crd2 .Name ).To (Equal ("bars.example.com" ))
198198
199199 // Clean up using the same file path
200- err = ProcessCRDsWithConfig (ctx , cfg , [] string { singleFilePath }, CRDOperationDelete )
200+ err = ProcessCRDsWithConfig (ctx , cfg , CRDOperationDelete , singleFilePath )
201201 Expect (err ).NotTo (HaveOccurred ())
202202
203203 // Verify deletion
@@ -211,5 +211,54 @@ var _ = Describe("CRDUtil", func() {
211211 return apierrors .IsNotFound (err )
212212 }, eventuallyTimeout ).Should (BeTrue ())
213213 })
214+
215+ It ("should accept multiple directories as variadic arguments" , func () {
216+ // Apply CRDs from multiple directories at once
217+ err := ProcessCRDsWithConfig (ctx , cfg , CRDOperationApply , crdsDir , nestedDir )
218+ Expect (err ).NotTo (HaveOccurred ())
219+
220+ // Verify CRDs from first directory were created
221+ crd1 , err := testCRDClient .Get (ctx , "foos.example.com" , metav1.GetOptions {})
222+ Expect (err ).NotTo (HaveOccurred ())
223+ Expect (crd1 .Name ).To (Equal ("foos.example.com" ))
224+
225+ crd2 , err := testCRDClient .Get (ctx , "bars.example.com" , metav1.GetOptions {})
226+ Expect (err ).NotTo (HaveOccurred ())
227+ Expect (crd2 .Name ).To (Equal ("bars.example.com" ))
228+
229+ // Verify CRDs from nested directory were created
230+ crd3 , err := testCRDClient .Get (ctx , "nestedfoos.example.com" , metav1.GetOptions {})
231+ Expect (err ).NotTo (HaveOccurred ())
232+ Expect (crd3 .Name ).To (Equal ("nestedfoos.example.com" ))
233+
234+ crd4 , err := testCRDClient .Get (ctx , "nestedbars.example.com" , metav1.GetOptions {})
235+ Expect (err ).NotTo (HaveOccurred ())
236+ Expect (crd4 .Name ).To (Equal ("nestedbars.example.com" ))
237+
238+ // Clean up using the same multiple directories
239+ err = ProcessCRDsWithConfig (ctx , cfg , CRDOperationDelete , crdsDir , nestedDir )
240+ Expect (err ).NotTo (HaveOccurred ())
241+
242+ // Verify all CRDs were deleted
243+ Eventually (func () bool {
244+ _ , err := testCRDClient .Get (ctx , "foos.example.com" , metav1.GetOptions {})
245+ return apierrors .IsNotFound (err )
246+ }, eventuallyTimeout ).Should (BeTrue ())
247+
248+ Eventually (func () bool {
249+ _ , err := testCRDClient .Get (ctx , "bars.example.com" , metav1.GetOptions {})
250+ return apierrors .IsNotFound (err )
251+ }, eventuallyTimeout ).Should (BeTrue ())
252+
253+ Eventually (func () bool {
254+ _ , err := testCRDClient .Get (ctx , "nestedfoos.example.com" , metav1.GetOptions {})
255+ return apierrors .IsNotFound (err )
256+ }, eventuallyTimeout ).Should (BeTrue ())
257+
258+ Eventually (func () bool {
259+ _ , err := testCRDClient .Get (ctx , "nestedbars.example.com" , metav1.GetOptions {})
260+ return apierrors .IsNotFound (err )
261+ }, eventuallyTimeout ).Should (BeTrue ())
262+ })
214263 })
215264})
0 commit comments