1
0
mirror of https://github.com/kubernetes-sigs/descheduler.git synced 2026-01-26 05:14:13 +01:00

Conversion to glog

Signed-off-by: ravisantoshgudimetla <ravisantoshgudimetla@gmail.com>

Conversion to glog
This commit is contained in:
ravisantoshgudimetla
2017-09-27 16:30:19 -04:00
parent e662d717df
commit 32c8898ec7
6 changed files with 43 additions and 32 deletions

View File

@@ -19,31 +19,40 @@ package app
import (
"fmt"
"flag"
"io"
"github.com/kubernetes-incubator/descheduler/cmd/descheduler/app/options"
"github.com/kubernetes-incubator/descheduler/pkg/descheduler"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/apiserver/pkg/util/logs"
aflag "k8s.io/apiserver/pkg/util/flag"
)
// NewDeschedulerCommand creates a *cobra.Command object with default parameters
func NewDeschedulerCommand() *cobra.Command {
func NewDeschedulerCommand(out io.Writer) *cobra.Command {
s := options.NewDeschedulerServer()
s.AddFlags(pflag.CommandLine)
cmd := &cobra.Command{
Use: "descheduler",
Short: "descheduler",
Long: `The descheduler evicts pods which may be bound to less desired nodes`,
Run: func(cmd *cobra.Command, args []string) {
logs.InitLogs()
defer logs.FlushLogs()
err := Run(s)
if err != nil {
fmt.Println(err)
}
},
}
cmd.SetOutput(out)
flags := cmd.Flags()
flags.SetNormalizeFunc(aflag.WordSepNormalizeFunc)
flags.AddGoFlagSet(flag.CommandLine)
s.AddFlags(flags)
return cmd
}

View File

@@ -19,12 +19,12 @@ package main
import (
"fmt"
"os"
"github.com/kubernetes-incubator/descheduler/cmd/descheduler/app"
)
func main() {
cmd := app.NewDeschedulerCommand()
out := os.Stdout
cmd := app.NewDeschedulerCommand(out)
if err := cmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)