goharbor / goharbor/harbor-cli
[feature]: Implement harbor auditlog command
- Dominant language
- Go
- Stars
- 163
- Forks
- 211
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
## Problem
Currently, Harbor CLI does not have a top-level command to view system-wide audit logs (`❌ Auditlog` in the WebUI feature parity list in `README.md`).
While project-level logs (`harbor project logs`) exist, administrators currently lack a CLI interface to list, filter, and inspect global audit logs across the Harbor system.
## Proposed Solution
Introduce a new command group `harbor auditlog` (with subcommand `harbor auditlog list`) that connects to the underlying API handlers (`AuditLogs` / `AuditLogsLegacy` in `pkg/api/auditLogs_handler.go`).
### Expected Commands & Behavior
```bash
# List system audit logs
harbor auditlog list
# Support pagination and filtering flags
harbor auditlog list --page 1 --page-size 10 --query "username=admin"
# Support view formats
harbor auditlog list -o json
harbor auditlog list -o yaml
```
### Proposed Output Format
The output table should display key audit record fields:
- Log ID
- Username
- Resource / Resource Type
- Operation / Action
- Timestamp
## Additional Context
The API helper functions (`AuditLogs`, `AuditLogsLegacy`, `AuditLogEventTypes`) are already present in `pkg/api/auditLogs_handler.go`. This feature will wire up the Cobra command interface, output table views, and flag bindings.
Contributor guide
Research direction
Start by reading pkg/api/auditLogs_handler.go and the existing harbor project logs command to follow the CLI's command, flag, and output patterns. Implement harbor auditlog list with pagination, query filtering, table output, and JSON/YAML formats. Done means administrators can list system-wide audit logs with the documented fields and flags.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100