[Sandbox] Official Harbor CLI
Go to file
Vadim Bauer ff1485171c
chnage robot account to supported
Signed-off-by: Vadim Bauer <vb@container-registry.com>
2025-08-05 15:07:46 +02:00
.dagger feat: Release to Homebrew-Tap (#421) 2025-06-20 15:22:25 +05:30
.github fix: remove codecov on main (#486) 2025-06-03 19:58:51 +05:30
cmd/harbor Add Support for System-Level Robot Accounts (#507) 2025-07-29 18:33:44 +05:30
doc Add Support for System-Level Robot Accounts (#507) 2025-07-29 18:33:44 +05:30
examples/config Add Support for System-Level Robot Accounts (#507) 2025-07-29 18:33:44 +05:30
pkg Add Support for System-Level Robot Accounts (#507) 2025-07-29 18:33:44 +05:30
test Unit testing Coverage report (#376) 2025-05-23 14:33:56 +02:00
.gitattributes lint 2024-09-24 15:46:15 +02:00
.gitignore cleanup 2024-09-24 16:13:52 +02:00
.golangci.yaml chore: update dependencies and golangci-lint configuration 2025-04-15 16:25:41 +02:00
.goreleaser.yaml feat: Release to Homebrew-Tap (#421) 2025-06-20 15:22:25 +05:30
CODE_OF_CONDUCT.md feat: revamp harbor cli 2024-01-28 18:47:11 +05:30
CONTRIBUTING.md docs: add CONTRIBUTING.md for community contributions (#405) 2025-04-22 15:48:01 +02:00
LICENSE Initial commit 2023-04-23 12:12:29 +05:30
README.md chnage robot account to supported 2025-08-05 15:07:46 +02:00
RELEASE.md add release documentation 2024-10-22 15:55:13 +05:30
copyright.tmpl Configure Linter & Improve Workflow (#294) 2025-01-10 16:15:49 +01:00
dagger.json fix velnerability-check (#494) 2025-06-20 01:43:57 +05:30
go.mod build(deps): bump golang.org/x/text from 0.23.0 to 0.27.0 (#519) 2025-07-21 14:32:23 +05:30
go.sum build(deps): bump golang.org/x/text from 0.23.0 to 0.27.0 (#519) 2025-07-21 14:32:23 +05:30

README.md

Harbor-CLI Logo_256px

Harbor CLI — a command-line interface for interacting with your Harbor container registry. A streamlined, user-friendly alternative to the WebUI, as your daily driver or for scripting and automation.

Artifact Hub FOSSA Status codecov Go Report Card

Scope 🧪

  1. CLI alternative to the WebUI
  2. Tool for scripting and automation of common repeatable Harbor tasks running on your machine or inside your pipeline

Features

The project's first goal is to reach WebUI parity.

✅ project       Mange projects  
✅ repo          Manage repositories  
✅ artifact      Manage artifacts  
✅ label         Manage labels  
✅ tag           Manage tags   
✅ quota         Manage quotas  
✅ webhook       Manage webhook policies 
✅ robot         Robot Account 

✅ login         Log in to Harbor registry  
✅ user          Manage users  

✅ registry      Manage registries
❌ replication   Manage replication

✅ config        Manage the config of the Harbor CLI
✅ cve-allowlist Manage system CVE allowlist
✅ health        Get the health status of Harbor components
✅ instance      Manage preheat provider instances in Harbor
✅ info          Display detailed Harbor system, statistics, and CLI environment information


✅ scanner       scanner commands
✅ schedule      Schedule jobs in Harbor

✅ completion    Generate the autocompletion script for the specified shell\
help          Help about any command
✅ version       Version of Harbor CLI

Installation

Container

Running Harbor CLI as a container is simple. Use the following command to get started:

docker run -ti --rm -v $HOME/.config/harbor-cli/config.yaml:/root/.config/harbor-cli/config.yaml \
  -e HARBOR_ENCRYPTION_KEY=$(echo "ThisIsAVeryLongPassword" | base64) \
  registry.goharbor.io/harbor-cli/harbor-cli \
  --help

Use the HARBOR_ENCRYPTION_KEY container environment variable as a base64-encoded 32-byte key for AES-256 encryption. This securely stores your harbor login password.

If you intend to run the CLI as a container,it is advised to set the following environment variables and to create an alias and append the alias to your .zshrc or .bashrc file

echo "export HARBOR_CLI_CONFIG=\$HOME/.config/harbor-cli/config.yaml" >> ~/.zshrc
echo "export HARBOR_ENCRYPTION_KEY=\$(cat <path_to_32bit_private_key_file> | base64)" >> ~/.zshrc
echo "alias harbor='docker run -ti --rm -v \$HARBOR_CLI_CONFIG:/root/.config/harbor-cli/config.yaml -e HARBOR_ENCRYPTION_KEY=\$HARBOR_ENCRYPTION_KEY registry.goharbor.io/harbor-cli/harbor-cli'" >> ~/.zshrc 
source ~/.zshrc # or restart your terminal

Linux, MacOS and Windows

Harbor CLI will soon be published on Homebrew. Meantime, we recommend using Harbor in the Container or downloading the binary from the releases page

Add the Harbor CLI to your Container Image

Using Curl or Wget isn't needed if you want to add the Harbor CLI to your container. Instead, we recommend copying the Harbor CLI from our official image by using the following Dockerfile:

#...
COPY --from=registry.goharbor.io/harbor-cli/harbor-cli:latest /harbor /usr/local/bin/harbor
# --chown and --chmod flags can be used to set the permissions

Example Commands💡

>./harbor    

Official Harbor CLI

Usage:
  harbor [command]

Examples:

// Base command:
harbor

// Display help about the command:
harbor help


Available Commands:
  artifact      Manage artifacts
  completion    Generate the autocompletion script for the specified shell
  config        Manage the config of the Harbor CLI
  cve-allowlist Manage system CVE allowlist
  health        Get the health status of Harbor components
  help          Help about any command
  info          Show the current credential information
  instance      Manage preheat provider instances in Harbor
  label         Manage labels in Harbor
  login         Log in to Harbor registry
  project       Manage projects and assign resources to them
  registry      Manage registries
  repo          Manage repositories
  schedule      Schedule jobs in Harbor
  tag           Manage tags in Harbor registry
  user          Manage users
  version       Version of Harbor CLI

Flags:
  -c, --config string          config file (default is $HOME/.config/harbor-cli/config.yaml)
  -h, --help                   help for harbor
  -o, --output-format string   Output format. One of: json|yaml
  -v, --verbose                verbose output

Use "harbor [command] --help" for more information about a command.


Config Management

Hierarchy

Use the --config flag to specify a custom configuration file path (the highest priority).

  harbor --config /path/to/custom/config.yaml artifact list

If --config is not provided, Harbor CLI checks the HARBOR_CLI_CONFIG environment variable for the config file path.

export HARBOR_CLI_CONFIG=/path/to/custom/config.yaml
harbor artifact list

If neither is set, it defaults to $XDG_CONFIG_HOME/harbor-cli/config.yaml or $HOME/.config/harbor-cli/config.yaml if XDG_CONFIG_HOME is unset.

harbor artifact list
Data Path
  • Data paths are determined by the XDG_DATA_HOME environment variable.
  • If XDG_DATA_HOME is not set, it defaults to $HOME/.local/share/harbor-cli/data.yaml.
  • The data file always contains the path of the latest config used.
Config TL;DR
  • --config flag > HARBOR_CLI_CONFIG environment variable > default XDG config paths.
  • Environment variables override default settings, and the --config flag takes precedence over both environment variables and defaults.
  • The data file always contains the path of the latest config used.

Log in to Harbor Registry

harbor login demo.goharbor.io -u harbor-cli -p Harbor12345

Create a New Project

harbor project create

List all Projects

harbor project list

# output
┌──────────────────────────────────────────────────────────────────────────────────────────┐
│  Project Name  Access Level  Type          Repo Count    Creation Time                   │
│ ──────────────────────────────────────────────────────────────────────────────────────── │
│  library       public        project       0             1 hour ago                      │
└──────────────────────────────────────────────────────────────────────────────────────────┘

List all Repository in a Project

harbor repo list

# output
┌────────────────────────────────────────────────────────────────────────────────────────┐
│  Name                      Artifacts     Pulls         Last Modified Time              │
│ ────────────────────────────────────────────────────────────────────────────────────── │
│  library/harbor-cli        1             0             0 minute ago                    │
└────────────────────────────────────────────────────────────────────────────────────────┘

Supported Platforms

Platform Status
Linux
macOS
Windows

Build From Source

Make sure you have the latest Dagger installed in your system.

Using Dagger

git clone https://github.com/goharbor/harbor-cli.git && cd harbor-cli
dagger call build-dev --platform darwin/arm64 export --path=./harbor-cli
./harbor-dev --help

If golang is installed in your system, you can also build the project using the following commands:

git clone https://github.com/goharbor/harbor-cli.git && cd harbor-cli
go build -o harbor-cli cmd/harbor/main.go

Version Compatibility With Harbor

At the moment, the Harbor CLI is developed and tested with Harbor 2.13. The CLI should work with versions prior to 2.13, but not all functionalities may be available or work as expected.

Harbor <2.0.0 is not supported.

Community

License

This project is licensed under the Apache 2.0 License. See the LICENSE file for details.

FOSSA Status

Acknowledgements

This project is maintained by the Harbor community. We thank all our contributors and users for their support.

❤️ Show your support

For any questions or issues, please open an issue on our GitHub Issues page.
Give a if this project helped you, Thank YOU!