util

package
v1.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 22 Imported by: 62

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AlphaDisclaimer to be places at the end of description of commands in alpha release
	AlphaDisclaimer = `
		Alpha Disclaimer: this command is currently alpha.
	`

	// MacroCommandLongDescription provide a standard description for "macro" commands
	MacroCommandLongDescription = LongDesc(`
		This command is not meant to be run on its own. See list of available subcommands.
	`)
)

Functions

func AddCRISocketFlag added in v1.14.0

func AddCRISocketFlag(flagSet *pflag.FlagSet, criSocket *string)

AddCRISocketFlag adds the cri-socket flag to the supplied flagSet

func Examples added in v1.16.0

func Examples(s string) string

Examples is designed to help with producing examples for command line usage. Its behavior is mimicking a similar kubectl function in the following ways: - Beginning and trailing space characters (including empty lines), are stripped from the output. - All lines of text are stripped of beginning and trailing spaces (thus loosing indentation) and are then double-space indented.

func GetClientSet added in v1.26.0

func GetClientSet(file string, dryRun bool) (clientset.Interface, error)

GetClientSet gets a real or fake client depending on whether the user is dry-running or not

func GetJoinControlPlaneCommand added in v1.14.0

func GetJoinControlPlaneCommand(kubeConfigFile, token, key string, skipTokenPrint, skipCertificateKeyPrint bool) (string, error)

GetJoinControlPlaneCommand returns the kubeadm join command for a given token and Kubernetes cluster (the current cluster in the kubeconfig file)

func GetJoinWorkerCommand added in v1.14.0

func GetJoinWorkerCommand(kubeConfigFile, token string, skipTokenPrint bool) (string, error)

GetJoinWorkerCommand returns the kubeadm join command for a given token and Kubernetes cluster (the current cluster in the kubeconfig file)

func GetKubeConfigPath added in v1.14.0

func GetKubeConfigPath(file string) string

GetKubeConfigPath can be used to search for a kubeconfig in standard locations if and empty string is passed to the function. If a non-empty string is passed the function returns the same string.

func InteractivelyConfirmAction added in v1.25.0

func InteractivelyConfirmAction(action, question string, r io.Reader) error

InteractivelyConfirmAction asks the user whether they _really_ want to take the action.

func LongDesc added in v1.16.0

func LongDesc(s string) string

LongDesc is designed to help with producing better long command line descriptions in code. Its behavior is somewhat inspired by the same function of kubectl, which uses Markdown for the input message. This one is not Markdown compliant, but it covers the needs of kubeadm. In particular: - Beginning and trailing space characters (including empty lines), are stripped from the output. - Consecutive non-empty lines of text are joined with spaces to form paragraphs. - Paragraphs are blocks of text divided by one or more empty lines or lines consisting only of "space" characters. - Paragraphs are spaced by precisely one empty line in the output. - A line break can be forced by adding a couple of empty spaces at the end of a text line. - All indentation is removed. The resulting output is not indented.

func SubCmdRun added in v1.26.0

func SubCmdRun() func(c *cobra.Command, args []string)

SubCmdRun returns a function that handles a case where a subcommand must be specified Without this callback, if a user runs just the command without a subcommand, or with an invalid subcommand, cobra will print usage information, but still exit cleanly.

func TypeMismatchErr added in v1.30.0

func TypeMismatchErr(opt, rType string) error

TypeMismatchErr return an error which indicates how the type is mismatched.

func ValidateExactArgNumber

func ValidateExactArgNumber(args []string, supportedArgs []string) error

ValidateExactArgNumber validates that the required top-level arguments are specified

func ValueFromFlagsOrConfig added in v1.28.0

func ValueFromFlagsOrConfig(flagSet *pflag.FlagSet, name string, cfgValue interface{}, flagValue interface{}) interface{}

ValueFromFlagsOrConfig checks if the "name" flag has been set. If yes, it returns the value of the flag, otherwise it returns the value from config.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL