mirror of https://github.com/fluxcd/cli-utils.git
Merge pull request #168 from mortent/SupportWaitForPrune
Add flags for waiting for pruned resources to be deleted
This commit is contained in:
commit
fde6a97711
|
|
@ -58,6 +58,10 @@ func GetApplyRunner(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *A
|
|||
"If true, do not prune previously applied objects.")
|
||||
cmd.Flags().StringVar(&r.prunePropagationPolicy, "prune-propagation-policy",
|
||||
"Background", "Propagation policy for pruning")
|
||||
cmd.Flags().BoolVar(&r.waitForPrune, "wait-for-prune", false,
|
||||
"Wait for all pruned resources to be deleted.")
|
||||
cmd.Flags().DurationVar(&r.waitForPruneTimeout, "wait-for-prune-timeout", 1*time.Minute,
|
||||
"Timeout threshold for waiting for all pruned resources to be deleted")
|
||||
|
||||
r.command = cmd
|
||||
return r
|
||||
|
|
@ -78,6 +82,8 @@ type ApplyRunner struct {
|
|||
timeout time.Duration
|
||||
noPrune bool
|
||||
prunePropagationPolicy string
|
||||
waitForPrune bool
|
||||
waitForPruneTimeout time.Duration
|
||||
}
|
||||
|
||||
func (r *ApplyRunner) RunE(cmd *cobra.Command, args []string) error {
|
||||
|
|
@ -100,6 +106,8 @@ func (r *ApplyRunner) RunE(cmd *cobra.Command, args []string) error {
|
|||
NoPrune: r.noPrune,
|
||||
DryRun: false,
|
||||
PrunePropagationPolicy: prunePropPolicy,
|
||||
WaitForPrune: r.waitForPrune,
|
||||
WaitForPruneTimeout: r.waitForPruneTimeout,
|
||||
})
|
||||
|
||||
// The printer will print updates from the channel. It will block
|
||||
|
|
|
|||
|
|
@ -440,6 +440,8 @@ func (a *Applier) Run(ctx context.Context, options Options) <-chan event.Event {
|
|||
Prune: !options.NoPrune,
|
||||
DryRun: options.DryRun,
|
||||
PrunePropagationPolicy: options.PrunePropagationPolicy,
|
||||
WaitForPrune: options.WaitForPrune,
|
||||
WaitForPruneTimeout: options.WaitForPruneTimeout,
|
||||
})
|
||||
|
||||
// Send event to inform the caller about the resources that
|
||||
|
|
@ -504,6 +506,15 @@ type Options struct {
|
|||
// that should be used for pruning. If this is not provided, the
|
||||
// default is to use the Background policy.
|
||||
PrunePropagationPolicy metav1.DeletionPropagation
|
||||
|
||||
// WaitForPrune defines whether we should wait for all resources
|
||||
// to be fully deleted after pruning. This is only effective
|
||||
// if the PrunePropagationPolicy is set to Forground.
|
||||
WaitForPrune bool
|
||||
|
||||
// WaitForPruneTimeout defines how long we should wait for all
|
||||
// resources to be deleted after prune before giving up.
|
||||
WaitForPruneTimeout time.Duration
|
||||
}
|
||||
|
||||
// setDefaults set the options to the default values if they
|
||||
|
|
@ -518,6 +529,9 @@ func setDefaults(o *Options) {
|
|||
if o.PrunePropagationPolicy == metav1.DeletionPropagation("") {
|
||||
o.PrunePropagationPolicy = metav1.DeletePropagationBackground
|
||||
}
|
||||
if o.WaitForPruneTimeout == time.Duration(0) {
|
||||
o.WaitForPruneTimeout = time.Minute
|
||||
}
|
||||
}
|
||||
|
||||
func handleError(eventChannel chan event.Event, err error) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue