Skip to content

Commit 2271827

Browse files
authored
Merge pull request #2180 from yanggangtony/clean-envtest-server
🌱 code clean for pkg/envtest/server.go
2 parents f9d8abc + 65f861d commit 2271827

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

pkg/envtest/server.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -230,17 +230,19 @@ func (te *Environment) Start() (*rest.Config, error) {
230230
if os.Getenv(envAttachOutput) == "true" {
231231
te.AttachControlPlaneOutput = true
232232
}
233-
if apiServer.Out == nil && te.AttachControlPlaneOutput {
234-
apiServer.Out = os.Stdout
235-
}
236-
if apiServer.Err == nil && te.AttachControlPlaneOutput {
237-
apiServer.Err = os.Stderr
238-
}
239-
if te.ControlPlane.Etcd.Out == nil && te.AttachControlPlaneOutput {
240-
te.ControlPlane.Etcd.Out = os.Stdout
241-
}
242-
if te.ControlPlane.Etcd.Err == nil && te.AttachControlPlaneOutput {
243-
te.ControlPlane.Etcd.Err = os.Stderr
233+
if te.AttachControlPlaneOutput {
234+
if apiServer.Out == nil {
235+
apiServer.Out = os.Stdout
236+
}
237+
if apiServer.Err == nil {
238+
apiServer.Err = os.Stderr
239+
}
240+
if te.ControlPlane.Etcd.Out == nil {
241+
te.ControlPlane.Etcd.Out = os.Stdout
242+
}
243+
if te.ControlPlane.Etcd.Err == nil {
244+
te.ControlPlane.Etcd.Err = os.Stderr
245+
}
244246
}
245247

246248
apiServer.Path = process.BinPathFinder("kube-apiserver", te.BinaryAssetsDirectory)

0 commit comments

Comments
 (0)