From ee14f796ed325fd95707e5736e065087fb2dd948 Mon Sep 17 00:00:00 2001 From: Jamie Lennox Date: Mon, 2 Nov 2020 13:44:08 +0700 Subject: [PATCH] :sparkles: 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. --- .../templates/config/controller/controller_suitetest.go | 3 ++- testdata/project-v3-addon/controllers/suite_test.go | 3 ++- testdata/project-v3-multigroup/controllers/crew/suite_test.go | 3 ++- .../project-v3-multigroup/controllers/foo.policy/suite_test.go | 3 ++- .../controllers/sea-creatures/suite_test.go | 3 ++- testdata/project-v3-multigroup/controllers/ship/suite_test.go | 3 ++- testdata/project-v3-multigroup/controllers/suite_test.go | 3 ++- testdata/project-v3/controllers/suite_test.go | 3 ++- 8 files changed, 16 insertions(+), 8 deletions(-) diff --git a/pkg/plugin/v3/scaffolds/internal/templates/config/controller/controller_suitetest.go b/pkg/plugin/v3/scaffolds/internal/templates/config/controller/controller_suitetest.go index e0979d44eac..49a064fdb64 100644 --- a/pkg/plugin/v3/scaffolds/internal/templates/config/controller/controller_suitetest.go +++ b/pkg/plugin/v3/scaffolds/internal/templates/config/controller/controller_suitetest.go @@ -152,7 +152,8 @@ var _ = BeforeSuite(func(done Done) { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join({{ .CRDDirectoryRelativePath }}, "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join({{ .CRDDirectoryRelativePath }}, "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, } var err error diff --git a/testdata/project-v3-addon/controllers/suite_test.go b/testdata/project-v3-addon/controllers/suite_test.go index 3c600ebd2d6..2f3c011762a 100644 --- a/testdata/project-v3-addon/controllers/suite_test.go +++ b/testdata/project-v3-addon/controllers/suite_test.go @@ -54,7 +54,8 @@ var _ = BeforeSuite(func(done Done) { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, } var err error diff --git a/testdata/project-v3-multigroup/controllers/crew/suite_test.go b/testdata/project-v3-multigroup/controllers/crew/suite_test.go index d564b56c321..f1e27dcb9ee 100644 --- a/testdata/project-v3-multigroup/controllers/crew/suite_test.go +++ b/testdata/project-v3-multigroup/controllers/crew/suite_test.go @@ -54,7 +54,8 @@ var _ = BeforeSuite(func(done Done) { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, } var err error diff --git a/testdata/project-v3-multigroup/controllers/foo.policy/suite_test.go b/testdata/project-v3-multigroup/controllers/foo.policy/suite_test.go index 82e3a82065d..853c392c763 100644 --- a/testdata/project-v3-multigroup/controllers/foo.policy/suite_test.go +++ b/testdata/project-v3-multigroup/controllers/foo.policy/suite_test.go @@ -54,7 +54,8 @@ var _ = BeforeSuite(func(done Done) { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, } var err error diff --git a/testdata/project-v3-multigroup/controllers/sea-creatures/suite_test.go b/testdata/project-v3-multigroup/controllers/sea-creatures/suite_test.go index 5331f324876..73db2a51c11 100644 --- a/testdata/project-v3-multigroup/controllers/sea-creatures/suite_test.go +++ b/testdata/project-v3-multigroup/controllers/sea-creatures/suite_test.go @@ -55,7 +55,8 @@ var _ = BeforeSuite(func(done Done) { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, } var err error diff --git a/testdata/project-v3-multigroup/controllers/ship/suite_test.go b/testdata/project-v3-multigroup/controllers/ship/suite_test.go index 8eceb3a92b7..cd28f551b6b 100644 --- a/testdata/project-v3-multigroup/controllers/ship/suite_test.go +++ b/testdata/project-v3-multigroup/controllers/ship/suite_test.go @@ -56,7 +56,8 @@ var _ = BeforeSuite(func(done Done) { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, } var err error diff --git a/testdata/project-v3-multigroup/controllers/suite_test.go b/testdata/project-v3-multigroup/controllers/suite_test.go index 2268aac80a6..bd9ae0f6dc9 100644 --- a/testdata/project-v3-multigroup/controllers/suite_test.go +++ b/testdata/project-v3-multigroup/controllers/suite_test.go @@ -54,7 +54,8 @@ var _ = BeforeSuite(func(done Done) { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, } var err error diff --git a/testdata/project-v3/controllers/suite_test.go b/testdata/project-v3/controllers/suite_test.go index 0e1020cb400..42802da7b66 100644 --- a/testdata/project-v3/controllers/suite_test.go +++ b/testdata/project-v3/controllers/suite_test.go @@ -54,7 +54,8 @@ var _ = BeforeSuite(func(done Done) { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, } var err error