forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxy.go
47 lines (36 loc) · 1 KB
/
proxy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package kubernetes
import (
"fmt"
"io"
"os"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/GoogleCloudPlatform/kubernetes/cmd/kube-proxy/app"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
)
const proxyLong = `Start Kubernetes Proxy
This command launches an instance of the Kubernetes proxy (kube-proxy).`
// NewProxyCommand provides a CLI handler for the 'proxy' command
func NewProxyCommand(name, fullName string, out io.Writer) *cobra.Command {
s := app.NewProxyServer()
cmd := &cobra.Command{
Use: name,
Short: "Launch Kubernetes proxy (kube-proxy)",
Long: proxyLong,
Run: func(c *cobra.Command, args []string) {
startProfiler()
util.InitLogs()
defer util.FlushLogs()
if err := s.Run(pflag.CommandLine.Args()); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
},
}
cmd.SetOutput(out)
flags := cmd.Flags()
//TODO: uncomment after picking up a newer cobra
//pflag.AddFlagSetToPFlagSet(flag, flags)
s.AddFlags(flags)
return cmd
}