mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Fix up logging flags for kubectl.
This commit is contained in:
parent
7ee327146a
commit
1d0b6ee5f5
@ -143,6 +143,10 @@ func (f *Factory) BindFlags(flags *pflag.FlagSet) {
|
|||||||
// any flags defined by external projects (not part of pflags)
|
// any flags defined by external projects (not part of pflags)
|
||||||
util.AddAllFlagsToPFlagSet(flags)
|
util.AddAllFlagsToPFlagSet(flags)
|
||||||
|
|
||||||
|
// This is necessary as github.com/spf13/cobra doesn't support "global"
|
||||||
|
// pflags currently. See https://github.com/spf13/cobra/issues/44.
|
||||||
|
util.AddPFlagSetToPFlagSet(pflag.CommandLine, flags)
|
||||||
|
|
||||||
if f.flags != nil {
|
if f.flags != nil {
|
||||||
f.flags.VisitAll(func(flag *pflag.Flag) {
|
f.flags.VisitAll(func(flag *pflag.Flag) {
|
||||||
flags.AddFlag(flag)
|
flags.AddFlag(flag)
|
||||||
|
@ -17,14 +17,15 @@ limitations under the License.
|
|||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
flag "github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
|
|
||||||
var logFlushFreq = flag.Duration("log_flush_frequency", 5*time.Second, "Maximum number of seconds between log flushes")
|
var logFlushFreq = pflag.Duration("log_flush_frequency", 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.
|
// TODO(thockin): This is temporary until we agree on log dirs and put those into each cmd.
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -87,3 +87,12 @@ func AddAllFlagsToPFlagSet(fs *pflag.FlagSet) {
|
|||||||
func AddAllFlagsToPFlags() {
|
func AddAllFlagsToPFlags() {
|
||||||
AddFlagSetToPFlagSet(flag.CommandLine, pflag.CommandLine)
|
AddFlagSetToPFlagSet(flag.CommandLine, pflag.CommandLine)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Merge all of the flags from fsFrom into fsTo.
|
||||||
|
func AddPFlagSetToPFlagSet(fsFrom *pflag.FlagSet, fsTo *pflag.FlagSet) {
|
||||||
|
fsFrom.VisitAll(func(f *pflag.Flag) {
|
||||||
|
if fsTo.Lookup(f.Name) == nil {
|
||||||
|
fsTo.AddFlag(f)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user