Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
k8s.io/component-base/logs: fix usage through Go flag package
api/v1.AddFlags only supports a pflag.FlagSet. The assumption was that code which wants to use flag.FlagSet can use VisitAll to copy the flags. That works, with one caveat: the flag.FlagSet help implementation will call String for the zero value to determine whether the flag has a non-default value. This currently leads to additional warnings at the end of the -help output: panic calling String method on zero v1.verbosityLevelPflag for flag v: runtime error: invalid memory address or nil pointer dereference panic calling String method on zero v1.vmoduleConfigurationPFlag for flag vmodule: runtime error: invalid memory address or nil pointer dereference Supporting usage of methods with the zero value is good practice anyway and thus gets added. This then avoids these panics.
- Loading branch information