...

Source file src/k8s.io/kubectl/pkg/cmd/alpha.go

Documentation: k8s.io/kubectl/pkg/cmd

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

View as plain text