goharbor / harbor-cli Goto Github PK
View Code? Open in Web Editor NEW[Sandbox] Official Harbor CLI
License: Apache License 2.0
[Sandbox] Official Harbor CLI
License: Apache License 2.0
Create project is a common flow, the current cli doesn't make it easy.
In my opinion, this should work.
harbor project create my_project
This should create a new private project my_project
with unlimited quota.
harbor-cli on ξ fork/bupd/batch-process:batch-process via πΉ v1.21.6
β― ./harbor project create --help
create project
Usage:
harbor project create [flags]
Flags:
-h, --help help for create
--name string Name of the project
--proxy-cache Whether the project is a proxy cache project
--public Project is public or private (default true)
--registry-id string ID of referenced registry when creating the proxy cache project
--storage-limit string Storage quota of the project (default "-1")
Global Flags:
--config string config file (default is $HOME/.harbor/config.yaml) (default "/Users/vadim/.harbor/config.yaml")
-o, --output-format string Output format. One of: json|yaml
-v, --verbose verbose output
harbor-cli on ξ fork/bupd/batch-process:batch-process via πΉ v1.21.6
β― ./harbor project create my_project
Why is Name of Credential mandatory?
What are the use cases where a user needs to set Name of Credential
Also, why can the name of credential not be generated as eg. [email protected]
./harbor login 8gears.container-registry.com
Server
> 8gears.container-registry.com
User Name
> vadim
Password
> *********
β Name of Credential
β >
To add the multiple TUI selection as a base component in separate PR.
which can be used by multiple commands that support multiple selection and their associated action.
with that we can mimic the behavior of multiple select and action in TUI.
Originally posted by @bupd in #80 (comment)
like the --password-stdin flag in Docker login is beneficial for security as it allows the password to be provided via standard input, preventing it from being exposed in command-line history or logs, enhancing overall password protection practices.
It would make sense if the harbor-cli followed the same pattern.
Ctrl+C keyboard interrupt crashes the code on login.
Trying to log in.
./harbor login 8gears.container-registry.com
now I hit aboard (CTRL+C)
panic: user aborted
goroutine 1 [running]:
github.com/goharbor/harbor-cli/pkg/views/login.CreateView(0x14000408240)
/Users/vadim/Development/container-registry/harbor-cli/pkg/views/login/create.go:61 +0x3e8
github.com/goharbor/harbor-cli/cmd/harbor/root.createLoginView(0x0?)
/Users/vadim/Development/container-registry/harbor-cli/cmd/harbor/root/login.go:77 +0x44
github.com/goharbor/harbor-cli/cmd/harbor/root.LoginCommand.func1(0x1400022eb00?, {0x140004064a0?, 0x4?, 0x1008fa4db?})
/Users/vadim/Development/container-registry/harbor-cli/cmd/harbor/root/login.go:48 +0x174
github.com/spf13/cobra.(*Command).execute(0x140001a0c00, {0x14000406470, 0x1, 0x1})
/Users/vadim/go/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0x828
github.com/spf13/cobra.(*Command).ExecuteC(0x140001a0600)
/Users/vadim/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x344
github.com/spf13/cobra.(*Command).Execute(0x100e522b8?)
/Users/vadim/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039 +0x1c
main.main()
/Users/vadim/Development/container-registry/harbor-cli/cmd/harbor/main.go:10 +0x20
The Harbor CLI tool's login command does not correctly handle the specified server URL, resulting in various errors and failed login attempts.
I attached video for the clear Explanation.
it should follow the schema as discussed here: #38
Track the missing commands in the CLI and ensure their implementation.
Command | Description | Priority | Status |
---|---|---|---|
Member | Manage project Members | High | #85 |
Quota | Manage project quotas | High | #97 |
Robot | Manage robot accounts in projects | High | #100 |
Replication | Manage replication policies | High | to-do |
Retention | Manage retention policies | High | to-do |
Audit | Manage and audit recent logs | Medium | to-do |
Usergroup | Manage user groups | Medium | to-do |
Ping | Ping the API server | Low | to-do |
Command | Description |
---|---|
Webhook | Manage project webhooks |
LDAP | Integrate with LDAP |
Preheat | Manage preheat policies and instances |
Security | Manage system security settings |
Configuration | Manage system configurations |
System Config | Manage internal system configurations |
Permissions | Manage system and project permissions |
I would like to tackle these issues to ensure proper implementation and integration of each command.
Your feedback and suggestions are welcome as I work through this.
Edit:
This issue is meant for collaboration and streamlining the process for everyone. Everyone is welcome to contribute and work on this. This issue serves as a tracker and reference point for all the missing commands in the CLI.
The metadata command might be inside the project command (such as project metadata
rather than metadata [project]
, as metadata is only for projects and it is more intuitive to access.
The Harbor web UI supports deleting multiple projects simultaneously, but this functionality is currently missing in the CLI. We need to add this feature to the CLI to improve the overall user experience and ensure that the CLI can perform similar actions available in the web UI.
This enhancement is crucial for users managing multiple projects who prefer or require CLI operations over the web UI.
It aligns the CLI capabilities with the web UI, ensuring a consistent experience across different interfaces.
The updated CLI command should allow users to delete multiple projects with a single command, similar to how it is done in the web UI.
As a user, I would rather not download the source code, compile to have binary.
A common practice for downloading and installing CLI tools is the use of popular Package Manager like Chocolatey on Win or Homebrew on Mac and so on.
One way to accomplish is to create a pipeline for each package manager.
Another alternative to have an all-in-one solution is to use https://jreleaser.org/ that provides many option to release and publish the binary to many package management systems. see full list https://jreleaser.org/guide/latest/integrations.html#_package_publish
At least we should support the following option
this is a nice software, but not notable enough for us to package in Homebrew for now. This is not a decision on the merits of the software, but we cannot distribute every single piece of software and have to draw a line on βnotabilityβ somewhere. Of course, we would be happy to reconsider in the future.
In Homebrew/homebrew-core#165860 the PR to add harbor CLI to Homebrew was rejected, we should try this again, once we reach a certain maturity and recognition in the community.
Add Replication Command to Manage replication policies and execution
New Commands:
harbor replication list
-- to list replication policies.
harbor replication create
-- to create a replication policy.
harbor replication delete
-- to delete a replication policy.
harbor replication start
-- to start a replication policy execution.
harbor replication stop
-- to stop a replication policy execution.
I don't think the schema should be mandatory.
./harbor login demo.goharbor.io -u admin -p Harbor12345
Error: login failed, please check your credentials: Get "https://localhost/demo.goharbor.io/users/current": dial tcp 127.0.0.1:443: connect: connection refused
Usage:
(--inecure
) like in curlEnhance the current CLI code by implementing the following measures for a smoother development experience, easier CLI installations, a structured release cycle, and more:
./harbor project create --help
create project
Usage:
harbor project create [flags]
Flags:
-h, --help help for create
--name string Name of the project
--proxy-cache Whether the project is a proxy cache project
--public Project is public or private (default true)
--registry-id string ID of referenced registry when creating the proxy cache project
--storage-limit string Storage quota of the project (default "-1")
Global Flags:
--config string config file (default is $HOME/.harbor/config.yaml) (default "/Users/vadim/.harbor/config.yaml")
-o, --output-format string Output format. One of: json|yaml
-v, --verbose verbose output
Here I cannot figure out what default true means, in --public
By default, projects are private unless they are specified explicitly as public.
Issue -> We need to enhance the readability and descriptive nature of the Harbor-CLI project's readme file.
Note -> take a look at how other projects organize their readme.
Problem
When updating the registry, all the input field are empty.
If the user gets the value in the input field like in web UI, It is more easier to make changes to them.
Solution
Values need to shown while using update registry command
Timeline: https://github.com/cncf/mentoring/tree/main/programs/lfx-mentorship/2024/02-Jun-Aug
Mentee applications due Tues May 28, 5:00 PM PDT
For more details, see the proposal for the summer term --> https://github.com/cncf/mentoring/blob/main/programs/lfx-mentorship/2024/02-Jun-Aug/project_ideas.md
To enable the usergroup functionality within our CLI, it's imperative to set up LDAP/OIDC authentication. This configuration is crucial as it allows us to access usergroups and facilitates the integration of LDAP and OIDC for user authentication.
Similar to kubectl we want users of the harbor-cli users to provide the same representations and output options.
YAML, JSON, Table.
Currently, only JSON output is supported:
./harbor get project testproject-832165132
{
"Payload": {
"chart_count": 0,
"creation_time": "2024-02-05T14:58:53.974Z",
"current_user_role_ids": null,
"cve_allowlist": {
"creation_time": "0001-01-01T00:00:00.000Z",
"id": 21,
"items": [],
"project_id": 20,
"update_time": "0001-01-01T00:00:00.000Z"
},
"metadata": {
"public": "true"
},
"name": "testproject-832165132",
"owner_id": 20,
"owner_name": "koenc",
"project_id": 20,
"repo_count": 2,
"update_time": "2024-02-05T14:58:53.974Z"
}
}
Many of the current list
commands in the CLI are not streamlined, and some are missing the ID function. This inconsistency makes it difficult for users to utilize these commands effectively, especially in scripts where resource IDs are required for further modifications.
This aligns the CLI with best practices for command-line tools, ensuring all necessary information is readily available in command outputs.
After implementing this enhancement, commands such as project list
, user list
, repo list
, etc., will include their resource ID by default, making it easier for users to identify and interact with resources.
hi! I was trying to set this up and seems like credential resolution panics the binary instead of outputting something like "Empty ~/,harbor/config, please " - the patch for this is rather easy, should I start a PR or is this a candidate for the mentorship program?
Cheers and thanks!
Abhinav.
End-to-end tests are essential for ensuring the quality of Harbor CLI features
Using Ginkgo and BDD for Harbor CLI tests can add complexity. Sticking with standard Go testing if the project is simple. But for complex projects, Ginkgo offers clearer tests, better collaboration.
Note: If you have alternative suggestions for constructing end-to-end tests for Harbor, please feel free to share your thoughts below.
Implemented support for codecov to ensure comprehensive code coverage
We need to create and build some sort of documentation regarding the CLI and its basic and advances usage.
Ideally something that can used on the CLI but also in the online form in Markdown.
Goal would be to generate a markdown in e.g docs dir, this dir would then imported by https://github.com/goharbor/website and rendered on as a page on goharbor.io/
Harbor can be used through docker extension itself.
https://www.docker.com/products/extensions/
Would be good if Login had the ability to prompt for a hidden password for security.
example ideas:
harbor login demo.goharbor.io -u admin
Password Prompt: **********
harbor login demo.goharbor.io -u admin --passwordprompt
Password Prompt: **********
This is not one of the top priorities, but in my opinion it would make sense to replace the Makefile and large part of the workflows with https://dagger.io/
Some benefits I see
Some commands do not provide all the parameters of the go client function. For example the user list
and user repo
command. Also, some commands need refactoring such as getting the credentialName
using viper
.
The current structure, with all features under one command ("harbor"), may be confusing for users, especially as more functionalities are added.
purpose | usage | implemented | |
---|---|---|---|
get | view the project by name or id | harbor get project [NAMEID] [flags] | yes |
list | list the project | harbor list project [flags] | yes |
create | create the project | harbor create project | yes |
delete | delete the project | harbor delete project [NAME/ID] [flags] | yes |
The proposed behavior, aligning with the approach used in popular tools like doctl, simplifies user experience by introducing separate "project" and "registry" commands for efficient management.
purpose | usage | implemented | |
---|---|---|---|
project | allow you to create, manage and assign resources to your project | harbor project [commands] | no |
registry | create, manage your container registry | harbor registry [commands] | no |
harbor project
Subcommand | Usage | Purpose | Flags |
---|---|---|---|
get |
harbor project get |
Retrieve information about a project. | |
list |
harbor project list |
List all available projects. | |
create |
harbor project create |
Create a new project | |
update |
harbor project update |
Update an existing project | |
delete |
harbor project delete |
Delete the specified project | |
harbor user
Subcommand | Usage | Purpose | Flags |
---|---|---|---|
list |
harbor user list |
||
create |
harbor project create |
||
update |
harbor project update |
||
delete |
harbor user delete |
||
harbor robot
harbor replication
harbor repository
Robot accounts created before Harbor v2.2 are considered legacy robot accounts and will appear with aΒ LegacyΒ label in the Harbor v2.2 and later interface. It will be removed in a future version of Harbor. (link)
Add CLI Commands for Robot Account Management:
Ensure no sensitive information is leaked during managing robot secrets.
Implementing secure and efficient robot account management in the CLI is crucial for enabling automated operations and replication, enhancing overall project security and functionality.
When we create a new user, there is some guidelines for accepting the password like
If the user violate one of the guideline, we cannot create a new user.
Expected Result:
Required proper error message when user violate these guidelines at the time we enter the password.
We require a GitHub workflow to perform linting checks on Go code pushed by contributors.
When executing the ./harbor registry list
command, an error is encountered:
./harbor registry list
Error: flag accessed but not defined: credential-name
This error occurs because the list command attempts to access a flag named credential-name
, which is neither registered within the command nor within any parent commands.
To resolve this issue, the credential-name flag should be registered within the list command.
When using bash in Windows, a new line is added with the input when enter is pressed for the next input. As a result, an extra space character is added to the server URL. It happens for all the inputs probably. For example, the password is changed due to carriage return so the user is unable to log in. Without pressing enter, the user cannot move to the next input. So it would be better to trim the spaces of the inputs.
System: Windows 10
Terminal: Bash
When creating a project as a user, I would expect that there is no need to explicitly provide the --name parameter.
So something like this ./harbor create project vadim-test should work.
--public should be by default `false``
The description and logic behind --registry-id int is not obvious/clear. When id !=1 does it mean that than a proxy project is created?
./harbor create project vadim-test
Error: [POST /projects][500] createProjectInternalServerError &{Errors:[0x14000130020]}
Usage:
harbor create project [flags]
Flags:
-h, --help help for project
--name string Name of the project
--public Project is public or private (default true)
--registry-id int ID of referenced registry when creating the proxy cache project (default 1)
--storage-limit int Storage quota of the project (default -1)
Add Quota Command to Manage quotas of the projects.
New Commands:
harbor quota list
-- to list quotasharbor quota get
-- to get quota of a projectharbor quota update
-- to update a quota of project.Fix a part of #94
Log in into harbor should work without specifying a schema.
./harbor login 8gears.container-registry.com
login failed, please check your credentials: Get "https://localhost/8gears.container-registry.com/users/current": dial tcp [::1]:443: connect: connection refused
The following combinations of commands should all work with schema, without schema, port number.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.