diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook_suitetest.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook_suitetest.go index 95086eccbd3..e303acec5cf 100644 --- a/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook_suitetest.go +++ b/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook_suitetest.go @@ -17,6 +17,9 @@ type WebhookSuite struct { file.BoilerplateMixin file.ResourceMixin + // todo: currently is not possible to know if an API was or not scaffolded. We can fix it when #1826 be addressed + WireResource bool + // BaseDirectoryRelativePath define the Path for the base directory when it is multigroup BaseDirectoryRelativePath string } @@ -163,7 +166,8 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join({{ .BaseDirectoryRelativePath }}, "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join({{ .BaseDirectoryRelativePath }}, "config", "crd", "bases")}, + ErrorIfCRDPathMissing: {{ .WireResource }}, WebhookInstallOptions: envtest.WebhookInstallOptions{ Paths: []string{filepath.Join({{ .BaseDirectoryRelativePath }}, "config", "webhook")}, }, diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/controllers/controller_suitetest.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/controllers/controller_suitetest.go index 2ac30c809e3..c61fe4e9dba 100644 --- a/pkg/plugins/golang/v3/scaffolds/internal/templates/controllers/controller_suitetest.go +++ b/pkg/plugins/golang/v3/scaffolds/internal/templates/controllers/controller_suitetest.go @@ -159,7 +159,8 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join({{ .CRDDirectoryRelativePath }}, "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join({{ .CRDDirectoryRelativePath }}, "config", "crd", "bases")}, + ErrorIfCRDPathMissing: {{ .WireResource }}, } cfg, err := testEnv.Start() diff --git a/testdata/project-v3-addon/controllers/suite_test.go b/testdata/project-v3-addon/controllers/suite_test.go index 12204ab2d17..73ee7f13dd0 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() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, } cfg, err := testEnv.Start() diff --git a/testdata/project-v3-config/api/v1/webhook_suite_test.go b/testdata/project-v3-config/api/v1/webhook_suite_test.go index 541e7682ea0..1498c040c12 100644 --- a/testdata/project-v3-config/api/v1/webhook_suite_test.go +++ b/testdata/project-v3-config/api/v1/webhook_suite_test.go @@ -64,7 +64,8 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: false, WebhookInstallOptions: envtest.WebhookInstallOptions{ Paths: []string{filepath.Join("..", "..", "config", "webhook")}, }, diff --git a/testdata/project-v3-config/controllers/suite_test.go b/testdata/project-v3-config/controllers/suite_test.go index c2fb4129bb5..9a71520d545 100644 --- a/testdata/project-v3-config/controllers/suite_test.go +++ b/testdata/project-v3-config/controllers/suite_test.go @@ -54,7 +54,8 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, } cfg, err := testEnv.Start() diff --git a/testdata/project-v3-multigroup/apis/crew/v1/webhook_suite_test.go b/testdata/project-v3-multigroup/apis/crew/v1/webhook_suite_test.go index 82fe2c58557..56d8f1147d5 100644 --- a/testdata/project-v3-multigroup/apis/crew/v1/webhook_suite_test.go +++ b/testdata/project-v3-multigroup/apis/crew/v1/webhook_suite_test.go @@ -64,7 +64,8 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: false, WebhookInstallOptions: envtest.WebhookInstallOptions{ Paths: []string{filepath.Join("..", "..", "..", "config", "webhook")}, }, diff --git a/testdata/project-v3-multigroup/apis/ship/v1/webhook_suite_test.go b/testdata/project-v3-multigroup/apis/ship/v1/webhook_suite_test.go index 85b2339cf32..226b7bf2dd9 100644 --- a/testdata/project-v3-multigroup/apis/ship/v1/webhook_suite_test.go +++ b/testdata/project-v3-multigroup/apis/ship/v1/webhook_suite_test.go @@ -64,7 +64,8 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: false, WebhookInstallOptions: envtest.WebhookInstallOptions{ Paths: []string{filepath.Join("..", "..", "..", "config", "webhook")}, }, diff --git a/testdata/project-v3-multigroup/apis/ship/v2alpha1/webhook_suite_test.go b/testdata/project-v3-multigroup/apis/ship/v2alpha1/webhook_suite_test.go index 0bdc004d23e..d7e1eb77302 100644 --- a/testdata/project-v3-multigroup/apis/ship/v2alpha1/webhook_suite_test.go +++ b/testdata/project-v3-multigroup/apis/ship/v2alpha1/webhook_suite_test.go @@ -64,7 +64,8 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: false, WebhookInstallOptions: envtest.WebhookInstallOptions{ Paths: []string{filepath.Join("..", "..", "..", "config", "webhook")}, }, diff --git a/testdata/project-v3-multigroup/apis/v1/webhook_suite_test.go b/testdata/project-v3-multigroup/apis/v1/webhook_suite_test.go index 3e9cfa5867b..e1612ea22ab 100644 --- a/testdata/project-v3-multigroup/apis/v1/webhook_suite_test.go +++ b/testdata/project-v3-multigroup/apis/v1/webhook_suite_test.go @@ -64,7 +64,8 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: false, WebhookInstallOptions: envtest.WebhookInstallOptions{ Paths: []string{filepath.Join("..", "..", "config", "webhook")}, }, diff --git a/testdata/project-v3-multigroup/controllers/apps/suite_test.go b/testdata/project-v3-multigroup/controllers/apps/suite_test.go index 0097b94eae1..1a52084f221 100644 --- a/testdata/project-v3-multigroup/controllers/apps/suite_test.go +++ b/testdata/project-v3-multigroup/controllers/apps/suite_test.go @@ -52,7 +52,8 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: false, } cfg, err := testEnv.Start() diff --git a/testdata/project-v3-multigroup/controllers/crew/suite_test.go b/testdata/project-v3-multigroup/controllers/crew/suite_test.go index 27905ab3a6e..0dc36f1a534 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() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, } cfg, err := testEnv.Start() 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 03d4a9adf2b..2610397938d 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() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, } cfg, err := testEnv.Start() 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 a49ae8ccc17..dbd072b0f72 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() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, } cfg, err := testEnv.Start() diff --git a/testdata/project-v3-multigroup/controllers/ship/suite_test.go b/testdata/project-v3-multigroup/controllers/ship/suite_test.go index da5583ed600..10ac6ba0554 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() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, } cfg, err := testEnv.Start() diff --git a/testdata/project-v3-multigroup/controllers/suite_test.go b/testdata/project-v3-multigroup/controllers/suite_test.go index 6ace66cef28..868760626b2 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() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, } cfg, err := testEnv.Start() diff --git a/testdata/project-v3/api/v1/webhook_suite_test.go b/testdata/project-v3/api/v1/webhook_suite_test.go index 541e7682ea0..1498c040c12 100644 --- a/testdata/project-v3/api/v1/webhook_suite_test.go +++ b/testdata/project-v3/api/v1/webhook_suite_test.go @@ -64,7 +64,8 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: false, WebhookInstallOptions: envtest.WebhookInstallOptions{ Paths: []string{filepath.Join("..", "..", "config", "webhook")}, }, diff --git a/testdata/project-v3/controllers/suite_test.go b/testdata/project-v3/controllers/suite_test.go index 90a0d92110a..7172d0f31ee 100644 --- a/testdata/project-v3/controllers/suite_test.go +++ b/testdata/project-v3/controllers/suite_test.go @@ -54,7 +54,8 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, } cfg, err := testEnv.Start()