@@ -69,8 +69,7 @@ var _ = Describe("Test", func() {
69
69
})
70
70
71
71
Describe ("InstallCRDs" , func () {
72
- It ("should install the CRDs into the cluster" , func (done Done ) {
73
-
72
+ It ("should install the CRDs into the cluster using directory" , func (done Done ) {
74
73
crds , err = InstallCRDs (env .Config , CRDInstallOptions {
75
74
Paths : []string {filepath .Join ("." , "testdata" )},
76
75
})
@@ -163,6 +162,65 @@ var _ = Describe("Test", func() {
163
162
close (done )
164
163
}, 5 )
165
164
165
+ It ("should install the CRDs into the cluster using file" , func (done Done ) {
166
+ crds , err = InstallCRDs (env .Config , CRDInstallOptions {
167
+ Paths : []string {filepath .Join ("." , "testdata" , "examplecrd2.yaml" )},
168
+ })
169
+ Expect (err ).NotTo (HaveOccurred ())
170
+
171
+ crd := & v1beta1.CustomResourceDefinition {}
172
+ err = c .Get (context .TODO (), types.NamespacedName {Name : "bazs.qux.example.com" }, crd )
173
+ Expect (err ).NotTo (HaveOccurred ())
174
+ Expect (crd .Spec .Names .Kind ).To (Equal ("Baz" ))
175
+
176
+ err = WaitForCRDs (env .Config , []* v1beta1.CustomResourceDefinition {
177
+ {
178
+ Spec : v1beta1.CustomResourceDefinitionSpec {
179
+ Group : "qux.example.com" ,
180
+ Version : "v1beta1" ,
181
+ Names : v1beta1.CustomResourceDefinitionNames {
182
+ Plural : "bazs" ,
183
+ }},
184
+ },
185
+ },
186
+ CRDInstallOptions {MaxTime : 50 * time .Millisecond , PollInterval : 15 * time .Millisecond },
187
+ )
188
+ Expect (err ).NotTo (HaveOccurred ())
189
+
190
+ close (done )
191
+ }, 10 )
192
+
193
+ It ("should filter out already existent CRD" , func (done Done ) {
194
+ crds , err = InstallCRDs (env .Config , CRDInstallOptions {
195
+ Paths : []string {
196
+ filepath .Join ("." , "testdata" ),
197
+ filepath .Join ("." , "testdata" , "examplecrd1.yaml" ),
198
+ },
199
+ })
200
+ Expect (err ).NotTo (HaveOccurred ())
201
+
202
+ crd := & v1beta1.CustomResourceDefinition {}
203
+ err = c .Get (context .TODO (), types.NamespacedName {Name : "foos.bar.example.com" }, crd )
204
+ Expect (err ).NotTo (HaveOccurred ())
205
+ Expect (crd .Spec .Names .Kind ).To (Equal ("Foo" ))
206
+
207
+ err = WaitForCRDs (env .Config , []* v1beta1.CustomResourceDefinition {
208
+ {
209
+ Spec : v1beta1.CustomResourceDefinitionSpec {
210
+ Group : "bar.example.com" ,
211
+ Version : "v1beta1" ,
212
+ Names : v1beta1.CustomResourceDefinitionNames {
213
+ Plural : "foos" ,
214
+ }},
215
+ },
216
+ },
217
+ CRDInstallOptions {MaxTime : 50 * time .Millisecond , PollInterval : 15 * time .Millisecond },
218
+ )
219
+ Expect (err ).NotTo (HaveOccurred ())
220
+
221
+ close (done )
222
+ }, 10 )
223
+
166
224
It ("should not return an not error if the directory doesn't exist" , func (done Done ) {
167
225
crds , err = InstallCRDs (env .Config , CRDInstallOptions {Paths : []string {"fake" }})
168
226
Expect (err ).NotTo (HaveOccurred ())
@@ -177,6 +235,15 @@ var _ = Describe("Test", func() {
177
235
close (done )
178
236
}, 5 )
179
237
238
+ It ("should return an error if the file doesn't exist" , func (done Done ) {
239
+ crds , err = InstallCRDs (env .Config , CRDInstallOptions {Paths : []string {
240
+ filepath .Join ("." , "testdata" , "fake.yaml" )}, ErrorIfPathMissing : true ,
241
+ })
242
+ Expect (err ).To (HaveOccurred ())
243
+
244
+ close (done )
245
+ }, 5 )
246
+
180
247
It ("should return an error if the resource group version isn't found" , func (done Done ) {
181
248
// Wait for a CRD where the Group and Version don't exist
182
249
err := WaitForCRDs (env .Config ,
0 commit comments