Commit 6bd6b905 authored by Joe Beda's avatar Joe Beda

Address code review comments

Add some documentation. Create new util.InitFlags() function to merge and parse in one step.
parent 1d0b6ee5
...@@ -700,8 +700,7 @@ func TestPodHasServiceEnvVars(c *client.Client) bool { ...@@ -700,8 +700,7 @@ func TestPodHasServiceEnvVars(c *client.Client) bool {
} }
func main() { func main() {
util.AddAllFlagsToPFlags() util.InitFlags()
flag.Parse()
goruntime.GOMAXPROCS(goruntime.NumCPU()) goruntime.GOMAXPROCS(goruntime.NumCPU())
util.ReallyCrash = true util.ReallyCrash = true
util.InitLogs() util.InitLogs()
......
...@@ -53,7 +53,6 @@ import ( ...@@ -53,7 +53,6 @@ import (
"github.com/coreos/go-etcd/etcd" "github.com/coreos/go-etcd/etcd"
"github.com/golang/glog" "github.com/golang/glog"
flag "github.com/spf13/pflag"
) )
var ( var (
...@@ -563,8 +562,7 @@ func runServiceTest(client *client.Client) { ...@@ -563,8 +562,7 @@ func runServiceTest(client *client.Client) {
type testFunc func(*client.Client) type testFunc func(*client.Client)
func main() { func main() {
util.AddAllFlagsToPFlags() util.InitFlags()
flag.Parse()
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())
util.ReallyCrash = true util.ReallyCrash = true
util.InitLogs() util.InitLogs()
......
...@@ -124,8 +124,7 @@ func newEtcd(etcdConfigFile string, etcdServerList util.StringList) (helper tool ...@@ -124,8 +124,7 @@ func newEtcd(etcdConfigFile string, etcdServerList util.StringList) (helper tool
} }
func main() { func main() {
util.AddAllFlagsToPFlags() util.InitFlags()
flag.Parse()
util.InitLogs() util.InitLogs()
defer util.FlushLogs() defer util.FlushLogs()
......
...@@ -75,8 +75,7 @@ func verifyMinionFlags() { ...@@ -75,8 +75,7 @@ func verifyMinionFlags() {
} }
func main() { func main() {
util.AddAllFlagsToPFlags() util.InitFlags()
flag.Parse()
util.InitLogs() util.InitLogs()
defer util.FlushLogs() defer util.FlushLogs()
......
...@@ -53,8 +53,7 @@ func init() { ...@@ -53,8 +53,7 @@ func init() {
} }
func main() { func main() {
util.AddAllFlagsToPFlags() util.InitFlags()
flag.Parse()
util.InitLogs() util.InitLogs()
defer util.FlushLogs() defer util.FlushLogs()
......
...@@ -90,8 +90,7 @@ func setupRunOnce() { ...@@ -90,8 +90,7 @@ func setupRunOnce() {
} }
func main() { func main() {
util.AddAllFlagsToPFlags() util.InitFlags()
flag.Parse()
util.InitLogs() util.InitLogs()
defer util.FlushLogs() defer util.FlushLogs()
rand.Seed(time.Now().UTC().UnixNano()) rand.Seed(time.Now().UTC().UnixNano())
......
...@@ -66,8 +66,7 @@ func newApiClient(addr string, port int) *client.Client { ...@@ -66,8 +66,7 @@ func newApiClient(addr string, port int) *client.Client {
} }
func main() { func main() {
util.AddAllFlagsToPFlags() util.InitFlags()
flag.Parse()
util.InitLogs() util.InitLogs()
defer util.FlushLogs() defer util.FlushLogs()
......
/*
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()
}
...@@ -66,6 +66,7 @@ func (v *versionValue) String() string { ...@@ -66,6 +66,7 @@ func (v *versionValue) String() string {
return fmt.Sprintf("%v", bool(*v == VersionTrue)) return fmt.Sprintf("%v", bool(*v == VersionTrue))
} }
// The type of the flag as requred by the pflag.Value interface
func (v *versionValue) Type() string { func (v *versionValue) Type() string {
return "version" return "version"
} }
......
...@@ -48,8 +48,7 @@ func init() { ...@@ -48,8 +48,7 @@ func init() {
} }
func main() { func main() {
util.AddAllFlagsToPFlags() util.InitFlags()
flag.Parse()
util.InitLogs() util.InitLogs()
defer util.FlushLogs() defer util.FlushLogs()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment