feat: add dry run option for cleanup subcommand#21
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: OchiengEd The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| // Individual deletion failures are recorded but do not abort the operation. | ||
| // If deleteNamespace is true, the namespace itself is deleted as the final step. | ||
| func CleanupAll(ctx context.Context, c client.Client, namespace string, deleteNamespace bool, runID string) (*CleanupResult, error) { | ||
| func CleanupAll(ctx context.Context, c client.Client, cfg *config.Config, deleteNamespace bool, runID string) (*CleanupResult, error) { |
There was a problem hiding this comment.
In lieu of adding an argument for dry run, I chose to pass in the *config.Config from which we can determine the namespace and if dry run is set to true.
|
|
||
| // Setup delete options | ||
| opts := []client.DeleteOption{} | ||
| if cfg.DryRun { |
There was a problem hiding this comment.
When dry run is true, controller runtime delete will be called with the dry run all option.
|
@OchiengEd thx for this. just one addition. there is no indication in the output it is a dry run. ❯ ./virtwork cleanup --dry-run |
|
Noted. I will look into that. |
Signed-off-by: Edmund Ochieng <ochienged@gmail.com>
|
All done. ➜ virtwork git:(cleanup_dry_run) ./bin/virtwork cleanup --dry-run
--- Dry Run ---
Cleanup complete: 6 VMs deleted, 1 services deleted, 6 secrets deleted
➜ virtwork git:(cleanup_dry_run) |
This commit adds the
--dry-runflag to the cleanup subcommand to allow users to review the impacts of the cleanup action before they run it.Below is output of the validation of work done:
Closes #5