Documentation ¶
Index ¶
- Constants
- Variables
- func AddApplyAnnotationFlags(cmd *cobra.Command)
- func AddApplyAnnotationVarFlags(cmd *cobra.Command, applyAnnotation *bool)
- func AddDryRunFlag(cmd *cobra.Command)
- func AddFilenameOptionFlags(cmd *cobra.Command, options *resource.FilenameOptions, usage string)
- func AddGeneratorFlags(cmd *cobra.Command, defaultGenerator string)
- func AddIncludeUninitializedFlag(cmd *cobra.Command)
- func AddJsonFilenameFlag(flags *pflag.FlagSet, value *[]string, usage string)
- func AddKustomizeFlag(flags *pflag.FlagSet, value *string)
- func AddPodRunningTimeoutFlag(cmd *cobra.Command, defaultTimeout time.Duration)
- func AddServerSideApplyFlags(cmd *cobra.Command)
- func AddSourceToErr(verb string, source string, err error) error
- func AddValidateFlags(cmd *cobra.Command)
- func AddValidateOptionFlags(cmd *cobra.Command, options *ValidateOptions)
- func BehaviorOnFatal(f func(string, int))
- func CheckErr(err error)
- func DefaultBehaviorOnFatal()
- func DefaultSubCommandRun(out io.Writer) func(c *cobra.Command, args []string)
- func DumpReaderToFile(reader io.Reader, filename string) error
- func GetDryRunFlag(cmd *cobra.Command) bool
- func GetFieldManagerFlag(cmd *cobra.Command) string
- func GetFlagBool(cmd *cobra.Command, flag string) bool
- func GetFlagDuration(cmd *cobra.Command, flag string) time.Duration
- func GetFlagInt(cmd *cobra.Command, flag string) int
- func GetFlagInt32(cmd *cobra.Command, flag string) int32
- func GetFlagInt64(cmd *cobra.Command, flag string) int64
- func GetFlagString(cmd *cobra.Command, flag string) string
- func GetFlagStringArray(cmd *cobra.Command, flag string) []string
- func GetFlagStringSlice(cmd *cobra.Command, flag string) []string
- func GetForceConflictsFlag(cmd *cobra.Command) bool
- func GetPodRunningTimeoutFlag(cmd *cobra.Command) (time.Duration, error)
- func GetResourcesAndPairs(args []string, pairType string) (resources []string, pairArgs []string, err error)
- func GetServerSideApplyFlag(cmd *cobra.Command) bool
- func IsFilenameSliceEmpty(filenames []string, directory string) bool
- func IsSiblingCommandExists(cmd *cobra.Command, targetCmdName string) bool
- func ManualStrip(file []byte) []byte
- func Merge(codec runtime.Codec, dst runtime.Object, fragment string) (runtime.Object, error)
- func MultilineError(prefix string, err error) string
- func MultipleErrors(prefix string, errs []error) string
- func ParsePairs(pairArgs []string, pairType string, supportRemove bool) (newPairs map[string]string, removePairs []string, err error)
- func PrintErrorWithCauses(err error, errOut io.Writer) bool
- func RequireNoArguments(c *cobra.Command, args []string)
- func StandardErrorMessage(err error) (string, bool)
- func StripComments(file []byte) []byte
- func SuggestAPIResources(parent string) string
- func UsageErrorf(cmd *cobra.Command, format string, args ...interface{}) error
- func Warning(cmdErr io.Writer, newGeneratorName, oldGeneratorName string)
- type CRDFinder
- type CRDGetter
- type Factory
- type MatchVersionFlags
- func (f *MatchVersionFlags) AddFlags(flags *pflag.FlagSet)
- func (f *MatchVersionFlags) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
- func (f *MatchVersionFlags) ToRESTConfig() (*rest.Config, error)
- func (f *MatchVersionFlags) ToRESTMapper() (meta.RESTMapper, error)
- func (f *MatchVersionFlags) ToRawKubeConfigLoader() clientcmd.ClientConfig
- type ScaleClientFunc
- type ValidateOptions
Constants ¶
const ( ApplyAnnotationsFlag = "save-config" DefaultErrorExitCode = 1 )
Variables ¶
var ErrExit = fmt.Errorf("exit")
ErrExit may be passed to CheckError to instruct it to output nothing but exit with status code 1.
Functions ¶
func AddApplyAnnotationFlags ¶ added in v1.2.3
func AddApplyAnnotationVarFlags ¶ added in v1.7.0
func AddDryRunFlag ¶ added in v1.3.0
AddDryRunFlag adds dry-run flag to a command. Usually used by mutations.
func AddFilenameOptionFlags ¶ added in v1.5.0
func AddFilenameOptionFlags(cmd *cobra.Command, options *resource.FilenameOptions, usage string)
func AddGeneratorFlags ¶ added in v1.2.3
AddGeneratorFlags adds flags common to resource generation commands TODO: need to take a pass at other generator commands to use this set of flags
func AddIncludeUninitializedFlag ¶ added in v1.8.0
func AddJsonFilenameFlag ¶ added in v1.11.2
func AddKustomizeFlag ¶ added in v1.14.0
AddKustomizeFlag adds kustomize flag to a command
func AddPodRunningTimeoutFlag ¶ added in v1.7.0
func AddServerSideApplyFlags ¶ added in v1.14.0
func AddSourceToErr ¶ added in v0.20.0
AddSourceToErr adds handleResourcePrefix and source string to error message. verb is the string like "creating", "deleting" etc. source is the filename or URL to the template file(*.json or *.yaml), or stdin to use to handle the resource.
func AddValidateFlags ¶ added in v1.1.1
func AddValidateOptionFlags ¶ added in v1.7.0
func AddValidateOptionFlags(cmd *cobra.Command, options *ValidateOptions)
func BehaviorOnFatal ¶ added in v1.1.1
BehaviorOnFatal allows you to override the default behavior when a fatal error occurs, which is to call os.Exit(code). You can pass 'panic' as a function here if you prefer the panic() over os.Exit(1).
func CheckErr ¶
func CheckErr(err error)
CheckErr prints a user friendly error to STDERR and exits with a non-zero exit code. Unrecognized errors will be printed with an "error: " prefix.
This method is generic to the command in use and may be used by non-Kubectl commands.
func DefaultBehaviorOnFatal ¶ added in v1.2.3
func DefaultBehaviorOnFatal()
DefaultBehaviorOnFatal allows you to undo any previous override. Useful in tests.
func DefaultSubCommandRun ¶ added in v1.5.0
DefaultSubCommandRun prints a command's help string to the specified output if no arguments (sub-commands) are provided, or a usage error otherwise.
func DumpReaderToFile ¶ added in v1.1.1
DumpReaderToFile writes all data from the given io.Reader to the specified file (usually for temporary use).
func GetDryRunFlag ¶ added in v1.3.0
func GetFieldManagerFlag ¶ added in v1.14.0
func GetFlagInt ¶
Assumes the flag has a default value.
func GetFlagInt32 ¶ added in v1.9.0
Assumes the flag has a default value.
func GetFlagInt64 ¶ added in v1.1.1
Assumes the flag has a default value.
func GetFlagStringArray ¶ added in v1.5.0
GetFlagStringArray can be used to accept multiple argument with flag repetition (e.g. -f arg1 -f arg2 ...)
func GetFlagStringSlice ¶ added in v1.1.1
GetFlagStringSlice can be used to accept multiple argument with flag repetition (e.g. -f arg1,arg2 -f arg3 ...)
func GetForceConflictsFlag ¶ added in v1.14.0
func GetPodRunningTimeoutFlag ¶ added in v1.7.0
func GetResourcesAndPairs ¶ added in v1.3.0
func GetResourcesAndPairs(args []string, pairType string) (resources []string, pairArgs []string, err error)
GetResourcesAndPairs retrieves resources and "KEY=VALUE or KEY-" pair args from given args
func GetServerSideApplyFlag ¶ added in v1.14.0
func IsFilenameSliceEmpty ¶ added in v1.8.0
func IsSiblingCommandExists ¶ added in v1.5.0
IsSiblingCommandExists receives a pointer to a cobra command and a target string. Returns true if the target string is found in the list of sibling commands.
func ManualStrip ¶ added in v1.7.0
ManualStrip is used for dropping comments from a YAML file
func Merge ¶
Merge requires JSON serialization TODO: merge assumes JSON serialization, and does not properly abstract API retrieval
func MultilineError ¶ added in v0.15.0
MultilineError returns a string representing an error that splits sub errors into their own lines. The returned string will end with a newline.
func MultipleErrors ¶ added in v0.18.0
MultipleErrors returns a newline delimited string containing the prefix and referenced errors in standard form.
func ParsePairs ¶ added in v1.3.0
func ParsePairs(pairArgs []string, pairType string, supportRemove bool) (newPairs map[string]string, removePairs []string, err error)
ParsePairs retrieves new and remove pairs (if supportRemove is true) from "KEY=VALUE or KEY-" pair args
func PrintErrorWithCauses ¶ added in v1.5.0
PrintErrorWithCauses prints an error's kind, name, and each of the error's causes in a new line. The returned string will end with a newline. Returns true if a case exists to handle the error type, or false otherwise.
func RequireNoArguments ¶ added in v1.5.0
RequireNoArguments exits with a usage error if extra arguments are provided.
func StandardErrorMessage ¶ added in v0.18.0
StandardErrorMessage translates common errors into a human readable message, or returns false if the error is not one of the recognized types. It may also log extended information to klog.
This method is generic to the command in use and may be used by non-Kubectl commands.
func StripComments ¶ added in v1.7.0
StripComments will transform a YAML file into JSON, thus dropping any comments in it. Note that if the given file has a syntax error, the transformation will fail and we will manually drop all comments from the file.
func SuggestAPIResources ¶ added in v1.14.0
SuggestAPIResources returns a suggestion to use the "api-resources" command to retrieve a supported list of resources
func UsageErrorf ¶ added in v1.8.0
Types ¶
type CRDFinder ¶ added in v1.13.1
CRDFinder keeps a cache of known CRDs and finds a given GVK in the list.
func NewCRDFinder ¶ added in v1.13.1
type CRDGetter ¶ added in v1.13.1
CRDGetter is a function that can download the list of GVK for all CRDs.
func CRDFromDynamic ¶ added in v1.13.1
type Factory ¶ added in v0.15.0
type Factory interface { genericclioptions.RESTClientGetter // DynamicClient returns a dynamic client ready for use DynamicClient() (dynamic.Interface, error) // KubernetesClientSet gives you back an external clientset KubernetesClientSet() (*kubernetes.Clientset, error) // Returns a RESTClient for accessing Kubernetes resources or an error. RESTClient() (*restclient.RESTClient, error) // NewBuilder returns an object that assists in loading objects from both disk and the server // and which implements the common patterns for CLI interactions with generic resources. NewBuilder() *resource.Builder // Returns a RESTClient for working with the specified RESTMapping or an error. This is intended // for working with arbitrary resources and is not guaranteed to point to a Kubernetes APIServer. ClientForMapping(mapping *meta.RESTMapping) (resource.RESTClient, error) // Returns a RESTClient for working with Unstructured objects. UnstructuredClientForMapping(mapping *meta.RESTMapping) (resource.RESTClient, error) // Returns a schema that can validate objects stored on disk. Validator(validate bool) (validation.Schema, error) // OpenAPISchema returns the schema openapi schema definition OpenAPISchema() (openapi.Resources, error) }
Factory provides abstractions that allow the Kubectl command to be extended across multiple types of resources and different API sets. The rings are here for a reason. In order for composers to be able to provide alternative factory implementations they need to provide low level pieces of *certain* functions so that when the factory calls back into itself it uses the custom version of the function. Rather than try to enumerate everything that someone would want to override we split the factory into rings, where each ring can depend on methods in an earlier ring, but cannot depend upon peer methods in its own ring. TODO: make the functions interfaces TODO: pass the various interfaces on the factory directly into the command constructors (so the commands are decoupled from the factory).
func NewFactory ¶ added in v0.15.0
func NewFactory(clientGetter genericclioptions.RESTClientGetter) Factory
type MatchVersionFlags ¶ added in v1.11.2
type MatchVersionFlags struct { Delegate genericclioptions.RESTClientGetter RequireMatchedServerVersion bool // contains filtered or unexported fields }
MatchVersionFlags is for setting the "match server version" function.
func NewMatchVersionFlags ¶ added in v1.11.2
func NewMatchVersionFlags(delegate genericclioptions.RESTClientGetter) *MatchVersionFlags
func (*MatchVersionFlags) AddFlags ¶ added in v1.11.2
func (f *MatchVersionFlags) AddFlags(flags *pflag.FlagSet)
func (*MatchVersionFlags) ToDiscoveryClient ¶ added in v1.11.2
func (f *MatchVersionFlags) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
func (*MatchVersionFlags) ToRESTConfig ¶ added in v1.11.2
func (f *MatchVersionFlags) ToRESTConfig() (*rest.Config, error)
ToRESTConfig implements RESTClientGetter. Returns a REST client configuration based on a provided path to a .kubeconfig file, loading rules, and config flag overrides. Expects the AddFlags method to have been called.
func (*MatchVersionFlags) ToRESTMapper ¶ added in v1.11.2
func (f *MatchVersionFlags) ToRESTMapper() (meta.RESTMapper, error)
ToRESTMapper returns a mapper.
func (*MatchVersionFlags) ToRawKubeConfigLoader ¶ added in v1.11.2
func (f *MatchVersionFlags) ToRawKubeConfigLoader() clientcmd.ClientConfig
type ScaleClientFunc ¶ added in v1.11.2
type ScaleClientFunc func(genericclioptions.RESTClientGetter) (scale.ScalesGetter, error)
ScaleClientFunc provides a ScalesGetter
var ScaleClientFn ScaleClientFunc = scaleClient
ScaleClientFn gives a way to easily override the function for unit testing if needed.
type ValidateOptions ¶ added in v1.7.0
type ValidateOptions struct {
EnableValidation bool
}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package openapi is a collection of libraries for fetching the openapi spec from a Kubernetes server and then indexing the type definitions.
|
Package openapi is a collection of libraries for fetching the openapi spec from a Kubernetes server and then indexing the type definitions. |