Skip to content

Commit

Permalink
Merge pull request kubernetes#22939 from resouer/util-sub-dir
Browse files Browse the repository at this point in the history
Auto commit by PR queue bot
  • Loading branch information
k8s-merge-robot committed Mar 23, 2016
2 parents 2777cd7 + f19d59c commit 76369c4
Show file tree
Hide file tree
Showing 20 changed files with 42 additions and 31 deletions.
4 changes: 2 additions & 2 deletions cluster/addons/dns/kube2sky/kube2sky.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion cmd/hyperkube/hyperkube.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion cmd/hyperkube/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"strings"

"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/flag"

"github.com/spf13/pflag"
)
Expand Down Expand Up @@ -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
}
3 changes: 2 additions & 1 deletion cmd/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion cmd/kube-apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -40,7 +41,7 @@ func main() {
s := options.NewAPIServer()
s.AddFlags(pflag.CommandLine)

util.InitFlags()
flag.InitFlags()
util.InitLogs()
defer util.FlushLogs()

Expand Down
3 changes: 2 additions & 1 deletion cmd/kube-controller-manager/controller-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -43,7 +44,7 @@ func main() {
s := options.NewCMServer()
s.AddFlags(pflag.CommandLine)

util.InitFlags()
flag.InitFlags()
util.InitLogs()
defer util.FlushLogs()

Expand Down
3 changes: 2 additions & 1 deletion cmd/kube-proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -39,7 +40,7 @@ func main() {
config := options.NewProxyConfig()
config.AddFlags(pflag.CommandLine)

util.InitFlags()
flag.InitFlags()
util.InitLogs()
defer util.FlushLogs()

Expand Down
3 changes: 2 additions & 1 deletion cmd/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -38,7 +39,7 @@ func main() {
s := options.NewKubeletServer()
s.AddFlags(pflag.CommandLine)

util.InitFlags()
flag.InitFlags()
util.InitLogs()
defer util.FlushLogs()

Expand Down
4 changes: 2 additions & 2 deletions cmd/kubemark/hollow-node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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())
Expand Down
3 changes: 2 additions & 1 deletion contrib/mesos/cmd/k8sm-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -40,7 +41,7 @@ func main() {
s := controllermanager.NewCMServer()
s.AddFlags(pflag.CommandLine)

util.InitFlags()
flag.InitFlags()
util.InitLogs()
defer util.FlushLogs()

Expand Down
3 changes: 2 additions & 1 deletion contrib/mesos/cmd/k8sm-executor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -34,7 +35,7 @@ func main() {
s := service.NewKubeletExecutorServer()
s.AddFlags(pflag.CommandLine)

util.InitFlags()
flag.InitFlags()
util.InitLogs()
defer util.FlushLogs()

Expand Down
3 changes: 2 additions & 1 deletion contrib/mesos/cmd/k8sm-scheduler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -33,7 +34,7 @@ func main() {
s := service.NewSchedulerServer()
s.AddStandaloneFlags(pflag.CommandLine)

util.InitFlags()
flag.InitFlags()
util.InitLogs()
defer util.FlushLogs()

Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions pkg/kubectl/cmd/util/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/cmd/util/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/env.go → pkg/util/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package util
package env

import (
"os"
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/env_test.go → pkg/util/env/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package util
package env

import (
"os"
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/flags.go → pkg/util/flag/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions pkg/volume/flocker/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion plugin/cmd/kube-scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -37,7 +38,7 @@ func main() {
s := options.NewSchedulerServer()
s.AddFlags(pflag.CommandLine)

util.InitFlags()
flag.InitFlags()
util.InitLogs()
defer util.FlushLogs()

Expand Down

0 comments on commit 76369c4

Please sign in to comment.