Commit 01c7d129 authored by Lee Verberne's avatar Lee Verberne

Create a kubectl alpha subcommand

Alpha commands can be added under `kubectl alpha` and are always accessible (regardless of feature gates). If no alpha commands have been defined then `alpha` is not displayed in `help`.
parent 8ef68578
...@@ -10,6 +10,7 @@ docs/man/man1/kube-apiserver.1 ...@@ -10,6 +10,7 @@ docs/man/man1/kube-apiserver.1
docs/man/man1/kube-controller-manager.1 docs/man/man1/kube-controller-manager.1
docs/man/man1/kube-proxy.1 docs/man/man1/kube-proxy.1
docs/man/man1/kube-scheduler.1 docs/man/man1/kube-scheduler.1
docs/man/man1/kubectl-alpha.1
docs/man/man1/kubectl-annotate.1 docs/man/man1/kubectl-annotate.1
docs/man/man1/kubectl-api-versions.1 docs/man/man1/kubectl-api-versions.1
docs/man/man1/kubectl-apply-set-last-applied.1 docs/man/man1/kubectl-apply-set-last-applied.1
...@@ -189,6 +190,7 @@ docs/user-guide/kubectl/kubectl_top_pod.md ...@@ -189,6 +190,7 @@ docs/user-guide/kubectl/kubectl_top_pod.md
docs/user-guide/kubectl/kubectl_uncordon.md docs/user-guide/kubectl/kubectl_uncordon.md
docs/user-guide/kubectl/kubectl_version.md docs/user-guide/kubectl/kubectl_version.md
docs/yaml/kubectl/kubectl.yaml docs/yaml/kubectl/kubectl.yaml
docs/yaml/kubectl/kubectl_alpha.yaml
docs/yaml/kubectl/kubectl_annotate.yaml docs/yaml/kubectl/kubectl_annotate.yaml
docs/yaml/kubectl/kubectl_api-versions.yaml docs/yaml/kubectl/kubectl_api-versions.yaml
docs/yaml/kubectl/kubectl_apply.yaml docs/yaml/kubectl/kubectl_apply.yaml
......
This file is autogenerated, but we've stopped checking such files into the
repository to reduce the need for rebases. Please run hack/generate-docs.sh to
populate this file.
This file is autogenerated, but we've stopped checking such files into the
repository to reduce the need for rebases. Please run hack/generate-docs.sh to
populate this file.
...@@ -9,6 +9,7 @@ load( ...@@ -9,6 +9,7 @@ load(
go_library( go_library(
name = "go_default_library", name = "go_default_library",
srcs = [ srcs = [
"alpha.go",
"annotate.go", "annotate.go",
"apiversions.go", "apiversions.go",
"apply.go", "apply.go",
......
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"io"
"github.com/spf13/cobra"
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/util/i18n"
)
// NewCmdAlpha creates a command that acts as an alternate root command for features in alpha
func NewCmdAlpha(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "alpha",
Short: i18n.T("Commands for features in alpha"),
Long: templates.LongDesc(i18n.T("These commands correspond to alpha features that are not enabled in Kubernetes clusters by default.")),
}
// Alpha commands should be added here. As features graduate from alpha they should move
// from here to the CommandGroups defined by NewKubeletCommand() in cmd.go.
//cmd.AddCommand(NewCmdDebug(f, in, out, err))
// NewKubeletCommand() will hide the alpha command if it has no subcommands. Overriding
// the help function ensures a reasonable message if someone types the hidden command anyway.
if !cmd.HasSubCommands() {
cmd.SetHelpFunc(func(*cobra.Command, []string) {
cmd.Println(i18n.T("No alpha commands are available in this version of kubectl"))
})
}
return cmd
}
...@@ -354,6 +354,13 @@ func NewKubectlCommand(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cob ...@@ -354,6 +354,13 @@ func NewKubectlCommand(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cob
"options", "options",
Deprecated("kubectl", "delete", cmds, NewCmdStop(f, out)), Deprecated("kubectl", "delete", cmds, NewCmdStop(f, out)),
} }
// Hide the "alpha" subcommand if there are no alpha commands in this build.
alpha := NewCmdAlpha(f, in, out, err)
if !alpha.HasSubCommands() {
filters = append(filters, alpha.Name())
}
templates.ActsAsRootCommand(cmds, filters, groups...) templates.ActsAsRootCommand(cmds, filters, groups...)
for name, completion := range bash_completion_flags { for name, completion := range bash_completion_flags {
...@@ -368,6 +375,7 @@ func NewKubectlCommand(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cob ...@@ -368,6 +375,7 @@ func NewKubectlCommand(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cob
} }
} }
cmds.AddCommand(alpha)
cmds.AddCommand(cmdconfig.NewCmdConfig(clientcmd.NewDefaultPathOptions(), out, err)) cmds.AddCommand(cmdconfig.NewCmdConfig(clientcmd.NewDefaultPathOptions(), out, err))
cmds.AddCommand(NewCmdPlugin(f, in, out, err)) cmds.AddCommand(NewCmdPlugin(f, in, out, err))
cmds.AddCommand(NewCmdVersion(f, out)) cmds.AddCommand(NewCmdVersion(f, out))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment