Documentation ¶
Index ¶
- Constants
- func GetApplyFieldManagerFlag(cmd *cobra.Command, serverSide bool) string
- func NewCmdApply(baseName string, f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command
- func NewCmdApplyEditLastApplied(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command
- func NewCmdApplySetLastApplied(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command
- func NewCmdApplyViewLastApplied(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command
- func WarnIfDeleting(obj runtime.Object, stderr io.Writer)
- type ApplyFlags
- type ApplyOptions
- func (o *ApplyOptions) GetObjects() ([]*resource.Info, error)
- func (o *ApplyOptions) MarkNamespaceVisited(info *resource.Info)
- func (o *ApplyOptions) MarkObjectVisited(info *resource.Info) error
- func (o *ApplyOptions) PrintAndPrunePostProcessor() func() error
- func (o *ApplyOptions) Run() error
- func (o *ApplyOptions) SetObjects(infos []*resource.Info)
- func (o *ApplyOptions) Validate(cmd *cobra.Command, args []string) error
- type PatchBuffer
- type Patcher
- type SetLastAppliedOptions
- type ViewLastAppliedOptions
Constants ¶
const ( // FieldManagerClientSideApply is the default client-side apply field manager. // // The default field manager is not `kubectl-apply` to distinguish from // server-side apply. FieldManagerClientSideApply = "kubectl-client-side-apply" )
Variables ¶
This section is empty.
Functions ¶
func GetApplyFieldManagerFlag ¶
GetApplyFieldManagerFlag gets the field manager for kubectl apply if it is not set.
The default field manager is not `kubectl-apply` to distinguish between client-side and server-side apply.
func NewCmdApply ¶
func NewCmdApply(baseName string, f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command
NewCmdApply creates the `apply` command
func NewCmdApplyEditLastApplied ¶
func NewCmdApplyEditLastApplied(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command
NewCmdApplyEditLastApplied created the cobra CLI command for the `apply edit-last-applied` command.
func NewCmdApplySetLastApplied ¶
func NewCmdApplySetLastApplied(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command
NewCmdApplySetLastApplied creates the cobra CLI `apply` subcommand `set-last-applied`.`
func NewCmdApplyViewLastApplied ¶
func NewCmdApplyViewLastApplied(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command
NewCmdApplyViewLastApplied creates the cobra CLI `apply` subcommand `view-last-applied`.`
Types ¶
type ApplyFlags ¶
type ApplyFlags struct { Factory cmdutil.Factory RecordFlags *genericclioptions.RecordFlags PrintFlags *genericclioptions.PrintFlags DeleteFlags *delete.DeleteFlags FieldManager string Selector string Prune bool PruneResources []prune.Resource All bool Overwrite bool OpenAPIPatch bool PruneWhitelist []string genericclioptions.IOStreams }
ApplyFlags directly reflect the information that CLI is gathering via flags. They will be converted to Options, which reflect the runtime requirements for the command. This structure reduces the transformation to wiring and makes the logic itself easy to unit test
func NewApplyFlags ¶
func NewApplyFlags(f cmdutil.Factory, streams genericclioptions.IOStreams) *ApplyFlags
NewApplyFlags returns a default ApplyFlags
func (*ApplyFlags) AddFlags ¶
func (flags *ApplyFlags) AddFlags(cmd *cobra.Command)
AddFlags registers flags for a cli
func (*ApplyFlags) ToOptions ¶
func (flags *ApplyFlags) ToOptions(cmd *cobra.Command, baseName string, args []string) (*ApplyOptions, error)
ToOptions converts from CLI inputs to runtime inputs
type ApplyOptions ¶
type ApplyOptions struct { Recorder genericclioptions.Recorder PrintFlags *genericclioptions.PrintFlags ToPrinter func(string) (printers.ResourcePrinter, error) DeleteOptions *delete.DeleteOptions ServerSideApply bool ForceConflicts bool FieldManager string Selector string DryRunStrategy cmdutil.DryRunStrategy DryRunVerifier *resource.QueryParamVerifier Prune bool PruneResources []prune.Resource All bool Overwrite bool OpenAPIPatch bool PruneWhitelist []string Validator validation.Schema Builder *resource.Builder Mapper meta.RESTMapper DynamicClient dynamic.Interface OpenAPISchema openapi.Resources Namespace string EnforceNamespace bool genericclioptions.IOStreams // Stores visited objects/namespaces for later use // calculating the set of objects to prune. VisitedUids sets.String VisitedNamespaces sets.String // Function run after the objects are generated and // stored in the "objects" field, but before the // apply is run on these objects. PreProcessorFn func() error // Function run after all objects have been applied. // The standard PostProcessorFn is "PrintAndPrunePostProcessor()". PostProcessorFn func() error // contains filtered or unexported fields }
ApplyOptions defines flags and other configuration parameters for the `apply` command
func (*ApplyOptions) GetObjects ¶
func (o *ApplyOptions) GetObjects() ([]*resource.Info, error)
GetObjects returns a (possibly cached) version of all the valid objects to apply as a slice of pointer to resource.Info and an error if one or more occurred. IMPORTANT: This function can return both valid objects AND an error, since "ContinueOnError" is set on the builder. This function should not be called until AFTER the "complete" and "validate" methods have been called to ensure that the ApplyOptions is filled in and valid.
func (*ApplyOptions) MarkNamespaceVisited ¶
func (o *ApplyOptions) MarkNamespaceVisited(info *resource.Info)
MarkNamespaceVisited keeps track of which namespaces the applied objects belong to. Used for pruning.
func (*ApplyOptions) MarkObjectVisited ¶
func (o *ApplyOptions) MarkObjectVisited(info *resource.Info) error
MarkObjectVisited keeps track of UIDs of the applied objects. Used for pruning.
func (*ApplyOptions) PrintAndPrunePostProcessor ¶
func (o *ApplyOptions) PrintAndPrunePostProcessor() func() error
PrintAndPrunePostProcessor returns a function which meets the PostProcessorFn function signature. This returned function prints all the objects as a list (if configured for that), and prunes the objects not applied. The returned function is the standard apply post processor.
func (*ApplyOptions) SetObjects ¶
func (o *ApplyOptions) SetObjects(infos []*resource.Info)
SetObjects stores the set of objects (as resource.Info) to be subsequently applied.
type PatchBuffer ¶
PatchBuffer caches changes that are to be applied.
type Patcher ¶
type Patcher struct { Mapping *meta.RESTMapping Helper *resource.Helper Overwrite bool BackOff clockwork.Clock Force bool CascadingStrategy metav1.DeletionPropagation Timeout time.Duration GracePeriod int // If set, forces the patch against a specific resourceVersion ResourceVersion *string // Number of retries to make if the patch fails with conflict Retries int OpenapiSchema openapi.Resources }
Patcher defines options to patch OpenAPI objects.
func (*Patcher) Patch ¶
func (p *Patcher) Patch(current runtime.Object, modified []byte, source, namespace, name string, errOut io.Writer) ([]byte, runtime.Object, error)
Patch tries to patch an OpenAPI resource. On success, returns the merge patch as well the final patched object. On failure, returns an error.
type SetLastAppliedOptions ¶
type SetLastAppliedOptions struct { CreateAnnotation bool PrintFlags *genericclioptions.PrintFlags PrintObj printers.ResourcePrinterFunc FilenameOptions resource.FilenameOptions genericclioptions.IOStreams // contains filtered or unexported fields }
SetLastAppliedOptions defines options for the `apply set-last-applied` command.`
func NewSetLastAppliedOptions ¶
func NewSetLastAppliedOptions(ioStreams genericclioptions.IOStreams) *SetLastAppliedOptions
NewSetLastAppliedOptions takes option arguments from a CLI stream and returns it at SetLastAppliedOptions type.
func (*SetLastAppliedOptions) RunSetLastApplied ¶
func (o *SetLastAppliedOptions) RunSetLastApplied() error
RunSetLastApplied executes the `set-last-applied` command according to SetLastAppliedOptions.
func (*SetLastAppliedOptions) Validate ¶
func (o *SetLastAppliedOptions) Validate() error
Validate checks SetLastAppliedOptions for validity.
type ViewLastAppliedOptions ¶
type ViewLastAppliedOptions struct { FilenameOptions resource.FilenameOptions Selector string LastAppliedConfigurationList []string OutputFormat string All bool Factory cmdutil.Factory genericclioptions.IOStreams }
ViewLastAppliedOptions defines options for the `apply view-last-applied` command.`
func NewViewLastAppliedOptions ¶
func NewViewLastAppliedOptions(ioStreams genericclioptions.IOStreams) *ViewLastAppliedOptions
NewViewLastAppliedOptions takes option arguments from a CLI stream and returns it at ViewLastAppliedOptions type.
func (*ViewLastAppliedOptions) Complete ¶
func (o *ViewLastAppliedOptions) Complete(cmd *cobra.Command, f cmdutil.Factory, args []string) error
Complete checks an object for last-applied-configuration annotations.
func (*ViewLastAppliedOptions) RunApplyViewLastApplied ¶
func (o *ViewLastAppliedOptions) RunApplyViewLastApplied(cmd *cobra.Command) error
RunApplyViewLastApplied executes the `view-last-applied` command according to ViewLastAppliedOptions.