enhance kube-schedule init flag

This commit is contained in:
zhengjiajin 2017-12-13 14:46:58 +08:00
parent 38e3351312
commit 3ee3cf65cb
2 changed files with 3 additions and 12 deletions

View File

@ -70,6 +70,7 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/pflag" "github.com/spf13/pflag"
utilflag "k8s.io/apiserver/pkg/util/flag"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
@ -342,8 +343,8 @@ through the API as necessary.`,
glog.Fatalf("unable to apply config defaults: %v", err) glog.Fatalf("unable to apply config defaults: %v", err)
} }
flags := cmd.Flags() AddFlags(opts, pflag.CommandLine)
AddFlags(opts, flags) utilflag.InitFlags()
cmd.MarkFlagFilename("config", "yaml", "yml", "json") cmd.MarkFlagFilename("config", "yaml", "yml", "json")

View File

@ -17,12 +17,8 @@ limitations under the License.
package main package main
import ( import (
goflag "flag"
"os" "os"
"github.com/spf13/pflag"
utilflag "k8s.io/apiserver/pkg/util/flag"
"k8s.io/apiserver/pkg/util/logs" "k8s.io/apiserver/pkg/util/logs"
_ "k8s.io/kubernetes/pkg/client/metrics/prometheus" // for client metric registration _ "k8s.io/kubernetes/pkg/client/metrics/prometheus" // for client metric registration
_ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration _ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration
@ -32,12 +28,6 @@ import (
func main() { func main() {
command := app.NewSchedulerCommand() command := app.NewSchedulerCommand()
// 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() logs.InitLogs()
defer logs.FlushLogs() defer logs.FlushLogs()