Improve kubectl help with examples.

This commit is contained in:
Phillip Wittrock
2017-01-06 12:05:08 -08:00
parent 8ef6902516
commit dc2fffe5d4
10 changed files with 113 additions and 29 deletions

View File

@@ -25,9 +25,16 @@ import (
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
)
var (
use_context_example = templates.Examples(`
# Use the context for the minikube cluster
kubectl config use-context minikube`)
)
type useContextOptions struct {
configAccess clientcmd.ConfigAccess
contextName string
@@ -37,9 +44,10 @@ func NewCmdConfigUseContext(out io.Writer, configAccess clientcmd.ConfigAccess)
options := &useContextOptions{configAccess: configAccess}
cmd := &cobra.Command{
Use: "use-context CONTEXT_NAME",
Short: "Sets the current-context in a kubeconfig file",
Long: `Sets the current-context in a kubeconfig file`,
Use: "use-context CONTEXT_NAME",
Short: "Sets the current-context in a kubeconfig file",
Long: `Sets the current-context in a kubeconfig file`,
Example: use_context_example,
Run: func(cmd *cobra.Command, args []string) {
if !options.complete(cmd) {
return