Skip to content

Commit ee14f79

Browse files
committed
✨ Use ErrorIfCRDPathMissing in EnvTest
The error message if the path to CRDs is missing is misleading. envtest.Environment has an option to throw a sensible error here if the path is wrong and for kubebuilder it would be likely we always want to upload our CRDs.
1 parent 9c02d55 commit ee14f79

File tree

8 files changed

+16
-8
lines changed

8 files changed

+16
-8
lines changed

pkg/plugin/v3/scaffolds/internal/templates/config/controller/controller_suitetest.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ var _ = BeforeSuite(func(done Done) {
152152
153153
By("bootstrapping test environment")
154154
testEnv = &envtest.Environment{
155-
CRDDirectoryPaths: []string{filepath.Join({{ .CRDDirectoryRelativePath }}, "config", "crd", "bases")},
155+
CRDDirectoryPaths: []string{filepath.Join({{ .CRDDirectoryRelativePath }}, "config", "crd", "bases")},
156+
ErrorIfCRDPathMissing: true,
156157
}
157158
158159
var err error

testdata/project-v3-addon/controllers/suite_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ var _ = BeforeSuite(func(done Done) {
5454

5555
By("bootstrapping test environment")
5656
testEnv = &envtest.Environment{
57-
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
57+
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
58+
ErrorIfCRDPathMissing: true,
5859
}
5960

6061
var err error

testdata/project-v3-multigroup/controllers/crew/suite_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ var _ = BeforeSuite(func(done Done) {
5454

5555
By("bootstrapping test environment")
5656
testEnv = &envtest.Environment{
57-
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
57+
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
58+
ErrorIfCRDPathMissing: true,
5859
}
5960

6061
var err error

testdata/project-v3-multigroup/controllers/foo.policy/suite_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ var _ = BeforeSuite(func(done Done) {
5454

5555
By("bootstrapping test environment")
5656
testEnv = &envtest.Environment{
57-
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
57+
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
58+
ErrorIfCRDPathMissing: true,
5859
}
5960

6061
var err error

testdata/project-v3-multigroup/controllers/sea-creatures/suite_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ var _ = BeforeSuite(func(done Done) {
5555

5656
By("bootstrapping test environment")
5757
testEnv = &envtest.Environment{
58-
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
58+
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
59+
ErrorIfCRDPathMissing: true,
5960
}
6061

6162
var err error

testdata/project-v3-multigroup/controllers/ship/suite_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ var _ = BeforeSuite(func(done Done) {
5656

5757
By("bootstrapping test environment")
5858
testEnv = &envtest.Environment{
59-
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
59+
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
60+
ErrorIfCRDPathMissing: true,
6061
}
6162

6263
var err error

testdata/project-v3-multigroup/controllers/suite_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ var _ = BeforeSuite(func(done Done) {
5454

5555
By("bootstrapping test environment")
5656
testEnv = &envtest.Environment{
57-
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
57+
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
58+
ErrorIfCRDPathMissing: true,
5859
}
5960

6061
var err error

testdata/project-v3/controllers/suite_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ var _ = BeforeSuite(func(done Done) {
5454

5555
By("bootstrapping test environment")
5656
testEnv = &envtest.Environment{
57-
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
57+
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
58+
ErrorIfCRDPathMissing: true,
5859
}
5960

6061
var err error

0 commit comments

Comments
 (0)