Skip to content

feat: add project config command#448

Merged
Vad1mo merged 30 commits into
goharbor:mainfrom
rizul2108:project-config
May 27, 2025
Merged

feat: add project config command#448
Vad1mo merged 30 commits into
goharbor:mainfrom
rizul2108:project-config

Conversation

@rizul2108

@rizul2108 rizul2108 commented Apr 29, 2025

Copy link
Copy Markdown
Collaborator

Introduces the project config command, enabling users to manage Harbor project configurations like in UI

image

Features added:

  • harbor project config
    Manage project configuration with support for specifying projects by name or ID.
    Includes options:
    • --id to use project ID instead of project name
  • Subcommands:
    • harbor project config list — List current configuration of a Harbor project
    • harbor project config update — Update project configuration interactively or via flags

image

Fix #91

muaz-32 and others added 17 commits May 29, 2024 05:20
Signed-off-by: muaz-32 <96006730+muaz-32@users.noreply.github.com>
It is beneficial when a project's name is same as another project's ID.
Signed-off-by: muaz-32 <96006730+muaz-32@users.noreply.github.com>
Signed-off-by: muaz-32 <96006730+muaz-32@users.noreply.github.com>
Signed-off-by: muaz-32 <96006730+muaz-32@users.noreply.github.com>
…e` and `list` command.

Signed-off-by: muaz-32 <96006730+muaz-32@users.noreply.github.com>
…n and addition of the flag in the command in the `cmd.go` file.

Signed-off-by: muaz-32 <96006730+muaz-32@users.noreply.github.com>
Signed-off-by: muaz-32 <96006730+muaz-32@users.noreply.github.com>
Signed-off-by: muaz-32 <96006730+muaz-32@users.noreply.github.com>
Signed-off-by: muaz-32 <96006730+muaz-32@users.noreply.github.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
@bupd

bupd commented May 2, 2025

Copy link
Copy Markdown
Member

Continuing work from #92

Fix #91

@rizul2108 Please add a clear PR description of changes made and Screenshots of the working cmd

@rizul2108

Copy link
Copy Markdown
Collaborator Author

I am currently working on this. It is not ready for review yet. It needs major changes so i am implementing those currently

Sorry I forgot to mark it as draft doing it just now

@rizul2108 rizul2108 marked this pull request as draft May 2, 2025 22:01
rizul2108 added 2 commits May 3, 2025 15:04
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
@rizul2108

Copy link
Copy Markdown
Collaborator Author

I'm a bit confused about the implementation of the add config command.
image

The URL we are referring to is: https://demo.goharbor.io/harbor/projects/1650/configs

From observing this UI, it seems that the API requests made for updating project configurations are not just targeting metadata (i.e., PUT or GET requests specifically for metadata), but instead are made on the entire project object. This is because metadata alone does not include information such as the project CVE allowlist.

To modify the CVE allowlist, we would need to make a PUT request on the entire project — not just via the metadata APIs.

This raises a question:
Should we include the option to add or modify the project CVE allowlist under the config add command in the CLI?
Doing so would mean our config command will have to interact with the broader project APIs and not limit itself to metadata-specific operations.

Additionally, for the get config command, if we want to retrieve the CVE allowlist, we would again need to fetch the full project object, not just the metadata.

So my main confusion is:
To what extent should we try to replicate the behavior/UI of the Harbor project config section in the CLI?

Does this implementation approach — where the config command also handles CVE allowlist and thus uses full project update APIs — make sense? Should I proceed in this direction?

@Vad1mo @bupd need your insights on this

@bupd

bupd commented May 9, 2025

Copy link
Copy Markdown
Member

because metadata alone does not include information such as the project CVE allowlist.

@rizul2108 I suggest we don't need to worry about the cve-allowlist in project config

Should we include the option to add or modify the project CVE allowlist under the config add command in the CLI?
No

For now, we can focus on having config command to manage only the project metadata.
Since we have a cve-allowlist cmd it would make sense to have option to set project level cve-allowlist in that cmd. rather than doing it in the config.

Hope this helps. Thanks

rizul2108 added 3 commits May 15, 2025 00:07
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
@rizul2108

Copy link
Copy Markdown
Collaborator Author

There is no option to update more than 1 metadata fields in the metadata API requests
So I will be using the update project API only to update the metadata

Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
@rizul2108 rizul2108 marked this pull request as ready for review May 15, 2025 10:12
rizul2108 added 2 commits May 15, 2025 15:48
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
@rizul2108 rizul2108 requested a review from Copilot May 15, 2025 19:58

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 introduces a new command group for managing Harbor project configuration, including interactive updates and listing of project metadata. Key changes include:

  • New views for updating and listing configuration (under pkg/views/project/config).
  • Updated API handlers for configuration management (under pkg/api).
  • CLI and manual documentation updates, along with new commands integrated into the project subcommands.

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/views/project/config/update/view.go Implements the interactive update view for project configuration.
pkg/views/project/config/list/view.go Implements the interactive list view for project configuration.
pkg/api/project_config_handler.go Provides API methods to list and update project configuration.
doc/man-docs/*.1 New man pages covering the config commands.
doc/cli-docs/*.md Updated CLI documentation for the new config commands.
cmd/harbor/root/project/config/*.go Implements and integrates the update and list commands into the CLI.
cmd/harbor/root/project/cmd.go Adds the new project config subcommand to the root project command.

Comment thread cmd/harbor/root/project/config/update.go Outdated
Comment thread doc/man-docs/man1/harbor-project-config.1 Outdated
rizul2108 and others added 3 commits May 16, 2025 01:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Rizul Gupta <112455393+rizul2108@users.noreply.github.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
@rizul2108 rizul2108 requested a review from bupd May 15, 2025 20:34

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

@rizul2108 please fix the suggestions

Comment thread cmd/harbor/root/project/config/list.go Outdated
var err error
var projectNameorID string
cmd := &cobra.Command{
Use: "list [NAME|ID]",

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.

Accept only name as an argument and users can give id via flags.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I gave that feature already. I gave ID as a persistent flag in the config subcommand rather than mentioning it in each sub-command under the config.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I will improve the use description in each command

Comment thread pkg/api/project_config_handler.go Outdated
Comment thread pkg/api/project_config_handler.go Outdated
Comment thread cmd/harbor/root/project/config/cmd.go
resolve errors

Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>

add docs

Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>

add docs

Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>

update docs

Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
@rizul2108

Copy link
Copy Markdown
Collaborator Author

@bupd resolved errors

@rizul2108

Copy link
Copy Markdown
Collaborator Author

@bupd can you review and approve this PR?

@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

@Vad1mo Vad1mo merged commit 6caf59e into goharbor:main May 27, 2025
7 checks passed
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.

Add the metadata command for managing project metadata

5 participants