Terminology
Commands invocation is structured as follows:
GLOBAL OPTIONS
Global options are options that apply to all commands. They must be specified before the command. Examples of this are --config
, --url
, --username
, etc.
See the output of harbor --help
for a full list of global options.
COMMAND
Command is a resource such as project
, repository
, artifact
, etc.
SUBCOMMAND
, SUBSUBCOMMAND
, etc.
Certain commands have subcommands, and these subcommands can have their own set of subcommands, etc.
An example of this is the commmand:
Which can be decomposed into the following:
COMMAND
:project
SUBCOMMAND
:metadata
SUBSUBCOMMAND
:field
SUBSUBSUBCOMMAND
:set
The final subcommand is the action to perform on the resource, such as create
, delete
, list
, etc.
Actions terminology
get
- Get a resourcecreate
- Create a resource-
delete
- Delete a resource- Prompts for confirmation unless
--force
is specified. This behavior can be disabled in the configuration file undergeneral.confirm_deletion
.
- Prompts for confirmation unless
-
list
- List resources.- Most of these commands expose the options
--query
,--sort
,--limit
,--page
and--page-size
to filter and limit the output. - Each command may have its own set of options for more granular filtering of the resources such as
--tag
,--architecture
. Some of this behavior can be achieved with--query
as well. - See harborapi
--query
docs for more information about the different parameters that can be used to filter the resources using--query
. - See harborapi
--sort
docs for information on how to use the--sort
parameter.
- Most of these commands expose the options
update
- Update a resource.- The behavior of these commands mimic a PATCH request. A
update
command performs a partial update to an existing resource replacing a subset of the resource's fields with new values. - Parameter names attempt to be 1:1 with the resource's field names. I.e. `project update --public trueAny divergences are specified in the relevant command's help text.
- The CLI fetches the existing resource first then replaces the given fields with the new values.1
- The behavior of these commands mimic a PATCH request. A
set
- Set the value of a specific field on a resource.- Used for setting single values, such as setting default project scanner.
add
- Add a value or reference to a resource to a resource- Used when multiple values can be added to a resource field, such as adding labels to artifacts.
start
- Start a job (scan, replication, etc.)stop
- Stop a jobinfo
- Get information about an immutable resource- Used for getting information about a resource that cannot be updated by users, such as getting information about the system status.
ARGS
The args for a command is usually one or more names or IDs identifying a resource. For example:
The command specifies my-project
as the argument for the get
action on the project
resource.
Certain commands accept either a name or ID as arguments. Prefix IDs with id:
to specify that the argument is an ID. Check the relevant command's documentation for more information.
COMMAND OPTIONS
Command options are options that apply to a command.
Theproject create
command has a --public
option that can be used to create a public project.
-
The endpoints themselves are
PUT
endpoints in the Harbor API but they usePATCH
semantics (i.e. partial updates). Until this is codified as intended behavior by Harbor, we will continue to fetch the existing resource first and then replace the given fields with the new values before sending back the updated resource to the server. ↩