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

cleanup long-deprecated flags #3716

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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: 3 additions & 16 deletions pkg/cmd/kind/build/nodeimage/nodeimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ type flagpole struct {
BuildType string
Image string
BaseImage string
KubeRoot string
Arch string
}

Expand All @@ -44,12 +43,6 @@ func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command {
Short: "Build the node image",
Long: "Build the node image which contains Kubernetes build artifacts and other kind requirements",
RunE: func(cmd *cobra.Command, args []string) error {
if cmd.Flags().Lookup("kube-root").Changed {
if len(args) != 0 {
return errors.New("passing an argument and deprecated --kube-root is not supported, please switch to just the argument")
}
logger.Warn("--kube-root is deprecated, please switch to passing this as an argument")
}
return runE(logger, flags, args)
},
}
Expand All @@ -65,12 +58,6 @@ func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command {
nodeimage.DefaultImage,
"name:tag of the resulting image to be built",
)
cmd.Flags().StringVar(
&flags.KubeRoot,
"kube-root",
"",
"DEPRECATED: please switch to just the argument. Path to the Kubernetes source directory (if empty, the path is autodetected)",
)
cmd.Flags().StringVar(
&flags.BaseImage,
"base-image",
Expand All @@ -87,14 +74,14 @@ func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command {
}

func runE(logger log.Logger, flags *flagpole, args []string) error {
kubeRoot := flags.KubeRoot
sourceSpec := ""
if len(args) > 0 {
kubeRoot = args[0]
sourceSpec = args[0]
}
if err := nodeimage.Build(
nodeimage.WithImage(flags.Image),
nodeimage.WithBaseImage(flags.BaseImage),
nodeimage.WithKubeParam(kubeRoot),
nodeimage.WithKubeParam(sourceSpec),
nodeimage.WithLogger(logger),
nodeimage.WithArch(flags.Arch),
nodeimage.WithBuildType(flags.BuildType),
Expand Down
30 changes: 2 additions & 28 deletions pkg/cmd/kind/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
)

type flagpole struct {
LogLevel string
Verbosity int32
Quiet bool
}
Expand All @@ -49,20 +48,14 @@ func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command {
Short: "kind is a tool for managing local Kubernetes clusters",
Long: "kind creates and manages local Kubernetes clusters using Docker container 'nodes'",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return runE(logger, flags, cmd)
return runE(logger, flags)
},
SilenceUsage: true,
SilenceErrors: true,
Version: version.Version(),
}
cmd.SetOut(streams.Out)
cmd.SetErr(streams.ErrOut)
cmd.PersistentFlags().StringVar(
&flags.LogLevel,
"loglevel",
"",
"DEPRECATED: see -v instead",
)
cmd.PersistentFlags().Int32VarP(
&flags.Verbosity,
"verbosity",
Expand All @@ -89,33 +82,14 @@ func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command {
return cmd
}

func runE(logger log.Logger, flags *flagpole, command *cobra.Command) error {
// handle limited migration for --loglevel
setLogLevel := command.Flag("loglevel").Changed
setVerbosity := command.Flag("verbosity").Changed
if setLogLevel && !setVerbosity {
switch flags.LogLevel {
case "debug":
flags.Verbosity = 3
case "trace":
flags.Verbosity = 2147483647
}
}
func runE(logger log.Logger, flags *flagpole) error {
// normal logger setup
if flags.Quiet {
// NOTE: if we are coming from app.Run handling this flag is
// redundant, however it doesn't hurt, and this may be called directly.
maybeSetWriter(logger, io.Discard)
}
maybeSetVerbosity(logger, log.Level(flags.Verbosity))
// warn about deprecated flag if used
if setLogLevel {
if cmd.ColorEnabled(logger) {
logger.Warn("\x1b[93mWARNING\x1b[0m: --loglevel is deprecated, please switch to -v and -q!")
} else {
logger.Warn("WARNING: --loglevel is deprecated, please switch to -v and -q!")
}
}
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions site/content/docs/user/known-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ Flags:
--base-image string name:tag of the base image to use for the build (default "kindest/base:v20181203-d055041")
-h, --help help for node-image
--image string name:tag of the resulting image to be built (default "kindest/node:latest")
--kube-root string Path to the Kubernetes source directory (if empty, the path is autodetected)
--type string build type, default is docker (default "docker")

Global Flags:
--loglevel string logrus log level [panic, fatal, error, warning, info, debug] (default "warning")
-q, --quiet silence all stderr output
-v, --verbosity int32 info log verbosity, higher value produces more output

error building node image: failed to build kubernetes: failed to build images: exit status 2
```
Expand Down
2 changes: 1 addition & 1 deletion site/content/docs/user/working-offline.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ You can clone Kubernetes source code.
### Building image

```sh
➜ ~ kind build node-image --image kindest/node:main --kube-root $GOPATH/src/k8s.io/kubernetes
➜ ~ kind build node-image --image kindest/node:main $GOPATH/src/k8s.io/kubernetes
Starting to build Kubernetes
...
Image build completed.
Expand Down
Loading