@@ -42,6 +42,7 @@ const (
42
42
envKubebuilderPath = "KUBEBUILDER_ASSETS"
43
43
envStartTimeout = "KUBEBUILDER_CONTROLPLANE_START_TIMEOUT"
44
44
envStopTimeout = "KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT"
45
+ envAttachOutput = "KUBEBUILDER_ATTACH_CONTROL_PLANE_OUTPUT"
45
46
defaultKubebuilderPath = "/usr/local/kubebuilder/bin"
46
47
StartTimeout = 60
47
48
StopTimeout = 60
@@ -103,6 +104,11 @@ type Environment struct {
103
104
104
105
// KubeAPIServerFlags is the set of flags passed while starting the api server.
105
106
KubeAPIServerFlags []string
107
+
108
+ // AttachControlPlaneOutput indicates if control plane output will be attached to os.Stdout and os.Stderr.
109
+ // Enable this to get more visibility of the testing control plane.
110
+ // It respect KUBEBUILDER_ATTACH_CONTROL_PLANE_OUTPUT environment variable.
111
+ AttachControlPlaneOutput bool
106
112
}
107
113
108
114
// Stop stops a running server
@@ -143,8 +149,28 @@ func (te *Environment) Start() (*rest.Config, error) {
143
149
}
144
150
} else {
145
151
te .ControlPlane = integration.ControlPlane {}
146
- te .ControlPlane .APIServer = & integration.APIServer {Args : te .getAPIServerFlags ()}
147
- te .ControlPlane .Etcd = & integration.Etcd {}
152
+ if te .ControlPlane .APIServer == nil {
153
+ te .ControlPlane .APIServer = & integration.APIServer {Args : te .getAPIServerFlags ()}
154
+ }
155
+ if te .ControlPlane .Etcd == nil {
156
+ te .ControlPlane .Etcd = & integration.Etcd {}
157
+ }
158
+
159
+ if os .Getenv (envAttachOutput ) == "true" {
160
+ te .AttachControlPlaneOutput = true
161
+ }
162
+ if te .ControlPlane .APIServer .Out == nil && te .AttachControlPlaneOutput {
163
+ te .ControlPlane .APIServer .Out = os .Stdout
164
+ }
165
+ if te .ControlPlane .APIServer .Err == nil && te .AttachControlPlaneOutput {
166
+ te .ControlPlane .APIServer .Err = os .Stderr
167
+ }
168
+ if te .ControlPlane .Etcd .Out == nil && te .AttachControlPlaneOutput {
169
+ te .ControlPlane .Etcd .Out = os .Stdout
170
+ }
171
+ if te .ControlPlane .Etcd .Err == nil && te .AttachControlPlaneOutput {
172
+ te .ControlPlane .Etcd .Err = os .Stderr
173
+ }
148
174
149
175
if os .Getenv (envKubeAPIServerBin ) == "" {
150
176
te .ControlPlane .APIServer .Path = defaultAssetPath ("kube-apiserver" )
0 commit comments