Skip to content

Add Support for System-Level Robot Accounts#507

Merged
bupd merged 9 commits into
goharbor:mainfrom
qcserestipy:full-system-robots
Jul 29, 2025
Merged

Add Support for System-Level Robot Accounts#507
bupd merged 9 commits into
goharbor:mainfrom
qcserestipy:full-system-robots

Conversation

@qcserestipy

@qcserestipy qcserestipy commented Jun 29, 2025

Copy link
Copy Markdown
Collaborator

This PR adds full support for managing system-level robot accounts in Harbor CLI, which allows automation across multiple projects with a single robot account.

Features Added:

  • Create system-level robot accounts with permissions spanning multiple projects
  • Update existing system-level robots while preserving their project permissions
  • Configure both system-wide and per-project permissions
  • Load and save robot configurations from/to files
  • Interactive permission selection for both system and project levels
  • Support for bulk project permission assignment
  • Commands include:
harbor-cli robot create 
harbor-cli robot update
harbor-cli robot delete
harbor-cli robot list
harbor-cli robot view
harbor-cli robot refresh

Benefits:

  • Simplifies automation setup for CI/CD pipelines that need access to multiple projects
  • Provides a more maintainable approach than creating many project-specific robots
  • Enables consistent permission management across Harbor instances
  • Reduces manual steps through configuration files and interactive prompts

This implementation follows Harbor's API design for system robot accounts and maintains consistency with the existing CLI patterns.

ToDo

There are still some steps that have to be covered:

  • Currently create and update have shared functionality written out. TO reduce code duplication this has to be moved to a different location.
  • It has to be discussed where to handle the interactive huh forms for create and update operations.

Screenshots & Videos

Screen.Recording.2025-07-21.at.14.37.46.mov

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>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
@codecov

codecov Bot commented Jun 29, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0.29070% with 1372 lines in your changes missing coverage. Please review.
✅ Project coverage is 7.39%. Comparing base (60ad0bd) to head (b0b0216).
⚠️ Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
cmd/harbor/root/robot/update.go 0.00% 497 Missing ⚠️
cmd/harbor/root/robot/create.go 0.00% 337 Missing ⚠️
cmd/harbor/root/robot/refresh.go 0.00% 93 Missing ⚠️
pkg/views/robot/view/view.go 0.00% 80 Missing ⚠️
pkg/views/robot/select/view.go 0.00% 75 Missing ⚠️
cmd/harbor/root/robot/list.go 0.00% 65 Missing ⚠️
pkg/config/robot/robot.go 0.00% 65 Missing ⚠️
cmd/harbor/root/robot/view.go 0.00% 52 Missing ⚠️
cmd/harbor/root/robot/delete.go 0.00% 48 Missing ⚠️
pkg/views/robot/create/view.go 0.00% 17 Missing ⚠️
... and 7 more
Additional details and impacted files
@@            Coverage Diff            @@
##             main    #507      +/-   ##
=========================================
- Coverage   10.99%   7.39%   -3.60%     
=========================================
  Files         173     226      +53     
  Lines        8671   13665    +4994     
=========================================
+ Hits          953    1010      +57     
- Misses       7612   12549    +4937     
  Partials      106     106              

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

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
@qcserestipy qcserestipy marked this pull request as ready for review July 9, 2025 17:58
@qcserestipy qcserestipy changed the title WIP: Add Support for System-Level Robot Accounts Add Support for System-Level Robot Accounts Jul 9, 2025
@bupd bupd self-requested a review July 21, 2025 08:54

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

Overall, LGTM

@qcserestipy please resolve conflicts

…on empty

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

Copy link
Copy Markdown
Collaborator Author

@bupd In a few upcoming PRs I aim to do some code clean up, because I think several things can be optimized and moved to other places

@bupd bupd merged commit 3c8e623 into goharbor:main Jul 29, 2025
7 of 9 checks passed
qcserestipy added a commit to qcserestipy/harbor-cli that referenced this pull request Sep 2, 2025
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Vad1mo pushed a commit that referenced this pull request Sep 2, 2025
…521)

* build(deps): bump golang.org/x/text from 0.23.0 to 0.27.0 (#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 (#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>
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.

2 participants