goharbor / goharbor/harbor-cli

feat: Add harbor project update command

Open
#1,044 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
163
Forks
211
Avg merge
1m
Merged PRs (30d)
1

Description

## Problem

`harbor project` has `create`, `delete`, `list`, and `view`, but no `update`. The Harbor WebUI lets you change project settings after creation. The CLI does not expose that in one place.

Today you have to use separate commands:

- `harbor project config update` for metadata (public, auto-scan, prevent-vul, severity, reuse system CVE allowlist)
- `harbor quota update` for storage quota

Proxy cache registry ID can only be set at create time via `harbor project create --registry-id`. There is no top-level project update command matching the rest of the project CRUD surface.

## Proposed Solution

Add `harbor project update [name]` with flags and an interactive form.

**Command**

```sh
harbor project update [project_name] [flags]
```

**Flags**

- `--public` (true/false)
- `--auto-scan` (true/false)
- `--prevent-vul` (true/false)
- `--reuse-sys-cve` (true/false)
- `--severity` (none, low, medium, high, critical)
- `--storage-limit` (bytes, -1 for unlimited)
- `--registry-id` (proxy cache projects)
- `--id` (use project ID instead of name)

**Behavior**

1. Resolve project by name or ID, or prompt if omitted.
2. Fetch current project state.
3. If flags are passed, apply those fields. Otherwise run an interactive form.
4. Call `UpdateProject` in `pkg/api/project_handler.go` with `Public`, `Metadata`, and `RegistryID` where relevant.
5. Update storage quota via the quota API when storage changes.

**Files**

- `cmd/harbor/root/project/update.go`
- `pkg/api/project_handler.go` (`UpdateProject`)
- `pkg/views/project/update/view.go`
- `cmd/harbor/root/project/update_test.go`
- Regenerated docs under `doc/cli-docs/` and `doc/man-docs/`

**Examples**

```sh
harbor project update myproject --public true
harbor project update myproject --storage-limit -1 --prevent-vul true
harbor project update myproject
```

## Alternatives Considered

**Extend `harbor project config update` only**

This command already updates metadata via `api.UpdateConfig`. It does not cover storage quota or registry ID, and it lives under `project config` instead of alongside create/delete/list/view.

**Keep using `harbor quota update` for storage**

Works today but splits project management across two commands. Users expect `harbor project update` for WebUI parity.

**Do nothing**

Users keep juggling `project config update` and `quota update`. No single command for scripts or interactive project edits.

## Additional Context

- WebUI parity is the main driver. Project settings are editable in the UI after creation.
- `pkg/api/project_config_handler.go` already calls Harbor `UpdateProject` but only sends `Metadata`. A dedicated `UpdateProject` in `project_handler.go` can send the full `ProjectReq` (`Public`, `Metadata`, `RegistryID`).
- Implementation should follow existing patterns in `project/create.go`, `repository/update.go`, and `project/config/update.go`.
- A draft implementation exists on branch `feat/project-update` in fork `false200/harbor-cli`.
- Tests added so far cover flag validation only. Live Harbor integration testing is still needed before merge.

Contributor guide

Open the contributing guide

Research direction

Start by comparing cmd/harbor/root/project/create.go, repository/update.go, project/config/update.go, and the listed view and test files. Review pkg/api/project_handler.go and project_config_handler.go, then verify flag validation and live Harbor behavior; done means the command supports the specified project fields, quota updates, interactive use, tests, and regenerated docs.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.