feat: implement Garbage Collection (gc) command group#1018
Conversation
Signed-off-by: Govind Charpe <govind.charpe16@gmail.com>
Signed-off-by: Govind Charpe <govind.charpe16@gmail.com>
Signed-off-by: Govind Charpe <govind.charpe16@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a new harbor gc command group to manage Harbor registry-wide Garbage Collection from the CLI (history, logs, schedule view/update, trigger, stop), and updates the README feature matrix accordingly.
Changes:
- Added
gcCobra command group with subcommands:history,log,schedule,stop,trigger,update-schedule. - Added GC API handler layer (
pkg/api/gc_handler.go) wiring to Harbor go-client GC endpoints. - Added Bubbletea/huh-based views for listing history, viewing schedule, and interactively editing schedule options.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Marks GC as implemented in the feature list. |
| pkg/api/gc_handler.go | Adds GC API wrapper functions (history/status/log/stop/schedule/update/trigger). |
| pkg/views/gc/list/view.go | Bubbletea table view for GC execution history. |
| pkg/views/gc/view/view.go | Bubbletea table view for current GC schedule. |
| pkg/views/gc/update/view.go | Interactive huh-based prompt + cron validation for schedule/trigger options. |
| cmd/harbor/root/gc/cmd.go | Registers the gc command group and subcommands. |
| cmd/harbor/root/gc/history.go | Implements harbor gc history with paging/query/sort and output formatting. |
| cmd/harbor/root/gc/log.go | Implements harbor gc log [gc-id]. |
| cmd/harbor/root/gc/schedule.go | Implements harbor gc schedule (formatted output or TUI view). |
| cmd/harbor/root/gc/stop.go | Implements harbor gc stop [gc-id]. |
| cmd/harbor/root/gc/trigger.go | Implements harbor gc trigger (flags or interactive). |
| cmd/harbor/root/gc/update_schedule.go | Implements harbor gc update-schedule [type] (flags or interactive). |
| cmd/harbor/root/gc/gc_test.go | Adds CLI validation tests for GC history and update-schedule. |
| cmd/harbor/root/cmd.go | Registers gc under the system command group. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Govind Charpe <govind.charpe16@gmail.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1018 +/- ##
=========================================
- Coverage 10.99% 9.52% -1.47%
=========================================
Files 173 332 +159
Lines 8671 16493 +7822
=========================================
+ Hits 953 1571 +618
- Misses 7612 14785 +7173
- Partials 106 137 +31 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Signed-off-by: Govind Charpe <govind.charpe16@gmail.com>
|
I noticed #1008 introduces generic schedule management. This proposal focuses on a dedicated GC administration workflow that includes execution history, logs, manual triggering, stopping active runs, and schedule management. While there is some overlap around scheduling, the broader goal is to provide a complete GC command group rather than only schedule creation/deletion. The scheduling component follows the existing resource-specific pattern already used by scan-all, while the additional commands focus on operational visibility and control of GC executions by leveraging the SDK's built-in GC client. |
📊 File Changes BreakdownTo keep the review process clean, here is the breakdown of the changes in this PR. Only 14 files were manually written or modified to implement the core feature. The remaining 136 files are purely auto-generated command documentation ( 1. Core Feature Implementation (Manual Changes)
2. Auto-Generated DocumentationThese files were automatically generated by running
|
Description
This PR adds a dedicated
gccommand group toharbor-cli, enabling administrators to manage Harbor Garbage Collection directly from the CLI.Garbage Collection is currently listed as an unsupported feature in the project README. While Harbor already exposes GC functionality through its API and Go SDK,
harbor-clidoes not currently provide a CLI interface for these operations. As a result, administrators must rely on the Harbor WebUI for common storage maintenance tasks.This implementation closes that gap by introducing a dedicated command group for registry-wide Garbage Collection, covering the complete GC workflow from the command line.
Fixes #1017
Type of Change
Changes
Commands added
Implementation
gccommand group with dedicated Cobra subcommands.huh.table,json,yaml, andcsv) where applicable.Testing
Verified with:
Additionally verified:
harbor gc --helpNotes
This implementation follows the existing command organization used throughout the project by introducing a dedicated resource-specific
gccommand group, consistent with other system-level commands such asscan-all.