Skip to content

refactor(output): replace log.Info and log.Infof statements with Printf and log.Debugf statements#884

Merged
bupd merged 3 commits into
goharbor:mainfrom
qcserestipy:refactor/userfacing-logs
May 8, 2026
Merged

refactor(output): replace log.Info and log.Infof statements with Printf and log.Debugf statements#884
bupd merged 3 commits into
goharbor:mainfrom
qcserestipy:refactor/userfacing-logs

Conversation

@qcserestipy

@qcserestipy qcserestipy commented May 5, 2026

Copy link
Copy Markdown
Collaborator

Description

Briefly describe what this pull request does and why the change is needed.

Type 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.

  • Bug fix
  • New feature
  • Refactor
  • Documentation update
  • Chore / maintenance

Changes

  • 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

…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>
@qcserestipy qcserestipy added the enhancement New feature or request label May 5, 2026
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
@codecov

codecov Bot commented May 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 8.79121% with 83 lines in your changes missing coverage. Please review.
✅ Project coverage is 9.00%. Comparing base (60ad0bd) to head (a31194f).
⚠️ Report is 148 commits behind head on main.

Files with missing lines Patch % Lines
cmd/harbor/root/scan_all/update_schedule.go 0.00% 9 Missing ⚠️
cmd/harbor/root/robot/update.go 0.00% 8 Missing ⚠️
pkg/utils/config.go 33.33% 6 Missing ⚠️
pkg/api/artifact_handler.go 0.00% 5 Missing ⚠️
cmd/harbor/root/robot/create.go 0.00% 4 Missing ⚠️
pkg/api/member_handler.go 20.00% 4 Missing ⚠️
pkg/api/user_handler.go 0.00% 4 Missing ⚠️
cmd/harbor/root/project/robot/create.go 0.00% 3 Missing ⚠️
pkg/api/registry_handler.go 0.00% 3 Missing ⚠️
pkg/api/robot_handler.go 0.00% 3 Missing ⚠️
... and 26 more
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@qcserestipy qcserestipy marked this pull request as draft May 5, 2026 15:51
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>
@qcserestipy qcserestipy marked this pull request as ready for review May 5, 2026 17:53
@qcserestipy qcserestipy requested a review from Copilot May 6, 2026 08:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/Infof success/confirmation messages with fmt.Println/Printf so they reliably reach the user.
  • Moved several informational progress-style logs to logrus.Debug/Debugf to keep default CLI output clean.
  • Adjusted one keyring fallback message from Info to Warn.

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.

Comment thread pkg/utils/config.go
CurrentHarborConfig = config

log.Infof("Harbor configuration updated at %s", configPath)
fmt.Printf("Harbor configuration updated at %s", configPath)
Comment thread pkg/utils/config.go
}

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)

@bupd bupd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@bupd bupd merged commit 02946ce into goharbor:main May 8, 2026
10 of 12 checks passed
rakshityadav1868 pushed a commit to rakshityadav1868/harbor-cli that referenced this pull request May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace log.Infof user-facing output with fmt.Printf

3 participants