Skip to content

Commit

Permalink
Address code review comments
Browse files Browse the repository at this point in the history
Add some documentation.
Create new util.InitFlags() function to merge and parse in one step.
  • Loading branch information
jbeda committed Jan 15, 2015
1 parent 1d0b6ee commit 6bd6b90
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 17 deletions.
3 changes: 1 addition & 2 deletions cmd/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,7 @@ func TestPodHasServiceEnvVars(c *client.Client) bool {
}

func main() {
util.AddAllFlagsToPFlags()
flag.Parse()
util.InitFlags()
goruntime.GOMAXPROCS(goruntime.NumCPU())
util.ReallyCrash = true
util.InitLogs()
Expand Down
4 changes: 1 addition & 3 deletions cmd/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import (

"github.com/coreos/go-etcd/etcd"
"github.com/golang/glog"
flag "github.com/spf13/pflag"
)

var (
Expand Down Expand Up @@ -563,8 +562,7 @@ func runServiceTest(client *client.Client) {
type testFunc func(*client.Client)

func main() {
util.AddAllFlagsToPFlags()
flag.Parse()
util.InitFlags()
runtime.GOMAXPROCS(runtime.NumCPU())
util.ReallyCrash = true
util.InitLogs()
Expand Down
3 changes: 1 addition & 2 deletions cmd/kube-apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ func newEtcd(etcdConfigFile string, etcdServerList util.StringList) (helper tool
}

func main() {
util.AddAllFlagsToPFlags()
flag.Parse()
util.InitFlags()
util.InitLogs()
defer util.FlushLogs()

Expand Down
3 changes: 1 addition & 2 deletions cmd/kube-controller-manager/controller-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ func verifyMinionFlags() {
}

func main() {
util.AddAllFlagsToPFlags()
flag.Parse()
util.InitFlags()
util.InitLogs()
defer util.FlushLogs()

Expand Down
3 changes: 1 addition & 2 deletions cmd/kube-proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ func init() {
}

func main() {
util.AddAllFlagsToPFlags()
flag.Parse()
util.InitFlags()
util.InitLogs()
defer util.FlushLogs()

Expand Down
3 changes: 1 addition & 2 deletions cmd/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ func setupRunOnce() {
}

func main() {
util.AddAllFlagsToPFlags()
flag.Parse()
util.InitFlags()
util.InitLogs()
defer util.FlushLogs()
rand.Seed(time.Now().UTC().UnixNano())
Expand Down
3 changes: 1 addition & 2 deletions cmd/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ func newApiClient(addr string, port int) *client.Client {
}

func main() {
util.AddAllFlagsToPFlags()
flag.Parse()
util.InitFlags()
util.InitLogs()
defer util.FlushLogs()

Expand Down
27 changes: 27 additions & 0 deletions pkg/util/flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Copyright 2014 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package util

import (
flag "github.com/spf13/pflag"
)

// InitFlags normalizes and parses the command line flags
func InitFlags() {
AddAllFlagsToPFlags()
flag.Parse()
}
1 change: 1 addition & 0 deletions pkg/version/verflag/verflag.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func (v *versionValue) String() string {
return fmt.Sprintf("%v", bool(*v == VersionTrue))
}

// The type of the flag as requred by the pflag.Value interface
func (v *versionValue) Type() string {
return "version"
}
Expand Down
3 changes: 1 addition & 2 deletions plugin/cmd/kube-scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ func init() {
}

func main() {
util.AddAllFlagsToPFlags()
flag.Parse()
util.InitFlags()
util.InitLogs()
defer util.FlushLogs()

Expand Down

0 comments on commit 6bd6b90

Please sign in to comment.