diff --git a/cluster/addons/dns/kube2sky/kube2sky.go b/cluster/addons/dns/kube2sky/kube2sky.go index fcb581eb05471..dd7bb12b8a812 100644 --- a/cluster/addons/dns/kube2sky/kube2sky.go +++ b/cluster/addons/dns/kube2sky/kube2sky.go @@ -46,7 +46,7 @@ import ( kframework "k8s.io/kubernetes/pkg/controller/framework" kselector "k8s.io/kubernetes/pkg/fields" etcdutil "k8s.io/kubernetes/pkg/storage/etcd/util" - "k8s.io/kubernetes/pkg/util" + utilflag "k8s.io/kubernetes/pkg/util/flag" "k8s.io/kubernetes/pkg/util/validation" "k8s.io/kubernetes/pkg/util/wait" ) @@ -634,7 +634,7 @@ func setupHealthzHandlers(ks *kube2sky) { } func main() { - flag.CommandLine.SetNormalizeFunc(util.WarnWordSepNormalizeFunc) + flag.CommandLine.SetNormalizeFunc(utilflag.WarnWordSepNormalizeFunc) flag.Parse() var err error setupSignalHandlers() diff --git a/cmd/hyperkube/hyperkube.go b/cmd/hyperkube/hyperkube.go index 5272c5dd14158..328a7eb142c0b 100644 --- a/cmd/hyperkube/hyperkube.go +++ b/cmd/hyperkube/hyperkube.go @@ -29,6 +29,7 @@ import ( "runtime" "k8s.io/kubernetes/pkg/util" + utilflag "k8s.io/kubernetes/pkg/util/flag" "k8s.io/kubernetes/pkg/version/verflag" "github.com/spf13/pflag" @@ -72,7 +73,7 @@ func (hk *HyperKube) Flags() *pflag.FlagSet { if hk.baseFlags == nil { hk.baseFlags = pflag.NewFlagSet(hk.Name, pflag.ContinueOnError) hk.baseFlags.SetOutput(ioutil.Discard) - hk.baseFlags.SetNormalizeFunc(util.WordSepNormalizeFunc) + hk.baseFlags.SetNormalizeFunc(utilflag.WordSepNormalizeFunc) hk.baseFlags.BoolVarP(&hk.helpFlagVal, "help", "h", false, "help for "+hk.Name) // These will add all of the "global" flags (defined with both the diff --git a/cmd/hyperkube/server.go b/cmd/hyperkube/server.go index 6b6e5ce521ab3..75899ca98af3f 100644 --- a/cmd/hyperkube/server.go +++ b/cmd/hyperkube/server.go @@ -23,6 +23,7 @@ import ( "strings" "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/flag" "github.com/spf13/pflag" ) @@ -70,7 +71,7 @@ func (s *Server) Flags() *pflag.FlagSet { if s.flags == nil { s.flags = pflag.NewFlagSet(s.Name(), pflag.ContinueOnError) s.flags.SetOutput(ioutil.Discard) - s.flags.SetNormalizeFunc(util.WordSepNormalizeFunc) + s.flags.SetNormalizeFunc(flag.WordSepNormalizeFunc) } return s.flags } diff --git a/cmd/integration/integration.go b/cmd/integration/integration.go index 7750bef645da8..2d95fc13c0ccd 100644 --- a/cmd/integration/integration.go +++ b/cmd/integration/integration.go @@ -55,6 +55,7 @@ import ( "k8s.io/kubernetes/pkg/master" "k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/flag" utilnet "k8s.io/kubernetes/pkg/util/net" utilruntime "k8s.io/kubernetes/pkg/util/runtime" "k8s.io/kubernetes/pkg/util/sets" @@ -972,7 +973,7 @@ func main() { gruntime.GOMAXPROCS(gruntime.NumCPU()) addFlags(pflag.CommandLine) - util.InitFlags() + flag.InitFlags() utilruntime.ReallyCrash = true util.InitLogs() defer util.FlushLogs() diff --git a/cmd/kube-apiserver/apiserver.go b/cmd/kube-apiserver/apiserver.go index 8aef2cf9ea3b3..c63ec99c35183 100644 --- a/cmd/kube-apiserver/apiserver.go +++ b/cmd/kube-apiserver/apiserver.go @@ -28,6 +28,7 @@ import ( "k8s.io/kubernetes/cmd/kube-apiserver/app" "k8s.io/kubernetes/cmd/kube-apiserver/app/options" "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/flag" "k8s.io/kubernetes/pkg/version/verflag" "github.com/spf13/pflag" @@ -40,7 +41,7 @@ func main() { s := options.NewAPIServer() s.AddFlags(pflag.CommandLine) - util.InitFlags() + flag.InitFlags() util.InitLogs() defer util.FlushLogs() diff --git a/cmd/kube-controller-manager/controller-manager.go b/cmd/kube-controller-manager/controller-manager.go index 03cea78692767..0968be61c7eff 100644 --- a/cmd/kube-controller-manager/controller-manager.go +++ b/cmd/kube-controller-manager/controller-manager.go @@ -29,6 +29,7 @@ import ( "k8s.io/kubernetes/cmd/kube-controller-manager/app/options" "k8s.io/kubernetes/pkg/healthz" "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/flag" "k8s.io/kubernetes/pkg/version/verflag" "github.com/spf13/pflag" @@ -43,7 +44,7 @@ func main() { s := options.NewCMServer() s.AddFlags(pflag.CommandLine) - util.InitFlags() + flag.InitFlags() util.InitLogs() defer util.FlushLogs() diff --git a/cmd/kube-proxy/proxy.go b/cmd/kube-proxy/proxy.go index 9fab4b302b01f..b2c5b5dfff62d 100644 --- a/cmd/kube-proxy/proxy.go +++ b/cmd/kube-proxy/proxy.go @@ -25,6 +25,7 @@ import ( "k8s.io/kubernetes/cmd/kube-proxy/app/options" "k8s.io/kubernetes/pkg/healthz" "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/flag" "k8s.io/kubernetes/pkg/version/verflag" "github.com/spf13/pflag" @@ -39,7 +40,7 @@ func main() { config := options.NewProxyConfig() config.AddFlags(pflag.CommandLine) - util.InitFlags() + flag.InitFlags() util.InitLogs() defer util.FlushLogs() diff --git a/cmd/kubelet/kubelet.go b/cmd/kubelet/kubelet.go index 20bba6ff735d3..fdc5c53811462 100644 --- a/cmd/kubelet/kubelet.go +++ b/cmd/kubelet/kubelet.go @@ -28,6 +28,7 @@ import ( "k8s.io/kubernetes/cmd/kubelet/app" "k8s.io/kubernetes/cmd/kubelet/app/options" "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/flag" "k8s.io/kubernetes/pkg/version/verflag" "github.com/spf13/pflag" @@ -38,7 +39,7 @@ func main() { s := options.NewKubeletServer() s.AddFlags(pflag.CommandLine) - util.InitFlags() + flag.InitFlags() util.InitLogs() defer util.FlushLogs() diff --git a/cmd/kubemark/hollow-node.go b/cmd/kubemark/hollow-node.go index 8dfc8272716f0..38112708186fc 100644 --- a/cmd/kubemark/hollow-node.go +++ b/cmd/kubemark/hollow-node.go @@ -32,7 +32,7 @@ import ( "k8s.io/kubernetes/pkg/kubelet/dockertools" "k8s.io/kubernetes/pkg/kubemark" proxyconfig "k8s.io/kubernetes/pkg/proxy/config" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/flag" fakeiptables "k8s.io/kubernetes/pkg/util/iptables/testing" "k8s.io/kubernetes/pkg/util/sets" @@ -85,7 +85,7 @@ func main() { config := HollowNodeConfig{} config.addFlags(pflag.CommandLine) - util.InitFlags() + flag.InitFlags() if !knownMorphs.Has(config.Morph) { glog.Fatalf("Unknown morph: %v. Allowed values: %v", config.Morph, knownMorphs.List()) diff --git a/contrib/mesos/cmd/k8sm-controller-manager/main.go b/contrib/mesos/cmd/k8sm-controller-manager/main.go index 72c7baf499b4e..f5581c7207daa 100644 --- a/contrib/mesos/cmd/k8sm-controller-manager/main.go +++ b/contrib/mesos/cmd/k8sm-controller-manager/main.go @@ -23,6 +23,7 @@ import ( "k8s.io/kubernetes/pkg/healthz" "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/flag" "k8s.io/kubernetes/pkg/version/verflag" "k8s.io/kubernetes/contrib/mesos/pkg/controllermanager" @@ -40,7 +41,7 @@ func main() { s := controllermanager.NewCMServer() s.AddFlags(pflag.CommandLine) - util.InitFlags() + flag.InitFlags() util.InitLogs() defer util.FlushLogs() diff --git a/contrib/mesos/cmd/k8sm-executor/main.go b/contrib/mesos/cmd/k8sm-executor/main.go index 82d6366f2fc00..604c702365ca7 100644 --- a/contrib/mesos/cmd/k8sm-executor/main.go +++ b/contrib/mesos/cmd/k8sm-executor/main.go @@ -25,6 +25,7 @@ import ( "k8s.io/kubernetes/contrib/mesos/pkg/executor/service" "k8s.io/kubernetes/contrib/mesos/pkg/hyperkube" "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/flag" "k8s.io/kubernetes/pkg/version/verflag" ) @@ -34,7 +35,7 @@ func main() { s := service.NewKubeletExecutorServer() s.AddFlags(pflag.CommandLine) - util.InitFlags() + flag.InitFlags() util.InitLogs() defer util.FlushLogs() diff --git a/contrib/mesos/cmd/k8sm-scheduler/main.go b/contrib/mesos/cmd/k8sm-scheduler/main.go index 1bba89504c7ec..eed1a20a8c33e 100644 --- a/contrib/mesos/cmd/k8sm-scheduler/main.go +++ b/contrib/mesos/cmd/k8sm-scheduler/main.go @@ -25,6 +25,7 @@ import ( "k8s.io/kubernetes/contrib/mesos/pkg/hyperkube" "k8s.io/kubernetes/contrib/mesos/pkg/scheduler/service" "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/flag" "k8s.io/kubernetes/pkg/version/verflag" ) @@ -33,7 +34,7 @@ func main() { s := service.NewSchedulerServer() s.AddStandaloneFlags(pflag.CommandLine) - util.InitFlags() + flag.InitFlags() util.InitLogs() defer util.FlushLogs() diff --git a/pkg/kubectl/cmd/cmd.go b/pkg/kubectl/cmd/cmd.go index 7c4c33c521878..2282884480050 100644 --- a/pkg/kubectl/cmd/cmd.go +++ b/pkg/kubectl/cmd/cmd.go @@ -23,7 +23,7 @@ import ( cmdconfig "k8s.io/kubernetes/pkg/kubectl/cmd/config" "k8s.io/kubernetes/pkg/kubectl/cmd/rollout" cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/flag" "github.com/spf13/cobra" ) @@ -156,7 +156,7 @@ Find more information at https://github.com/kubernetes/kubernetes.`, f.BindExternalFlags(cmds.PersistentFlags()) // From this point and forward we get warnings on flags that contain "_" separators - cmds.SetGlobalNormalizationFunc(util.WarnWordSepNormalizeFunc) + cmds.SetGlobalNormalizationFunc(flag.WarnWordSepNormalizeFunc) cmds.AddCommand(NewCmdGet(f, out)) cmds.AddCommand(NewCmdDescribe(f, out)) diff --git a/pkg/kubectl/cmd/util/factory.go b/pkg/kubectl/cmd/util/factory.go index 0076ce99a728f..f8c001f85e88c 100644 --- a/pkg/kubectl/cmd/util/factory.go +++ b/pkg/kubectl/cmd/util/factory.go @@ -53,7 +53,7 @@ import ( "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime/serializer/json" - "k8s.io/kubernetes/pkg/util" + utilflag "k8s.io/kubernetes/pkg/util/flag" ) const ( @@ -186,7 +186,7 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory { mapper := kubectl.ShortcutExpander{RESTMapper: registered.RESTMapper()} flags := pflag.NewFlagSet("", pflag.ContinueOnError) - flags.SetNormalizeFunc(util.WarnWordSepNormalizeFunc) // Warn for "_" flags + flags.SetNormalizeFunc(utilflag.WarnWordSepNormalizeFunc) // Warn for "_" flags clientConfig := optionalClientConfig if optionalClientConfig == nil { @@ -639,7 +639,7 @@ func (f *Factory) BindFlags(flags *pflag.FlagSet) { // Normalize all flags that are coming from other packages or pre-configurations // a.k.a. change all "_" to "-". e.g. glog package - flags.SetNormalizeFunc(util.WordSepNormalizeFunc) + flags.SetNormalizeFunc(utilflag.WordSepNormalizeFunc) } // BindCommonFlags adds any flags defined by external projects (not part of pflags) diff --git a/pkg/kubectl/cmd/util/factory_test.go b/pkg/kubectl/cmd/util/factory_test.go index 03a4403d3387d..459b34d6cd8c4 100644 --- a/pkg/kubectl/cmd/util/factory_test.go +++ b/pkg/kubectl/cmd/util/factory_test.go @@ -38,7 +38,7 @@ import ( "k8s.io/kubernetes/pkg/client/unversioned/fake" "k8s.io/kubernetes/pkg/kubectl" "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/flag" ) func TestNewFactoryDefaultFlagBindings(t *testing.T) { @@ -198,7 +198,7 @@ func TestCanBeExposed(t *testing.T) { func TestFlagUnderscoreRenaming(t *testing.T) { factory := NewFactory(nil) - factory.flags.SetNormalizeFunc(util.WordSepNormalizeFunc) + factory.flags.SetNormalizeFunc(flag.WordSepNormalizeFunc) factory.flags.Bool("valid_flag", false, "bool value") // In case of failure of this test check this PR: spf13/pflag#23 diff --git a/pkg/util/env.go b/pkg/util/env/env.go similarity index 98% rename from pkg/util/env.go rename to pkg/util/env/env.go index 6a479bd949993..ad4310c25cead 100644 --- a/pkg/util/env.go +++ b/pkg/util/env/env.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package util +package env import ( "os" diff --git a/pkg/util/env_test.go b/pkg/util/env/env_test.go similarity index 99% rename from pkg/util/env_test.go rename to pkg/util/env/env_test.go index a640fbe2a736d..f7ff0a2351363 100644 --- a/pkg/util/env_test.go +++ b/pkg/util/env/env_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package util +package env import ( "os" diff --git a/pkg/util/flags.go b/pkg/util/flag/flags.go similarity index 99% rename from pkg/util/flags.go rename to pkg/util/flag/flags.go index 3d5799243cf19..94b9f733f5af1 100644 --- a/pkg/util/flags.go +++ b/pkg/util/flag/flags.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package util +package flag import ( goflag "flag" diff --git a/pkg/volume/flocker/plugin.go b/pkg/volume/flocker/plugin.go index 472ffbf0132f6..2b21cb7b2d247 100644 --- a/pkg/volume/flocker/plugin.go +++ b/pkg/volume/flocker/plugin.go @@ -24,7 +24,7 @@ import ( flockerclient "github.com/ClusterHQ/flocker-go" "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/types" - "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/env" "k8s.io/kubernetes/pkg/util/exec" "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/util/strings" @@ -133,15 +133,15 @@ func (b flockerBuilder) SetUp(fsGroup *int64) error { // newFlockerClient uses environment variables and pod attributes to return a // flocker client capable of talking with the Flocker control service. func (b flockerBuilder) newFlockerClient() (*flockerclient.Client, error) { - host := util.GetEnvAsStringOrFallback("FLOCKER_CONTROL_SERVICE_HOST", defaultHost) - port, err := util.GetEnvAsIntOrFallback("FLOCKER_CONTROL_SERVICE_PORT", defaultPort) + host := env.GetEnvAsStringOrFallback("FLOCKER_CONTROL_SERVICE_HOST", defaultHost) + port, err := env.GetEnvAsIntOrFallback("FLOCKER_CONTROL_SERVICE_PORT", defaultPort) if err != nil { return nil, err } - caCertPath := util.GetEnvAsStringOrFallback("FLOCKER_CONTROL_SERVICE_CA_FILE", defaultCACertFile) - keyPath := util.GetEnvAsStringOrFallback("FLOCKER_CONTROL_SERVICE_CLIENT_KEY_FILE", defaultClientKeyFile) - certPath := util.GetEnvAsStringOrFallback("FLOCKER_CONTROL_SERVICE_CLIENT_CERT_FILE", defaultClientCertFile) + caCertPath := env.GetEnvAsStringOrFallback("FLOCKER_CONTROL_SERVICE_CA_FILE", defaultCACertFile) + keyPath := env.GetEnvAsStringOrFallback("FLOCKER_CONTROL_SERVICE_CLIENT_KEY_FILE", defaultClientKeyFile) + certPath := env.GetEnvAsStringOrFallback("FLOCKER_CONTROL_SERVICE_CLIENT_CERT_FILE", defaultClientCertFile) c, err := flockerclient.NewClient(host, port, b.flocker.pod.Status.HostIP, caCertPath, keyPath, certPath) return c, err diff --git a/plugin/cmd/kube-scheduler/scheduler.go b/plugin/cmd/kube-scheduler/scheduler.go index 72e22f4b04eb2..f3fca7b7f53c1 100644 --- a/plugin/cmd/kube-scheduler/scheduler.go +++ b/plugin/cmd/kube-scheduler/scheduler.go @@ -21,6 +21,7 @@ import ( "k8s.io/kubernetes/pkg/healthz" "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/flag" "k8s.io/kubernetes/pkg/version/verflag" "k8s.io/kubernetes/plugin/cmd/kube-scheduler/app" "k8s.io/kubernetes/plugin/cmd/kube-scheduler/app/options" @@ -37,7 +38,7 @@ func main() { s := options.NewSchedulerServer() s.AddFlags(pflag.CommandLine) - util.InitFlags() + flag.InitFlags() util.InitLogs() defer util.FlushLogs()