alpha.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. Copyright 2017 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package cmd
  14. import (
  15. "github.com/spf13/cobra"
  16. "k8s.io/cli-runtime/pkg/genericclioptions"
  17. cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
  18. "k8s.io/kubernetes/pkg/kubectl/util/i18n"
  19. "k8s.io/kubernetes/pkg/kubectl/util/templates"
  20. )
  21. // NewCmdAlpha creates a command that acts as an alternate root command for features in alpha
  22. func NewCmdAlpha(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
  23. cmd := &cobra.Command{
  24. Use: "alpha",
  25. Short: i18n.T("Commands for features in alpha"),
  26. Long: templates.LongDesc(i18n.T("These commands correspond to alpha features that are not enabled in Kubernetes clusters by default.")),
  27. }
  28. // Alpha commands should be added here. As features graduate from alpha they should move
  29. // from here to the CommandGroups defined by NewKubeletCommand() in cmd.go.
  30. //cmd.AddCommand(NewCmdDebug(f, in, out, err))
  31. // NewKubeletCommand() will hide the alpha command if it has no subcommands. Overriding
  32. // the help function ensures a reasonable message if someone types the hidden command anyway.
  33. if !cmd.HasSubCommands() {
  34. cmd.SetHelpFunc(func(*cobra.Command, []string) {
  35. cmd.Println(i18n.T("No alpha commands are available in this version of kubectl"))
  36. })
  37. }
  38. return cmd
  39. }