-
Notifications
You must be signed in to change notification settings - Fork 202
Add documentation for Harbor CLI configuration and encryption management #645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
qcserestipy
wants to merge
12
commits into
goharbor:main
Choose a base branch
from
qcserestipy:cnt-doc-harborcli
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4ce9fcd
modified readme file
Althaf66 13c1964
deleted md files
Althaf66 5fed2bb
Added Documentation for Harbor-CLI
Althaf66 ad8d138
Cherry pick finished
qcserestipy 8c1babe
Added more cli docs entries, added section for configuration manageme…
qcserestipy 14abb82
Added cross reference between encryption and configuration management…
qcserestipy e5ee800
Fix: typo
qcserestipy 841b26f
Updated cli-docs generation script to track the latest tag of harbor-…
qcserestipy 26c88f6
Added latest tag after release of harbor-cli
qcserestipy e151b07
Clean up
qcserestipy 1ec6478
Try add ranges to fix sorting in cli-docs side bar
qcserestipy 6d6b5d8
add ranges to fix sorting in cli-docs side bar and layout
qcserestipy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
# Step 1: Clone the required repositories | ||
HARBOR_CLI_REPO="https://github.com/goharbor/harbor-cli.git" | ||
|
||
# Step 2: Fetch the latest tag from the repository | ||
LATEST_TAG=$( | ||
git ls-remote --tags --sort='v:refname' "$HARBOR_CLI_REPO" | | ||
tail -n1 | | ||
awk -F/ '{print $3}' | ||
) | ||
|
||
# Step 3: Clone the repository at the latest tag | ||
git clone --depth 1 --branch "$LATEST_TAG" "$HARBOR_CLI_REPO" harbor-cli | ||
|
||
# Step 4: Copy the CLI documentation to the website directory | ||
HARBOR_CLI_DOCS="harbor-cli/doc/" | ||
WEBSITE_CLI_DOCS="content/cli-docs" | ||
rsync -av --delete --prune-empty-dirs \ | ||
--exclude '*.go' \ | ||
--exclude 'man-docs' \ | ||
--exclude 'README.md' \ | ||
"$HARBOR_CLI_DOCS" \ | ||
"$WEBSITE_CLI_DOCS" | ||
|
||
# Step 5: Clean up the cloned repository | ||
rm -rf harbor-cli |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
title: Harbor CLI Documentation | ||
--- | ||
|
||
Welcome to the Harbor CLI documentation. This provides detailed documentation for the Harbor CLI. | ||
|
||
## Harbor CLI Documentation | ||
|
||
This section describes the comprehensive set of commands provided by the Harbor CLI, which enables you to efficiently manage and interact with your Harbor registry. | ||
|
||
- `harbor` - Configure the Harbor CLI and set global flags to customize your experience. | ||
- `harbor artifact` - Manage artifacts in Harbor Repository | ||
- `harbor project` - Manage projects and assign resources to them | ||
- `harbor registry` - Manage registries in Harbor | ||
- `harbor repo` - Manage repositories in Harbor context | ||
- `harbor user` - Administer users in Harbor, including creating, updating, and managing user accounts | ||
|
||
## Access the Documentation Source Files | ||
|
||
The source files for this documentation set are located in the [Harbor CLI repository on Github](https://github.com/goharbor/harbor-cli/tree/main/doc/cli-docs). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
--- | ||
title: Harbor CLI Config Management | ||
weight: 25 | ||
--- | ||
|
||
# Harbor CLI Configuration Management | ||
|
||
> **Note** | ||
> The Harbor CLI follows the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) for configuration and data storage by default. | ||
|
||
## Introduction | ||
Harbor CLI is a flexible command-line tool that lets you manage various Harbor environments with different credentials. Whether you need a production-ready setup or quick testing configurations, the CLI's hierarchical structure and XDG support help keep things organized. | ||
|
||
|
||
## Understanding the Configuration Structure | ||
The Harbor CLI can manage multiple credentials and keep track of which credential is currently active. This setup allows you to maintain separate contexts for different Harbor instances or user accounts without having to rewrite configuration files manually. While the Harbor CLI configuration file manages your credentials, passwords themselves are never stored in plain text. Instead, they are secured using the AES-GCM encryption described in the [Harbor CLI Encryption documentation](../cli-config). | ||
|
||
### Example Configuration File | ||
Below is a simplified example of a typical Harbor CLI configuration file: | ||
```yaml | ||
current-credential-name: example@demo-harbor | ||
credentials: | ||
- name: example@demo-harbor | ||
username: example-user | ||
password: example-password | ||
serveraddress: https://demo.goharbor.io | ||
``` | ||
|
||
In this configuration: | ||
- **current-credential-name** references the active credential by name. | ||
- **credentials** holds one or more sets of user credentials, each following the same structure. | ||
|
||
## Managing Multiple Credentials | ||
If you need to work with multiple sets of credentials—such as development, staging, or production — Harbor CLI makes it easy to create and switch between them. | ||
|
||
> **Note**: For more login command details please refer to the [login command reference](../cli-docs/harbor-login.md). | ||
### Creating a New Credentials Entry | ||
Use the `harbor login` command with the required arguments to store new credentials: | ||
```bash | ||
harbor login --name my-new-credential \ | ||
--username myuser \ | ||
--password mypass \ | ||
https://my-harbor-instance.com | ||
``` | ||
This adds a new entry to your credentials list, allowing you to manage different Harbor accounts from the same CLI. | ||
|
||
### Switching Between Credentials | ||
To switch to another credential set, run: | ||
```bash | ||
harbor login --name <name-of-credential> | ||
``` | ||
The CLI will then set the specified credential as the active one, eliminating the need to manually edit your configuration files. This will overwrite the `current-credential-name`. | ||
|
||
|
||
## Configuration Hierarchy (Highest to Lowest Priority) | ||
|
||
1. **Explicit Config Flag** | ||
Provide a custom config file at runtime using `--config`: | ||
```bash | ||
harbor --config /path/to/custom/config.yaml artifact list | ||
``` | ||
|
||
2. **Environment Variable** | ||
Set a persistent configuration through the `HARBOR_CLI_CONFIG` environment variable: | ||
```bash | ||
export HARBOR_CLI_CONFIG="$HOME/.custom/harbor-config.yaml" | ||
harbor artifact list # Uses the environment-specified config | ||
``` | ||
|
||
3. **XDG Default Paths** | ||
Automatically discover configuration in the following order: | ||
```bash | ||
${XDG_CONFIG_HOME}/harbor-cli/config.yaml # If XDG_CONFIG_HOME is set | ||
~/.config/harbor-cli/config.yaml # Fallback default | ||
``` | ||
|
||
## Data Storage Management | ||
### Data File Location | ||
|
||
- **Primary Path**: `$XDG_DATA_HOME/harbor-cli/data.yaml` | ||
- **Fallback Path**: `$HOME/.local/share/harbor-cli/data.yaml` | ||
|
||
> **Important** | ||
> The data file automatically tracks the last-used configuration file path | ||
|
||
## Configuration Precedence Summary | ||
| Priority | Method | Example | | ||
|----------|----------------------------|---------------------------------------| | ||
| 1 | --config flag | harbor --config ./test.yaml ... | | ||
| 2 | HARBOR_CLI_CONFIG env var | export HARBOR_CLI_CONFIG=... | | ||
| 3 | XDG Default Locations | ~/.config/harbor-cli/config.yaml | | ||
|
||
## Practical Usage Examples | ||
### Scenario 1: Temporary Config Override | ||
```bash | ||
harbor --config ./experimental.yaml project create "new-project" | ||
``` | ||
|
||
### Scenario 2: Persistent Environment-based Config | ||
```bash | ||
echo 'export HARBOR_CLI_CONFIG="$HOME/work/configs/prod-harbor.yaml"' >> ~/.zshrc | ||
source ~/.zshrc | ||
harbor config list # Uses production config | ||
``` | ||
|
||
### Scenario 3: Reset to Default Configuration | ||
```bash | ||
unset HARBOR_CLI_CONFIG | ||
harbor config delete --current # Deletes current context | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: Harbor CLI Commands | ||
weight: 25 | ||
--- | ||
|
||
This section describes the comprehensive set of commands provided by the Harbor CLI, which enables you to efficiently manage and interact with your Harbor registry. The Harbor CLI commands are categorized by function, | ||
|
||
- `harbor` - Configure the Harbor CLI and set global flags to customize your experience. | ||
- `harbor artifact` - Manage artifacts in Harbor Repository | ||
- `harbor project` - Manage projects and assign resources to them | ||
- `harbor registry` - Manage registries in Harbor | ||
- `harbor repo` - Manage repositories in Harbor context | ||
- `harbor user` - Administer users in Harbor, including creating, updating, and managing user accounts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
title: harbor artifact delete | ||
weight: 35 | ||
--- | ||
## harbor artifact delete | ||
|
||
### Description | ||
|
||
##### delete an artifact | ||
|
||
```sh | ||
harbor artifact delete [flags] | ||
``` | ||
|
||
### Options | ||
|
||
```sh | ||
-h, --help help for delete | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
```sh | ||
-c, --config string config file (default is $HOME/.config/harbor-cli/config.yaml) | ||
-o, --output-format string Output format. One of: json|yaml | ||
-v, --verbose verbose output | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [harbor artifact](harbor-artifact.md) - Manage artifacts | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
title: harbor artifact info | ||
weight: 25 | ||
--- | ||
## harbor artifact info | ||
|
||
### Description | ||
|
||
##### Get info of an artifact | ||
|
||
### Synopsis | ||
|
||
Get info of an artifact | ||
|
||
```sh | ||
harbor artifact info [flags] | ||
``` | ||
|
||
### Examples | ||
|
||
```sh | ||
harbor artifact info <project>/<repository>/<reference> | ||
``` | ||
|
||
### Options | ||
|
||
```sh | ||
-h, --help help for info | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
```sh | ||
--config string config file (default is $HOME/.harbor/config.yaml) (default "/home/user/.harbor/config.yaml") | ||
-o, --output-format string Output format. One of: json|yaml | ||
-v, --verbose verbose output | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [harbor artifact](harbor-artifact.md) - Manage artifacts | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
title: harbor artifact label add | ||
weight: 95 | ||
--- | ||
## harbor artifact label add | ||
|
||
### Description | ||
|
||
##### Attach a label to an artifact in a Harbor project repository | ||
|
||
### Synopsis | ||
|
||
Attach an existing label to a specific artifact identified by <project>/<repository>:<reference>. | ||
You can specify the artifact and label directly as arguments, or interactively select them if arguments are omitted. | ||
|
||
Examples: | ||
# Add a label to an artifact using project/repo:reference and label name | ||
harbor artifact label add myproject/myrepo@sha256:abcdef1234567890 dev | ||
|
||
# Prompt-based label selection for an artifact | ||
harbor artifact label add library/nginx:1.21 | ||
|
||
# Fully interactive mode (prompt for everything) | ||
harbor artifact label add | ||
|
||
|
||
```sh | ||
harbor artifact label add [flags] | ||
``` | ||
|
||
### Options | ||
|
||
```sh | ||
-h, --help help for add | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
```sh | ||
-c, --config string config file (default is $HOME/.config/harbor-cli/config.yaml) | ||
-o, --output-format string Output format. One of: json|yaml | ||
-v, --verbose verbose output | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [harbor artifact label](harbor-artifact-label.md) - label command for artifacts | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
title: harbor artifact label delete | ||
weight: 90 | ||
--- | ||
## harbor artifact label delete | ||
|
||
### Description | ||
|
||
##### Detach a label from an artifact in a Harbor project repository | ||
|
||
### Synopsis | ||
|
||
Remove an existing label from a specific artifact identified by <project>/<repository>:<reference>. | ||
You can provide the artifact and label name as arguments, or choose them interactively if not specified. | ||
|
||
Examples: | ||
# Remove a label by specifying artifact and label name | ||
harbor artifact label delete library/nginx:latest stable | ||
|
||
# Prompt-based label selection for a specific artifact | ||
harbor artifact label del library/nginx:1.21 | ||
|
||
# Fully interactive mode (prompt for project, repo, reference, and label) | ||
harbor artifact label delete | ||
|
||
# Remove a label from an artifact identified by digest | ||
harbor artifact label del myproject/myrepo@sha256:abcdef1234567890 qa-label | ||
|
||
```sh | ||
harbor artifact label delete [flags] | ||
``` | ||
|
||
### Options | ||
|
||
```sh | ||
-h, --help help for delete | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
```sh | ||
-c, --config string config file (default is $HOME/.config/harbor-cli/config.yaml) | ||
-o, --output-format string Output format. One of: json|yaml | ||
-v, --verbose verbose output | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [harbor artifact label](harbor-artifact-label.md) - label command for artifacts | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.