@@ -62,14 +62,18 @@ const (
62
62
defaultKubebuilderControlPlaneStopTimeout = 20 * time .Second
63
63
)
64
64
65
- // Default binary path for test framework
66
- func defaultAssetPath (binary string ) string {
67
- assetPath := os .Getenv (envKubebuilderPath )
68
- if assetPath = = "" {
69
- assetPath = defaultKubebuilderPath
65
+ // getBinAssetPath will return the path for the binary informed
66
+ func ( te * Environment ) getBinAssetPath (binary string ) string {
67
+ valueFromEnvVar := os .Getenv (envKubebuilderPath )
68
+ if valueFromEnvVar ! = "" {
69
+ return filepath . Join ( valueFromEnvVar , binary )
70
70
}
71
- return filepath .Join (assetPath , binary )
72
71
72
+ if te .BinaryAssetsDirectory != "" {
73
+ return filepath .Join (te .BinaryAssetsDirectory , binary )
74
+ }
75
+
76
+ return filepath .Join (defaultKubebuilderPath , binary )
73
77
}
74
78
75
79
// ControlPlane is the re-exported ControlPlane type from the internal integration package
@@ -113,6 +117,10 @@ type Environment struct {
113
117
// values are merged.
114
118
CRDDirectoryPaths []string
115
119
120
+ // BinaryAssetsDirectory is the path where the binaries required for the envtest are
121
+ // locate in the environment
122
+ BinaryAssetsDirectory string
123
+
116
124
// UseExisting indicates that this environments should use an
117
125
// existing kubeconfig, instead of trying to stand up a new control plane.
118
126
// This is useful in cases that need aggregated API servers and the like.
@@ -217,14 +225,14 @@ func (te *Environment) Start() (*rest.Config, error) {
217
225
}
218
226
219
227
if os .Getenv (envKubeAPIServerBin ) == "" {
220
- te .ControlPlane .APIServer .Path = defaultAssetPath ("kube-apiserver" )
228
+ te .ControlPlane .APIServer .Path = te . getBinAssetPath ("kube-apiserver" )
221
229
}
222
230
if os .Getenv (envEtcdBin ) == "" {
223
- te .ControlPlane .Etcd .Path = defaultAssetPath ("etcd" )
231
+ te .ControlPlane .Etcd .Path = te . getBinAssetPath ("etcd" )
224
232
}
225
233
if os .Getenv (envKubectlBin ) == "" {
226
234
// we can't just set the path manually (it's behind a function), so set the environment variable instead
227
- if err := os .Setenv (envKubectlBin , defaultAssetPath ("kubectl" )); err != nil {
235
+ if err := os .Setenv (envKubectlBin , te . getBinAssetPath ("kubectl" )); err != nil {
228
236
return nil , err
229
237
}
230
238
}
0 commit comments