refactor(output): replace log.Info and log.Infof statements with Printf and log.Debugf statements#884
Conversation
…tf and log.Debugf statements - all log.Info statements were assessed whether they should be user facing output or debug output - most statements were classified as simple user feed using Printf with newline format - two statements were adapted to log.Debugf statements because do not need to be seen by user Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #884 +/- ##
=========================================
- Coverage 10.99% 9.00% -1.99%
=========================================
Files 173 272 +99
Lines 8671 13441 +4770
=========================================
+ Hits 953 1211 +258
- Misses 7612 12115 +4503
- Partials 106 115 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
User-facing success messages were routed through logrus, making output dependent on log level/format/destination. CLI confirmations belong on stdout via fmt, not the log subsystem. - User-facing success msgs to fmt.Printf with - Internal/intermediate steps to logrus.Debugf - Keyring fallback to logrus.Warn - Remove unused logrus imports where applicable Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses #883 by refactoring Harbor CLI output so user-facing confirmations are no longer emitted via logrus.Info/Infof (which can be suppressed by log configuration), and by downgrading non-user-facing messages to debug-level logging.
Changes:
- Replaced many
log.Info/Infofsuccess/confirmation messages withfmt.Println/Printfso they reliably reach the user. - Moved several informational progress-style logs to
logrus.Debug/Debugfto keep default CLI output clean. - Adjusted one keyring fallback message from
InfotoWarn.
Reviewed changes
Copilot reviewed 39 out of 39 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/utils/utils.go | Changed parsing log from info → debug. |
| pkg/utils/encryption.go | Raised keyring fallback message from info → warn. |
| pkg/utils/config.go | Switched multiple config/data-file success logs from logrus → fmt output. |
| pkg/api/user_handler.go | Converted user CRUD success logs to fmt output and removed logrus import. |
| pkg/api/scan_all_handler.go | Converted scan-all success logs to fmt output and removed logrus import. |
| pkg/api/robot_handler.go | Converted robot success logs to fmt output (kept logrus where still used). |
| pkg/api/repository_handler.go | Converted repository delete success log to fmt output and removed logrus import. |
| pkg/api/registry_handler.go | Converted registry create/update/delete success logs to fmt output and removed logrus import. |
| pkg/api/project_handler.go | Converted project create/delete success logs to fmt output. |
| pkg/api/project_config_handler.go | Converted metadata update success log to fmt output and removed logrus import. |
| pkg/api/member_handler.go | Converted member CRUD success logs to fmt output and removed logrus import. |
| pkg/api/instance_handler.go | Converted instance create/delete success logs to fmt output and removed logrus import. |
| pkg/api/immutable_handler.go | Converted immutability rule create/delete success logs to fmt output and removed logrus import. |
| pkg/api/cveallowlist_handler.go | Converted CVE allowlist update success log to fmt output and removed logrus import. |
| pkg/api/artifact_handler.go | Converted artifact/tag/scan success logs to fmt output. |
| cmd/harbor/root/vulnerability/list.go | Converted “no vulnerabilities found” from logrus → fmt output. |
| cmd/harbor/root/user/list.go | Converted “no users found” from logrus → fmt output. |
| cmd/harbor/root/scanner/update.go | Converted scanner update success log to fmt output and removed logrus import. |
| cmd/harbor/root/scanner/list.go | Converted “no scanners found” from logrus → fmt output and removed logrus import. |
| cmd/harbor/root/scanner/delete.go | Converted scanner delete success log to fmt output and removed logrus import. |
| cmd/harbor/root/scan_all/view_schedule.go | Changed progress log from info → debug. |
| cmd/harbor/root/scan_all/update_schedule.go | Changed progress logs from info → debug; moved success messages to fmt output. |
| cmd/harbor/root/scan_all/stop.go | Changed progress log from info → debug; moved success message to fmt output. |
| cmd/harbor/root/scan_all/run.go | Changed progress log from info → debug; moved success message to fmt output. |
| cmd/harbor/root/scan_all/metrics.go | Changed progress log from info → debug. |
| cmd/harbor/root/robot/update.go | Changed progress logs from info → debug; moved success message to fmt output. |
| cmd/harbor/root/robot/refresh.go | Converted secret refresh success log to fmt output. |
| cmd/harbor/root/robot/create.go | Changed progress logs from info → debug; moved success/export messages to fmt output. |
| cmd/harbor/root/repository/list.go | Converted “no repositories found” from logrus → fmt output. |
| cmd/harbor/root/replication/policies/update.go | Changed “updating…” log from info → debug; moved success message to fmt output. |
| cmd/harbor/root/replication/policies/list.go | Converted “no policies found” from logrus → fmt output. |
| cmd/harbor/root/replication/executions/list.go | Converted “no executions found” from logrus → fmt output. |
| cmd/harbor/root/registry/list.go | Converted “no registries found” from logrus → fmt output. |
| cmd/harbor/root/quota/update.go | Converted quota update success log to fmt output and removed logrus import. |
| cmd/harbor/root/project/robot/refresh.go | Converted secret refresh success log to fmt output. |
| cmd/harbor/root/project/robot/create.go | Changed progress logs from info → debug; moved success/export messages to fmt output. |
| cmd/harbor/root/project/list.go | Converted “no projects found” from logrus → fmt output. |
| cmd/harbor/root/context/update.go | Converted success log to fmt output. |
| cmd/harbor/root/context/delete.go | Changed informational logs from info → debug. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| CurrentHarborConfig = config | ||
|
|
||
| log.Infof("Harbor configuration updated at %s", configPath) | ||
| fmt.Printf("Harbor configuration updated at %s", configPath) |
| } | ||
|
|
||
| log.Infof("Config file created at %s", configPath) | ||
| fmt.Printf("Config file created at %s", configPath) |
| @@ -69,8 +69,7 @@ If you specify --name, that credential (rather than the "current" one) will be u | |||
|
|
|||
| // 5. Confirm to the user (logrus.Info is fine here; no error) | |||
…tf and log.Debugf statements (goharbor#884)
Description
Briefly describe what this pull request does and why the change is needed.
log.Infofuser-facing output withfmt.Printf#883Type of Change
To fulfill our effort to make Harbor CLI more user and developer friendly messy usage of log.Info statements were removed. It has been agreed on that user facing outputs about confirmation or related info shall not be go through a log, but directly be handled by the cobra output stream as of using Print statements of the fmt package.
Changes