Fix kubectl proxy

Port flag was being ignored. Fixed now.
pull/6/head
Jeff Lowdermlk 2015-01-16 13:19:43 -08:00 committed by Jeff Lowdermilk
parent bba01c7a54
commit 6e98ce34ca
2 changed files with 6 additions and 7 deletions

View File

@ -36,9 +36,9 @@ func (f *Factory) NewCmdProxy(out io.Writer) *cobra.Command {
clientConfig, err := f.ClientConfig(cmd)
checkErr(err)
server, err := kubectl.NewProxyServer(GetFlagString(cmd, "www"), clientConfig, port)
server, err := kubectl.NewProxyServer(GetFlagString(cmd, "www"), clientConfig)
checkErr(err)
glog.Fatal(server.Serve())
glog.Fatal(server.Serve(port))
},
}
cmd.Flags().StringP("www", "w", "", "Also serve static files from the given directory under the prefix /static")

View File

@ -29,12 +29,11 @@ import (
// ProxyServer is a http.Handler which proxies Kubernetes APIs to remote API server.
type ProxyServer struct {
httputil.ReverseProxy
Port int
}
// NewProxyServer creates and installs a new ProxyServer.
// It automatically registers the created ProxyServer to http.DefaultServeMux.
func NewProxyServer(filebase string, cfg *client.Config, port int) (*ProxyServer, error) {
func NewProxyServer(filebase string, cfg *client.Config) (*ProxyServer, error) {
prefix := cfg.Prefix
if prefix == "" {
prefix = "/api"
@ -52,9 +51,9 @@ func NewProxyServer(filebase string, cfg *client.Config, port int) (*ProxyServer
return proxy, nil
}
// Serve starts the server (http.DefaultServeMux) on TCP port 8001, loops forever.
func (s *ProxyServer) Serve() error {
addr := fmt.Sprintf(":%d", s.Port)
// Serve starts the server (http.DefaultServeMux) on given port, loops forever.
func (s *ProxyServer) Serve(port int) error {
addr := fmt.Sprintf(":%d", port)
return http.ListenAndServe(addr, nil)
}