Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING: remove the default flag value for --v #12

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"io"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/component-base/logs"

Expand Down Expand Up @@ -51,23 +50,7 @@ func NewCertManagerCtlCommand(ctx context.Context, in io.Reader, out, err io.Wri
}
cmds.SetUsageTemplate(usageTemplate())

{
var logFlags pflag.FlagSet
logf.AddFlagsNonDeprecated(logOptions, &logFlags)

logFlags.VisitAll(func(f *pflag.Flag) {
switch f.Name {
case "v":
// "cmctl check api" already had a "v" flag that did not require any value, for
// backwards compatibility we allow the "v" logging flag to be set without a value
// and default to "2" (which will result in the same behaviour as before).
f.NoOptDefVal = "2"
cmds.PersistentFlags().AddFlag(f)
default:
cmds.PersistentFlags().AddFlag(f)
}
})
}
logf.AddFlagsNonDeprecated(logOptions, cmds.PersistentFlags())

ioStreams := genericclioptions.IOStreams{In: in, Out: out, ErrOut: err}
for _, registerCmd := range commands.Commands() {
Expand Down