Skip to content

Finalize PR 114 Configuration command to Manage System Configuration#521

Merged
Vad1mo merged 20 commits into
goharbor:mainfrom
qcserestipy:rework-bupd-pr-114
Sep 2, 2025
Merged

Finalize PR 114 Configuration command to Manage System Configuration#521
Vad1mo merged 20 commits into
goharbor:mainfrom
qcserestipy:rework-bupd-pr-114

Conversation

@qcserestipy

@qcserestipy qcserestipy commented Jul 31, 2025

Copy link
Copy Markdown
Collaborator

Overview

This PR continues and extends the work started by @bupd in PR #114, adding comprehensive configuration management capabilities to Harbor CLI. The changes include a new view command, improved reflection handling, and secret management.

What's Changed

🆕 New Features

  • Configuration View Command: Added harbor config view command with category-based filtering aligned with Harbor UI
  • Enhanced Reflection System: Added reflection utilities to handle both regular and secret configuration values
  • Category Support: Configuration commands now support filtering by categories (Authentication, Email, Security, etc.)
  • Secret Field Handling: Proper encryption/decryption of sensitive configuration fields

🔧 Improvements

  • Clean API Handlers: Refactored configuration API handlers for better maintainability
  • Better Error Handling: Improved error messages and validation for configuration operations
  • Type Safety: Enhanced reflection code with better type checking and error handling
  • Table View: Added table-based display for configuration data using reflection

Technical Details

New Commands

# View all configurations
harbor config view

# View configurations by category
harbor config view --category authentication
harbor config view --category email
harbor config view --category security

Reflection Enhancements

The reflection system now properly handles:

  • ConfigItem structures with both Value and Editable fields
  • Secret field encryption for sensitive data storage
  • Type-safe conversions between API models and configuration structures
  • Null value handling for optional fields

Categories Supported

  • Authentication
  • Security
  • System Settings

Acknowledgments

This work builds upon the foundation laid by @bupd in PR #114. Special thanks for the initial configuration update implementation that made this enhancement possible.

Screen recording

Screen.Recording.2025-09-02.at.13.39.02.mov

@codecov

codecov Bot commented Jul 31, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 1.36519% with 289 lines in your changes missing coverage. Please review.
✅ Project coverage is 7.04%. Comparing base (60ad0bd) to head (5bb58ee).
⚠️ Report is 38 commits behind head on main.

Files with missing lines Patch % Lines
pkg/utils/reflect.go 0.00% 81 Missing ⚠️
cmd/harbor/root/configurations/view.go 0.00% 67 Missing ⚠️
cmd/harbor/root/configurations/apply.go 0.00% 44 Missing ⚠️
cmd/harbor/root/configurations/cmd.go 0.00% 41 Missing ⚠️
pkg/views/configurations/view/view.go 0.00% 33 Missing ⚠️
pkg/api/configurations_handler.go 0.00% 14 Missing ⚠️
pkg/utils/configurations_categories.go 0.00% 8 Missing ⚠️
pkg/utils/config.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main    #521      +/-   ##
=========================================
- Coverage   10.99%   7.04%   -3.95%     
=========================================
  Files         173     243      +70     
  Lines        8671   14571    +5900     
=========================================
+ Hits          953    1027      +74     
- Misses       7612   13437    +5825     
- Partials      106     107       +1     

☔ 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

Copy link
Copy Markdown
Collaborator Author

@bupd while working on this I noticed a weird issue. The settings ldapurl and ldapbasedn can be retrieved from the harbor configuration and stored in the config file. When we try to update the config with these two fields in the config contained the request to the Harbor API fails:

./bin/harbor-cli config update
Error: failed to update Harbor configurations: response status code does not match any response statuses defined for this endpoint in the swagger spec (status 400): {}

Do you have any clue what could be the issue here?

@qcserestipy qcserestipy requested a review from bupd July 31, 2025 15:54
@bupd

bupd commented Aug 12, 2025

Copy link
Copy Markdown
Member

@bupd while working on this I noticed a weird issue. The settings ldapurl and ldapbasedn can be retrieved from the harbor configuration and stored in the config file. When we try to update the config with these two fields in the config contained the request to the Harbor API fails:

./bin/harbor-cli config update
Error: failed to update Harbor configurations: response status code does not match any response statuses defined for this endpoint in the swagger spec (status 400): {}

Do you have any clue what could be the issue here?

probably due to harbor not having ldap configured. 400 indicates that the body from the client side is wrong.

@qcserestipy

Copy link
Copy Markdown
Collaborator Author

@bupd Can I merge this one?

@bupd

bupd commented Aug 14, 2025

Copy link
Copy Markdown
Member

@bupd Can I merge this one?

@qcserestipy Please do add screenshots or a video with the changes. I will review it next week.

Thanks

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

@qcserestipy Thanks for your contributions

I have left my improvements below.

  1. remove the get cmd.
  2. improve the view command.

Comment thread cmd/harbor/root/configurations/view.go Outdated
Comment thread cmd/harbor/root/configurations/view.go Outdated
Comment thread cmd/harbor/root/configurations/get.go Outdated
Comment thread cmd/harbor/root/configurations/get.go Outdated
Comment thread cmd/harbor/root/configurations/apply.go
Comment thread pkg/utils/configurations_categories.go Outdated
Comment thread pkg/utils/configurations_categories.go Outdated
Comment thread pkg/utils/configurations_categories.go Outdated
Comment thread pkg/utils/config.go
Credentials []Credential `mapstructure:"credentials" yaml:"credentials"`
CurrentCredentialName string `mapstructure:"current-credential-name" yaml:"current-credential-name"`
Credentials []Credential `mapstructure:"credentials" yaml:"credentials"`
Configurations models.Configurations `mapstructure:"configurations" yaml:"configurations"`

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.

we don't need this

Comment thread pkg/utils/config.go Outdated
dependabot Bot and others added 13 commits September 2, 2025 13:33
Bumps [golang.org/x/text](https://github.com/golang/text) from 0.23.0 to 0.27.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](golang/text@v0.23.0...v0.27.0)

---
updated-dependencies:
- dependency-name: golang.org/x/text
  dependency-version: 0.27.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
This command fetches and stores the system config in the harbor config
file.

Signed-off-by: bupd <bupdprasanth@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: bupd <bupdprasanth@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
…r api configurationsok types;

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
…ifferent categories; todo: update from config runs into swagger api errors

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
… and update command, extend reflection for view functionality

- In this commit the view command is added that supports setting categories aligned with the UI
- Reflection is cleaned up to also handle secret values stored in the config file
- Reflection is used for table view of configurations

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
… command to support specifiying configurations in a separate file than the harbor-cli global config

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
The get command is removed since not necessary. The view command is updated to make category selection available for piping. The apply command is adapted to not use harbor config but external config file that can be chosen via flag.

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
…tion.

This function is not longer needed since the configurations settings will be stored in another file and not in the harbor credentials config file.

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: qcserestipy <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
qcserestipy and others added 7 commits September 2, 2025 13:35
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
@Vad1mo Vad1mo merged commit 139640a into goharbor:main Sep 2, 2025
7 of 9 checks passed

@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

neel-1414 pushed a commit to neel-1414/harbor-cli that referenced this pull request Sep 5, 2025
…oharbor#521)

* build(deps): bump golang.org/x/text from 0.23.0 to 0.27.0 (goharbor#519)

Bumps [golang.org/x/text](https://github.com/golang/text) from 0.23.0 to 0.27.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](golang/text@v0.23.0...v0.27.0)

---
updated-dependencies:
- dependency-name: golang.org/x/text
  dependency-version: 0.27.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* add system `config get` command

This command fetches and stores the system config in the harbor config
file.

Signed-off-by: bupd <bupdprasanth@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* add system config `update` command

Signed-off-by: bupd <bupdprasanth@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* Rebase on main; moved command to its own package; added reflection for api configurationsok types;

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* Updated get function to sort for categories; update api handler for different categories; todo: update from config runs into swagger api errors

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* ..

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* feat(configurations): Added configurations view command, clean up get and update command, extend reflection for view functionality

- In this commit the view command is added that supports setting categories aligned with the UI
- Reflection is cleaned up to also handle secret values stored in the config file
- Reflection is used for table view of configurations

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* Add Support for System-Level Robot Accounts (goharbor#507)

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* Updated github.com/go-viper/mapstructure/v2 to avoid vulnerability

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* Renamed config update to config apply; added -f flag for config apply command to support specifiying configurations in a separate file than the harbor-cli global config

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* feat: Remove get command, refactor view command

The get command is removed since not necessary. The view command is updated to make category selection available for piping. The apply command is adapted to not use harbor config but external config file that can be chosen via flag.

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* refactor(harbor-cli): Remove add configurations to harbor config function.

This function is not longer needed since the configurations settings will be stored in another file and not in the harbor credentials config file.

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* Added changes according to PR

Signed-off-by: qcserestipy <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* docs(config): update cli docs

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* fix(mod): Patch error in go.mod missing )

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* docs(config): update cli docs

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* fix(config): make changes to satisfy vulncheck

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* doc(config): remove messed up cli config directory

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

* fix(config): remove obsolete vscode settings folder

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: bupd <bupdprasanth@gmail.com>
Signed-off-by: qcserestipy <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: bupd <bupdprasanth@gmail.com>
@qcserestipy qcserestipy mentioned this pull request Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants