Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#3716 from BenTheElder/cleanup-depr…
Browse files Browse the repository at this point in the history
…ecated

cleanup long-deprecated flags
  • Loading branch information
k8s-ci-robot authored Dec 9, 2024
2 parents 74acdf7 + 6a50aac commit 8759112
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 47 deletions.
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

0 comments on commit 8759112

Please sign in to comment.