From 15c844031f26d49a115ea9f4c174f3fb1215a5f8 Mon Sep 17 00:00:00 2001 From: cici37 Date: Wed, 22 Apr 2020 10:06:11 -0700 Subject: [PATCH] Remove CCM dependency pkg/util/flag --- cmd/cloud-controller-manager/app/BUILD | 1 - cmd/cloud-controller-manager/app/controllermanager.go | 3 +-- cmd/kube-apiserver/app/BUILD | 1 - cmd/kube-apiserver/app/server.go | 3 +-- cmd/kube-controller-manager/app/BUILD | 1 - cmd/kube-controller-manager/app/controllermanager.go | 3 +-- cmd/kube-proxy/app/server.go | 2 +- cmd/kube-scheduler/app/BUILD | 1 - cmd/kube-scheduler/app/server.go | 3 +-- cmd/kubelet/app/BUILD | 1 - cmd/kubelet/app/server.go | 3 +-- pkg/util/flag/BUILD | 1 - pkg/util/flag/flags.go | 8 -------- staging/src/k8s.io/component-base/cli/flag/flags.go | 7 +++++++ 14 files changed, 13 insertions(+), 25 deletions(-) diff --git a/cmd/cloud-controller-manager/app/BUILD b/cmd/cloud-controller-manager/app/BUILD index abb9260239d..cdd8b686e28 100644 --- a/cmd/cloud-controller-manager/app/BUILD +++ b/cmd/cloud-controller-manager/app/BUILD @@ -17,7 +17,6 @@ go_library( "//pkg/controller/service:go_default_library", "//pkg/features:go_default_library", "//pkg/util/configz:go_default_library", - "//pkg/util/flag:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library", diff --git a/cmd/cloud-controller-manager/app/controllermanager.go b/cmd/cloud-controller-manager/app/controllermanager.go index b4b7b8d2d25..66f8d8c2734 100644 --- a/cmd/cloud-controller-manager/app/controllermanager.go +++ b/cmd/cloud-controller-manager/app/controllermanager.go @@ -44,7 +44,6 @@ import ( "k8s.io/kubernetes/cmd/cloud-controller-manager/app/options" genericcontrollermanager "k8s.io/kubernetes/cmd/controller-manager/app" "k8s.io/kubernetes/pkg/util/configz" - utilflag "k8s.io/kubernetes/pkg/util/flag" ) const ( @@ -67,7 +66,7 @@ func NewCloudControllerManagerCommand() *cobra.Command { the cloud specific control loops shipped with Kubernetes.`, Run: func(cmd *cobra.Command, args []string) { verflag.PrintAndExitIfRequested() - utilflag.PrintFlags(cmd.Flags()) + cliflag.PrintFlags(cmd.Flags()) c, err := s.Config(KnownControllers(), ControllersDisabledByDefault.List()) if err != nil { diff --git a/cmd/kube-apiserver/app/BUILD b/cmd/kube-apiserver/app/BUILD index f7b7d4fdea1..a3e9186bbf0 100644 --- a/cmd/kube-apiserver/app/BUILD +++ b/cmd/kube-apiserver/app/BUILD @@ -29,7 +29,6 @@ go_library( "//pkg/registry/cachesize:go_default_library", "//pkg/registry/rbac/rest:go_default_library", "//pkg/serviceaccount:go_default_library", - "//pkg/util/flag:go_default_library", "//plugin/pkg/auth/authenticator/token/bootstrap:go_default_library", "//staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1:go_default_library", "//staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1:go_default_library", diff --git a/cmd/kube-apiserver/app/server.go b/cmd/kube-apiserver/app/server.go index 458da8559b5..a2795fb9b07 100644 --- a/cmd/kube-apiserver/app/server.go +++ b/cmd/kube-apiserver/app/server.go @@ -86,7 +86,6 @@ import ( "k8s.io/kubernetes/pkg/registry/cachesize" rbacrest "k8s.io/kubernetes/pkg/registry/rbac/rest" "k8s.io/kubernetes/pkg/serviceaccount" - utilflag "k8s.io/kubernetes/pkg/util/flag" "k8s.io/kubernetes/plugin/pkg/auth/authenticator/token/bootstrap" ) @@ -109,7 +108,7 @@ cluster's shared state through which all other components interact.`, SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { verflag.PrintAndExitIfRequested() - utilflag.PrintFlags(cmd.Flags()) + cliflag.PrintFlags(cmd.Flags()) // set default options completedOptions, err := Complete(s) diff --git a/cmd/kube-controller-manager/app/BUILD b/cmd/kube-controller-manager/app/BUILD index d2955f8f698..093cd2c7b73 100644 --- a/cmd/kube-controller-manager/app/BUILD +++ b/cmd/kube-controller-manager/app/BUILD @@ -86,7 +86,6 @@ go_library( "//pkg/quota/v1/install:go_default_library", "//pkg/serviceaccount:go_default_library", "//pkg/util/configz:go_default_library", - "//pkg/util/flag:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/awsebs:go_default_library", "//pkg/volume/azure_dd:go_default_library", diff --git a/cmd/kube-controller-manager/app/controllermanager.go b/cmd/kube-controller-manager/app/controllermanager.go index bd74763459d..eb15e7d2bb7 100644 --- a/cmd/kube-controller-manager/app/controllermanager.go +++ b/cmd/kube-controller-manager/app/controllermanager.go @@ -68,7 +68,6 @@ import ( "k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/serviceaccount" "k8s.io/kubernetes/pkg/util/configz" - utilflag "k8s.io/kubernetes/pkg/util/flag" ) const ( @@ -107,7 +106,7 @@ Kubernetes today are the replication controller, endpoints controller, namespace controller, and serviceaccounts controller.`, Run: func(cmd *cobra.Command, args []string) { verflag.PrintAndExitIfRequested() - utilflag.PrintFlags(cmd.Flags()) + cliflag.PrintFlags(cmd.Flags()) c, err := s.Config(KnownControllers(), ControllersDisabledByDefault.List()) if err != nil { diff --git a/cmd/kube-proxy/app/server.go b/cmd/kube-proxy/app/server.go index 376cfffc972..d3f7e0443ac 100644 --- a/cmd/kube-proxy/app/server.go +++ b/cmd/kube-proxy/app/server.go @@ -481,7 +481,7 @@ addon that provides cluster DNS for these cluster IPs. The user must create a se with the apiserver API to configure the proxy.`, Run: func(cmd *cobra.Command, args []string) { verflag.PrintAndExitIfRequested() - utilflag.PrintFlags(cmd.Flags()) + cliflag.PrintFlags(cmd.Flags()) if err := initForOS(opts.WindowsService); err != nil { klog.Fatalf("failed OS init: %v", err) diff --git a/cmd/kube-scheduler/app/BUILD b/cmd/kube-scheduler/app/BUILD index 1eb1fa553e7..f3c3d57e9e8 100644 --- a/cmd/kube-scheduler/app/BUILD +++ b/cmd/kube-scheduler/app/BUILD @@ -20,7 +20,6 @@ go_library( "//pkg/scheduler/metrics:go_default_library", "//pkg/scheduler/profile:go_default_library", "//pkg/util/configz:go_default_library", - "//pkg/util/flag:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/events/v1beta1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library", diff --git a/cmd/kube-scheduler/app/server.go b/cmd/kube-scheduler/app/server.go index 6e02fa159b5..068a3ae7ca4 100644 --- a/cmd/kube-scheduler/app/server.go +++ b/cmd/kube-scheduler/app/server.go @@ -60,7 +60,6 @@ import ( "k8s.io/kubernetes/pkg/scheduler/metrics" "k8s.io/kubernetes/pkg/scheduler/profile" "k8s.io/kubernetes/pkg/util/configz" - utilflag "k8s.io/kubernetes/pkg/util/flag" ) // Option configures a framework.Registry. @@ -117,7 +116,7 @@ for more information about scheduling and the kube-scheduler component.`, // runCommand runs the scheduler. func runCommand(cmd *cobra.Command, args []string, opts *options.Options, registryOptions ...Option) error { verflag.PrintAndExitIfRequested() - utilflag.PrintFlags(cmd.Flags()) + cliflag.PrintFlags(cmd.Flags()) ctx, cancel := context.WithCancel(context.Background()) defer cancel() diff --git a/cmd/kubelet/app/BUILD b/cmd/kubelet/app/BUILD index 1bc274fc631..67a5da579cd 100644 --- a/cmd/kubelet/app/BUILD +++ b/cmd/kubelet/app/BUILD @@ -72,7 +72,6 @@ go_library( "//pkg/kubelet/types:go_default_library", "//pkg/util/configz:go_default_library", "//pkg/util/filesystem:go_default_library", - "//pkg/util/flag:go_default_library", "//pkg/util/flock:go_default_library", "//pkg/util/node:go_default_library", "//pkg/util/oom:go_default_library", diff --git a/cmd/kubelet/app/server.go b/cmd/kubelet/app/server.go index e515500c600..35b9c8ffba2 100644 --- a/cmd/kubelet/app/server.go +++ b/cmd/kubelet/app/server.go @@ -95,7 +95,6 @@ import ( kubetypes "k8s.io/kubernetes/pkg/kubelet/types" "k8s.io/kubernetes/pkg/util/configz" utilfs "k8s.io/kubernetes/pkg/util/filesystem" - utilflag "k8s.io/kubernetes/pkg/util/flag" "k8s.io/kubernetes/pkg/util/flock" nodeutil "k8s.io/kubernetes/pkg/util/node" "k8s.io/kubernetes/pkg/util/oom" @@ -176,7 +175,7 @@ HTTP server: The kubelet can also listen for HTTP and respond to a simple API // short-circuit on verflag verflag.PrintAndExitIfRequested() - utilflag.PrintFlags(cleanFlagSet) + cliflag.PrintFlags(cleanFlagSet) // set feature gates from initial flags-based config if err := utilfeature.DefaultMutableFeatureGate.SetFromMap(kubeletConfig.FeatureGates); err != nil { diff --git a/pkg/util/flag/BUILD b/pkg/util/flag/BUILD index 9a8a7f1aaa1..4e5ac790111 100644 --- a/pkg/util/flag/BUILD +++ b/pkg/util/flag/BUILD @@ -13,7 +13,6 @@ go_library( deps = [ "//staging/src/k8s.io/apimachinery/pkg/util/net:go_default_library", "//vendor/github.com/spf13/pflag:go_default_library", - "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/net:go_default_library", ], ) diff --git a/pkg/util/flag/flags.go b/pkg/util/flag/flags.go index 5e991321acf..7c489e93ab3 100644 --- a/pkg/util/flag/flags.go +++ b/pkg/util/flag/flags.go @@ -21,19 +21,11 @@ import ( "net" "github.com/spf13/pflag" - "k8s.io/klog" utilnet "k8s.io/apimachinery/pkg/util/net" utilsnet "k8s.io/utils/net" ) -// PrintFlags logs the flags in the flagset -func PrintFlags(flags *pflag.FlagSet) { - flags.VisitAll(func(flag *pflag.Flag) { - klog.V(1).Infof("FLAG: --%s=%q", flag.Name, flag.Value) - }) -} - // TODO(mikedanese): remove these flag wrapper types when we remove command line flags var ( diff --git a/staging/src/k8s.io/component-base/cli/flag/flags.go b/staging/src/k8s.io/component-base/cli/flag/flags.go index d0fff8db2e4..9ee41b11430 100644 --- a/staging/src/k8s.io/component-base/cli/flag/flags.go +++ b/staging/src/k8s.io/component-base/cli/flag/flags.go @@ -52,3 +52,10 @@ func InitFlags() { klog.V(2).Infof("FLAG: --%s=%q", flag.Name, flag.Value) }) } + +// PrintFlags logs the flags in the flagset +func PrintFlags(flags *pflag.FlagSet) { + flags.VisitAll(func(flag *pflag.Flag) { + klog.V(1).Infof("FLAG: --%s=%q", flag.Name, flag.Value) + }) +}