diff --git a/hack/.staticcheck_failures b/hack/.staticcheck_failures index 4120867685f..e9bfa6740bd 100644 --- a/hack/.staticcheck_failures +++ b/hack/.staticcheck_failures @@ -99,7 +99,6 @@ vendor/k8s.io/kubectl/pkg/cmd/config vendor/k8s.io/kubectl/pkg/cmd/edit vendor/k8s.io/kubectl/pkg/cmd/exec vendor/k8s.io/kubectl/pkg/cmd/get -vendor/k8s.io/kubectl/pkg/cmd/proxy vendor/k8s.io/kubectl/pkg/cmd/rollingupdate vendor/k8s.io/kubectl/pkg/cmd/scale vendor/k8s.io/kubectl/pkg/cmd/set diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/proxy/proxy.go b/staging/src/k8s.io/kubectl/pkg/cmd/proxy/proxy.go index 904ab782b0f..98ed1405f3d 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/proxy/proxy.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/proxy/proxy.go @@ -200,6 +200,10 @@ func (o ProxyOptions) Validate() error { func (o ProxyOptions) RunProxy() error { server, err := proxy.NewServer(o.staticDir, o.apiPrefix, o.staticPrefix, o.filter, o.clientConfig, o.keepalive) + if err != nil { + return err + } + // Separate listening from serving so we can report the bound port // when it is chosen by os (eg: port == 0) var l net.Listener @@ -209,9 +213,8 @@ func (o ProxyOptions) RunProxy() error { l, err = server.ListenUnix(o.unixSocket) } if err != nil { - klog.Fatal(err) + return err } fmt.Fprintf(o.IOStreams.Out, "Starting to serve on %s\n", l.Addr().String()) - klog.Fatal(server.ServeOnListener(l)) - return nil + return server.ServeOnListener(l) }