@@ -29,6 +29,7 @@ import (
29
29
. "github.com/onsi/ginkgo/v2"
30
30
. "github.com/onsi/gomega"
31
31
"go.uber.org/zap/zapcore"
32
+ "golang.org/x/tools/go/packages"
32
33
corev1 "k8s.io/api/core/v1"
33
34
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
34
35
"k8s.io/kubectl/pkg/scheme"
@@ -72,11 +73,18 @@ var _ = BeforeSuite(func() {
72
73
73
74
tests .GetEnvOrSkip ("KUBEBUILDER_ASSETS" )
74
75
76
+ // We need to calculate the cluster-api version to load the CRDs from the right path
77
+ capiModule , err := packages .Load (& packages.Config {Mode : packages .NeedModule }, "sigs.k8s.io/cluster-api" )
78
+ Expect (err ).NotTo (HaveOccurred ())
79
+ // We need to calculate the cluster-api-provider-aws version to load the CRDs from the right path
80
+ capaModule , err := packages .Load (& packages.Config {Mode : packages .NeedModule }, "sigs.k8s.io/cluster-api-provider-aws/v2" )
81
+ Expect (err ).NotTo (HaveOccurred ())
82
+
75
83
By ("bootstrapping test environment" )
76
84
testEnv = & envtest.Environment {
77
85
CRDDirectoryPaths : []string {
78
- filepath .Join (build .Default .GOPATH , "pkg" , "mod" , "sigs.k8s.io" , "cluster-api@v1.8.3" , "config" , "crd" , "bases" ),
79
- filepath .Join (build .Default .GOPATH , "pkg" , "mod" , "sigs.k8s.io" , "cluster-api-provider-aws" , "v2@v2.6.1" , "config" , "crd" , "bases" ),
86
+ filepath .Join (build .Default .GOPATH , "pkg" , "mod" , "sigs.k8s.io" , fmt . Sprintf ( "cluster-api@%s" , capiModule [ 0 ]. Module . Version ) , "config" , "crd" , "bases" ),
87
+ filepath .Join (build .Default .GOPATH , "pkg" , "mod" , "sigs.k8s.io" , "cluster-api-provider-aws" , fmt . Sprintf ( "v2@%s" , capaModule [ 0 ]. Module . Version ) , "config" , "crd" , "bases" ),
80
88
},
81
89
ErrorIfCRDPathMissing : true ,
82
90
}
0 commit comments