@@ -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
@@ -142,9 +148,28 @@ func (te *Environment) Start() (*rest.Config, error) {
142
148
}
143
149
}
144
150
} else {
145
- te .ControlPlane = integration.ControlPlane {}
146
- te .ControlPlane .APIServer = & integration.APIServer {Args : te .getAPIServerFlags ()}
147
- te .ControlPlane .Etcd = & integration.Etcd {}
151
+ if te .ControlPlane .APIServer == nil {
152
+ te .ControlPlane .APIServer = & integration.APIServer {Args : te .getAPIServerFlags ()}
153
+ }
154
+ if te .ControlPlane .Etcd == nil {
155
+ te .ControlPlane .Etcd = & integration.Etcd {}
156
+ }
157
+
158
+ if os .Getenv (envAttachOutput ) == "true" {
159
+ te .AttachControlPlaneOutput = true
160
+ }
161
+ if te .ControlPlane .APIServer .Out == nil && te .AttachControlPlaneOutput {
162
+ te .ControlPlane .APIServer .Out = os .Stdout
163
+ }
164
+ if te .ControlPlane .APIServer .Err == nil && te .AttachControlPlaneOutput {
165
+ te .ControlPlane .APIServer .Err = os .Stderr
166
+ }
167
+ if te .ControlPlane .Etcd .Out == nil && te .AttachControlPlaneOutput {
168
+ te .ControlPlane .Etcd .Out = os .Stdout
169
+ }
170
+ if te .ControlPlane .Etcd .Err == nil && te .AttachControlPlaneOutput {
171
+ te .ControlPlane .Etcd .Err = os .Stderr
172
+ }
148
173
149
174
if os .Getenv (envKubeAPIServerBin ) == "" {
150
175
te .ControlPlane .APIServer .Path = defaultAssetPath ("kube-apiserver" )
0 commit comments