1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-17 23:59:36 +00:00
Files
norman/pkg/kwrapper/kubectl/main.go
2018-10-23 22:46:45 -07:00

40 lines
922 B
Go

package kubectl
import (
goflag "flag"
"fmt"
"math/rand"
"os"
"time"
"github.com/docker/docker/pkg/reexec"
"github.com/spf13/pflag"
utilflag "k8s.io/apiserver/pkg/util/flag"
"k8s.io/apiserver/pkg/util/logs"
"k8s.io/kubernetes/pkg/kubectl/cmd"
)
func init() {
reexec.Register("kubectl", Main)
}
func Main() {
rand.Seed(time.Now().UTC().UnixNano())
command := cmd.NewDefaultKubectlCommand()
// TODO: once we switch everything over to Cobra commands, we can go back to calling
// utilflag.InitFlags() (by removing its pflag.Parse() call). For now, we have to set the
// normalize func and add the go flag set by hand.
pflag.CommandLine.SetNormalizeFunc(utilflag.WordSepNormalizeFunc)
pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)
// utilflag.InitFlags()
logs.InitLogs()
defer logs.FlushLogs()
if err := command.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}