From d1a7006fcacf01213080b72aaa1527e5882f1a8a Mon Sep 17 00:00:00 2001 From: Michael Taufen Date: Sun, 24 Dec 2017 19:19:46 -0600 Subject: [PATCH] All Kubelet flags should be explicitly registered This explicitly registers Kubelet flags from libraries that were registering flags globally, and stops parsing the global flag set. In general, we should always be explicit about flags we register and parse, so that we maintain control over our command-line API. Kubernetes-commit: 8ec1958667e66fb3da2a1f1428998f59f8b027f2 --- pkg/util/logs/logs.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/util/logs/logs.go b/pkg/util/logs/logs.go index a3909583a..c5ba084a5 100644 --- a/pkg/util/logs/logs.go +++ b/pkg/util/logs/logs.go @@ -26,13 +26,21 @@ import ( "k8s.io/apimachinery/pkg/util/wait" ) -var logFlushFreq = pflag.Duration("log-flush-frequency", 5*time.Second, "Maximum number of seconds between log flushes") +const logFlushFreqFlagName = "log-flush-frequency" + +var logFlushFreq = pflag.Duration(logFlushFreqFlagName, 5*time.Second, "Maximum number of seconds between log flushes") // TODO(thockin): This is temporary until we agree on log dirs and put those into each cmd. func init() { flag.Set("logtostderr", "true") } +// AddFlags registers this package's flags on arbitrary FlagSets, such that they point to the +// same value as the global flags. +func AddFlags(fs *pflag.FlagSet) { + fs.AddFlag(pflag.Lookup(logFlushFreqFlagName)) +} + // GlogWriter serves as a bridge between the standard log package and the glog package. type GlogWriter struct{}