From 235bc4a94b3a568c469149650f6e7fec19184648 Mon Sep 17 00:00:00 2001 From: Camila Macedo Date: Sun, 23 Apr 2023 18:07:28 +0100 Subject: [PATCH] :bug: fix scaffold to allow run the tests directly --- pkg/plugins/golang/v4/scaffolds/api.go | 2 +- pkg/plugins/golang/v4/scaffolds/init.go | 5 +++-- .../internal/templates/api/webhook_suitetest.go | 14 +++++++++++++- .../templates/controllers/controller_suitetest.go | 12 ++++++++++++ pkg/plugins/golang/v4/scaffolds/webhook.go | 2 +- .../project-v4-config/api/v1/webhook_suite_test.go | 8 ++++++++ .../internal/controller/suite_test.go | 10 ++++++++++ .../internal/controller/suite_test.go | 10 ++++++++++ .../api/crew/v1/webhook_suite_test.go | 8 ++++++++ .../api/ship/v1/webhook_suite_test.go | 8 ++++++++ .../api/ship/v2alpha1/webhook_suite_test.go | 8 ++++++++ .../api/v1/webhook_suite_test.go | 8 ++++++++ .../internal/controller/apps/suite_test.go | 10 ++++++++++ .../internal/controller/crew/suite_test.go | 10 ++++++++++ .../internal/controller/fiz/suite_test.go | 10 ++++++++++ .../internal/controller/foo.policy/suite_test.go | 10 ++++++++++ .../internal/controller/foo/suite_test.go | 10 ++++++++++ .../controller/sea-creatures/suite_test.go | 10 ++++++++++ .../internal/controller/ship/suite_test.go | 10 ++++++++++ .../internal/controller/suite_test.go | 10 ++++++++++ .../api/v1alpha1/webhook_suite_test.go | 8 ++++++++ .../internal/controller/suite_test.go | 10 ++++++++++ testdata/project-v4/api/v1/webhook_suite_test.go | 8 ++++++++ .../project-v4/internal/controller/suite_test.go | 10 ++++++++++ 24 files changed, 206 insertions(+), 5 deletions(-) diff --git a/pkg/plugins/golang/v4/scaffolds/api.go b/pkg/plugins/golang/v4/scaffolds/api.go index 6afcb040627..56211222aa7 100644 --- a/pkg/plugins/golang/v4/scaffolds/api.go +++ b/pkg/plugins/golang/v4/scaffolds/api.go @@ -96,7 +96,7 @@ func (s *apiScaffolder) Scaffold() error { if doController { if err := scaffold.Execute( - &controllers.SuiteTest{Force: s.force}, + &controllers.SuiteTest{Force: s.force, K8SVersion: K8SVersion}, &controllers.Controller{ControllerRuntimeVersion: ControllerRuntimeVersion, Force: s.force}, ); err != nil { return fmt.Errorf("error scaffolding controller: %v", err) diff --git a/pkg/plugins/golang/v4/scaffolds/init.go b/pkg/plugins/golang/v4/scaffolds/init.go index 6a1b64e7948..81fdf8b15b6 100644 --- a/pkg/plugins/golang/v4/scaffolds/init.go +++ b/pkg/plugins/golang/v4/scaffolds/init.go @@ -37,8 +37,9 @@ const ( ControllerRuntimeVersion = "v0.14.4" // ControllerToolsVersion is the kubernetes-sigs/controller-tools version to be used in the project ControllerToolsVersion = "v0.11.3" - - imageName = "controller:latest" + // K8SVersion is the k8s version used to do the scaffold + K8SVersion = "1.26.1" + imageName = "controller:latest" ) var _ plugins.Scaffolder = &initScaffolder{} diff --git a/pkg/plugins/golang/v4/scaffolds/internal/templates/api/webhook_suitetest.go b/pkg/plugins/golang/v4/scaffolds/internal/templates/api/webhook_suitetest.go index 22fd41479ad..199a083972a 100644 --- a/pkg/plugins/golang/v4/scaffolds/internal/templates/api/webhook_suitetest.go +++ b/pkg/plugins/golang/v4/scaffolds/internal/templates/api/webhook_suitetest.go @@ -36,6 +36,10 @@ type WebhookSuite struct { //nolint:maligned // todo: currently is not possible to know if an API was or not scaffolded. We can fix it when #1826 be addressed WireResource bool + // K8SVersion define the k8s version used to do the scaffold + // so that is possible retrieve the binaries + K8SVersion string + // BaseDirectoryRelativePath define the Path for the base directory when it is multigroup BaseDirectoryRelativePath string } @@ -176,7 +180,15 @@ var _ = BeforeSuite(func() { ErrorIfCRDPathMissing: {{ .WireResource }}, WebhookInstallOptions: envtest.WebhookInstallOptions{ Paths: []string{filepath.Join({{ .BaseDirectoryRelativePath }}, "config", "webhook")}, - }, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join({{ .BaseDirectoryRelativePath }}, "bin", "k8s", + fmt.Sprintf("{{ .K8SVersion }}-%%s-%%s", runtime.GOOS, runtime.GOARCH)), + }, } var err error diff --git a/pkg/plugins/golang/v4/scaffolds/internal/templates/controllers/controller_suitetest.go b/pkg/plugins/golang/v4/scaffolds/internal/templates/controllers/controller_suitetest.go index 5f2f8174772..32f809a4596 100644 --- a/pkg/plugins/golang/v4/scaffolds/internal/templates/controllers/controller_suitetest.go +++ b/pkg/plugins/golang/v4/scaffolds/internal/templates/controllers/controller_suitetest.go @@ -34,6 +34,10 @@ type SuiteTest struct { machinery.BoilerplateMixin machinery.ResourceMixin + // K8SVersion define the k8s version used to do the scaffold + // so that is possible retrieve the binaries + K8SVersion string + // CRDDirectoryRelativePath define the Path for the CRD CRDDirectoryRelativePath string @@ -165,6 +169,14 @@ var _ = BeforeSuite(func() { testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{filepath.Join({{ .CRDDirectoryRelativePath }}, "config", "crd", "bases")}, ErrorIfCRDPathMissing: {{ .Resource.HasAPI }}, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join({{ .CRDDirectoryRelativePath }}, "bin", "k8s", + fmt.Sprintf("{{ .K8SVersion }}-%%s-%%s", runtime.GOOS, runtime.GOARCH)), } var err error diff --git a/pkg/plugins/golang/v4/scaffolds/webhook.go b/pkg/plugins/golang/v4/scaffolds/webhook.go index 029f75ee5e5..765963ed0a9 100644 --- a/pkg/plugins/golang/v4/scaffolds/webhook.go +++ b/pkg/plugins/golang/v4/scaffolds/webhook.go @@ -98,7 +98,7 @@ You need to implement the conversion.Hub and conversion.Convertible interfaces f // TODO: Add test suite for conversion webhook after #1664 has been merged & conversion tests supported in envtest. if doDefaulting || doValidation { if err := scaffold.Execute( - &api.WebhookSuite{}, + &api.WebhookSuite{K8SVersion: K8SVersion}, ); err != nil { return err } diff --git a/testdata/project-v4-config/api/v1/webhook_suite_test.go b/testdata/project-v4-config/api/v1/webhook_suite_test.go index 674dbd75261..ca006722510 100644 --- a/testdata/project-v4-config/api/v1/webhook_suite_test.go +++ b/testdata/project-v4-config/api/v1/webhook_suite_test.go @@ -65,6 +65,14 @@ var _ = BeforeSuite(func() { ErrorIfCRDPathMissing: false, WebhookInstallOptions: envtest.WebhookInstallOptions{ Paths: []string{filepath.Join("..", "..", "config", "webhook")}, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), }, } diff --git a/testdata/project-v4-config/internal/controller/suite_test.go b/testdata/project-v4-config/internal/controller/suite_test.go index e5d3da932db..0a7a2626521 100644 --- a/testdata/project-v4-config/internal/controller/suite_test.go +++ b/testdata/project-v4-config/internal/controller/suite_test.go @@ -17,7 +17,9 @@ limitations under the License. package controller import ( + "fmt" "path/filepath" + "runtime" "testing" . "github.com/onsi/ginkgo/v2" @@ -54,6 +56,14 @@ var _ = BeforeSuite(func() { testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, ErrorIfCRDPathMissing: true, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), } var err error diff --git a/testdata/project-v4-declarative-v1/internal/controller/suite_test.go b/testdata/project-v4-declarative-v1/internal/controller/suite_test.go index 4b9dbd7be96..2f053108dc8 100644 --- a/testdata/project-v4-declarative-v1/internal/controller/suite_test.go +++ b/testdata/project-v4-declarative-v1/internal/controller/suite_test.go @@ -17,7 +17,9 @@ limitations under the License. package controller import ( + "fmt" "path/filepath" + "runtime" "testing" . "github.com/onsi/ginkgo/v2" @@ -54,6 +56,14 @@ var _ = BeforeSuite(func() { testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, ErrorIfCRDPathMissing: true, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), } var err error diff --git a/testdata/project-v4-multigroup/api/crew/v1/webhook_suite_test.go b/testdata/project-v4-multigroup/api/crew/v1/webhook_suite_test.go index 49c94418569..30d4fbb7a3e 100644 --- a/testdata/project-v4-multigroup/api/crew/v1/webhook_suite_test.go +++ b/testdata/project-v4-multigroup/api/crew/v1/webhook_suite_test.go @@ -65,6 +65,14 @@ var _ = BeforeSuite(func() { ErrorIfCRDPathMissing: false, WebhookInstallOptions: envtest.WebhookInstallOptions{ Paths: []string{filepath.Join("..", "..", "..", "config", "webhook")}, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), }, } diff --git a/testdata/project-v4-multigroup/api/ship/v1/webhook_suite_test.go b/testdata/project-v4-multigroup/api/ship/v1/webhook_suite_test.go index 2edd77dacfc..01b8ea14f59 100644 --- a/testdata/project-v4-multigroup/api/ship/v1/webhook_suite_test.go +++ b/testdata/project-v4-multigroup/api/ship/v1/webhook_suite_test.go @@ -65,6 +65,14 @@ var _ = BeforeSuite(func() { ErrorIfCRDPathMissing: false, WebhookInstallOptions: envtest.WebhookInstallOptions{ Paths: []string{filepath.Join("..", "..", "..", "config", "webhook")}, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), }, } diff --git a/testdata/project-v4-multigroup/api/ship/v2alpha1/webhook_suite_test.go b/testdata/project-v4-multigroup/api/ship/v2alpha1/webhook_suite_test.go index d32e5ed78b1..2bdd5a98099 100644 --- a/testdata/project-v4-multigroup/api/ship/v2alpha1/webhook_suite_test.go +++ b/testdata/project-v4-multigroup/api/ship/v2alpha1/webhook_suite_test.go @@ -65,6 +65,14 @@ var _ = BeforeSuite(func() { ErrorIfCRDPathMissing: false, WebhookInstallOptions: envtest.WebhookInstallOptions{ Paths: []string{filepath.Join("..", "..", "..", "config", "webhook")}, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), }, } diff --git a/testdata/project-v4-multigroup/api/v1/webhook_suite_test.go b/testdata/project-v4-multigroup/api/v1/webhook_suite_test.go index f1511968296..d54bf1b87b4 100644 --- a/testdata/project-v4-multigroup/api/v1/webhook_suite_test.go +++ b/testdata/project-v4-multigroup/api/v1/webhook_suite_test.go @@ -65,6 +65,14 @@ var _ = BeforeSuite(func() { ErrorIfCRDPathMissing: false, WebhookInstallOptions: envtest.WebhookInstallOptions{ Paths: []string{filepath.Join("..", "..", "config", "webhook")}, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), }, } diff --git a/testdata/project-v4-multigroup/internal/controller/apps/suite_test.go b/testdata/project-v4-multigroup/internal/controller/apps/suite_test.go index efd73704027..44601199e4e 100644 --- a/testdata/project-v4-multigroup/internal/controller/apps/suite_test.go +++ b/testdata/project-v4-multigroup/internal/controller/apps/suite_test.go @@ -17,7 +17,9 @@ limitations under the License. package apps import ( + "fmt" "path/filepath" + "runtime" "testing" . "github.com/onsi/ginkgo/v2" @@ -53,6 +55,14 @@ var _ = BeforeSuite(func() { testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, ErrorIfCRDPathMissing: false, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), } var err error diff --git a/testdata/project-v4-multigroup/internal/controller/crew/suite_test.go b/testdata/project-v4-multigroup/internal/controller/crew/suite_test.go index 10330561187..1ab3c32f56b 100644 --- a/testdata/project-v4-multigroup/internal/controller/crew/suite_test.go +++ b/testdata/project-v4-multigroup/internal/controller/crew/suite_test.go @@ -17,7 +17,9 @@ limitations under the License. package crew import ( + "fmt" "path/filepath" + "runtime" "testing" . "github.com/onsi/ginkgo/v2" @@ -54,6 +56,14 @@ var _ = BeforeSuite(func() { testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, ErrorIfCRDPathMissing: true, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), } var err error diff --git a/testdata/project-v4-multigroup/internal/controller/fiz/suite_test.go b/testdata/project-v4-multigroup/internal/controller/fiz/suite_test.go index b3baaba801e..3237aa11f4e 100644 --- a/testdata/project-v4-multigroup/internal/controller/fiz/suite_test.go +++ b/testdata/project-v4-multigroup/internal/controller/fiz/suite_test.go @@ -17,7 +17,9 @@ limitations under the License. package fiz import ( + "fmt" "path/filepath" + "runtime" "testing" . "github.com/onsi/ginkgo/v2" @@ -54,6 +56,14 @@ var _ = BeforeSuite(func() { testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, ErrorIfCRDPathMissing: true, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), } var err error diff --git a/testdata/project-v4-multigroup/internal/controller/foo.policy/suite_test.go b/testdata/project-v4-multigroup/internal/controller/foo.policy/suite_test.go index 6e4f52f95eb..1330656d3fb 100644 --- a/testdata/project-v4-multigroup/internal/controller/foo.policy/suite_test.go +++ b/testdata/project-v4-multigroup/internal/controller/foo.policy/suite_test.go @@ -17,7 +17,9 @@ limitations under the License. package foopolicy import ( + "fmt" "path/filepath" + "runtime" "testing" . "github.com/onsi/ginkgo/v2" @@ -54,6 +56,14 @@ var _ = BeforeSuite(func() { testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, ErrorIfCRDPathMissing: true, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), } var err error diff --git a/testdata/project-v4-multigroup/internal/controller/foo/suite_test.go b/testdata/project-v4-multigroup/internal/controller/foo/suite_test.go index 5f434e57002..babc65a5f75 100644 --- a/testdata/project-v4-multigroup/internal/controller/foo/suite_test.go +++ b/testdata/project-v4-multigroup/internal/controller/foo/suite_test.go @@ -17,7 +17,9 @@ limitations under the License. package foo import ( + "fmt" "path/filepath" + "runtime" "testing" . "github.com/onsi/ginkgo/v2" @@ -54,6 +56,14 @@ var _ = BeforeSuite(func() { testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, ErrorIfCRDPathMissing: true, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), } var err error diff --git a/testdata/project-v4-multigroup/internal/controller/sea-creatures/suite_test.go b/testdata/project-v4-multigroup/internal/controller/sea-creatures/suite_test.go index 000034c4c6e..e19254de8ee 100644 --- a/testdata/project-v4-multigroup/internal/controller/sea-creatures/suite_test.go +++ b/testdata/project-v4-multigroup/internal/controller/sea-creatures/suite_test.go @@ -17,7 +17,9 @@ limitations under the License. package seacreatures import ( + "fmt" "path/filepath" + "runtime" "testing" . "github.com/onsi/ginkgo/v2" @@ -55,6 +57,14 @@ var _ = BeforeSuite(func() { testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, ErrorIfCRDPathMissing: true, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), } var err error diff --git a/testdata/project-v4-multigroup/internal/controller/ship/suite_test.go b/testdata/project-v4-multigroup/internal/controller/ship/suite_test.go index 2dd3f472c65..278d0579d85 100644 --- a/testdata/project-v4-multigroup/internal/controller/ship/suite_test.go +++ b/testdata/project-v4-multigroup/internal/controller/ship/suite_test.go @@ -17,7 +17,9 @@ limitations under the License. package ship import ( + "fmt" "path/filepath" + "runtime" "testing" . "github.com/onsi/ginkgo/v2" @@ -56,6 +58,14 @@ var _ = BeforeSuite(func() { testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, ErrorIfCRDPathMissing: true, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), } var err error diff --git a/testdata/project-v4-multigroup/internal/controller/suite_test.go b/testdata/project-v4-multigroup/internal/controller/suite_test.go index fc4d2f406e1..cc263cfa6ce 100644 --- a/testdata/project-v4-multigroup/internal/controller/suite_test.go +++ b/testdata/project-v4-multigroup/internal/controller/suite_test.go @@ -17,7 +17,9 @@ limitations under the License. package controller import ( + "fmt" "path/filepath" + "runtime" "testing" . "github.com/onsi/ginkgo/v2" @@ -54,6 +56,14 @@ var _ = BeforeSuite(func() { testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, ErrorIfCRDPathMissing: true, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), } var err error diff --git a/testdata/project-v4-with-deploy-image/api/v1alpha1/webhook_suite_test.go b/testdata/project-v4-with-deploy-image/api/v1alpha1/webhook_suite_test.go index e2ffbb63fef..2faf5f59314 100644 --- a/testdata/project-v4-with-deploy-image/api/v1alpha1/webhook_suite_test.go +++ b/testdata/project-v4-with-deploy-image/api/v1alpha1/webhook_suite_test.go @@ -65,6 +65,14 @@ var _ = BeforeSuite(func() { ErrorIfCRDPathMissing: false, WebhookInstallOptions: envtest.WebhookInstallOptions{ Paths: []string{filepath.Join("..", "..", "config", "webhook")}, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), }, } diff --git a/testdata/project-v4-with-deploy-image/internal/controller/suite_test.go b/testdata/project-v4-with-deploy-image/internal/controller/suite_test.go index bef37d780be..db1c2386270 100644 --- a/testdata/project-v4-with-deploy-image/internal/controller/suite_test.go +++ b/testdata/project-v4-with-deploy-image/internal/controller/suite_test.go @@ -17,7 +17,9 @@ limitations under the License. package controller import ( + "fmt" "path/filepath" + "runtime" "testing" . "github.com/onsi/ginkgo/v2" @@ -54,6 +56,14 @@ var _ = BeforeSuite(func() { testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, ErrorIfCRDPathMissing: true, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), } var err error diff --git a/testdata/project-v4/api/v1/webhook_suite_test.go b/testdata/project-v4/api/v1/webhook_suite_test.go index 674dbd75261..ca006722510 100644 --- a/testdata/project-v4/api/v1/webhook_suite_test.go +++ b/testdata/project-v4/api/v1/webhook_suite_test.go @@ -65,6 +65,14 @@ var _ = BeforeSuite(func() { ErrorIfCRDPathMissing: false, WebhookInstallOptions: envtest.WebhookInstallOptions{ Paths: []string{filepath.Join("..", "..", "config", "webhook")}, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), }, } diff --git a/testdata/project-v4/internal/controller/suite_test.go b/testdata/project-v4/internal/controller/suite_test.go index a6742364412..8e374dec214 100644 --- a/testdata/project-v4/internal/controller/suite_test.go +++ b/testdata/project-v4/internal/controller/suite_test.go @@ -17,7 +17,9 @@ limitations under the License. package controller import ( + "fmt" "path/filepath" + "runtime" "testing" . "github.com/onsi/ginkgo/v2" @@ -54,6 +56,14 @@ var _ = BeforeSuite(func() { testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, ErrorIfCRDPathMissing: true, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "bin", "k8s", + fmt.Sprintf("1.26.1-%s-%s", runtime.GOOS, runtime.GOARCH)), } var err error