mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-20 07:37:38 +01:00
Merge branch 'master' into dev
This commit is contained in:
commit
41637ea559
39
README.md
39
README.md
@ -5,22 +5,25 @@
|
|||||||
![alg tag](https://cloud.githubusercontent.com/assets/2390463/13484557/088a1000-e13a-11e5-87d4-a64366365bef.png)
|
![alg tag](https://cloud.githubusercontent.com/assets/2390463/13484557/088a1000-e13a-11e5-87d4-a64366365bef.png)
|
||||||
|
|
||||||
|
|
||||||
Project Harbor is an enterprise-class registry server, which extends the open source Docker Registry server by adding the functionality usually required by an enterprise, such as security, replication and management. Harbor is primarily designed to be a private registry - providing the needed security and control that enterprises require. It also helps minimize bandwidth usage, which is helpful to both improve productivity (local network access) as well as performance (for those with poor internet connectivity).
|
Project Harbor is an enterprise-class registry server that stores and distributes Docker images. Harbor extends the open source Docker Distribution by adding the functionalities usually required by an enterprise, such as security, identity and management. As an enterprise private registry, Harbor offers better performance and security. Having a registry closer to the build and run environment improves the image transfer efficiency. Harbor supports the setup of multiple registries and has images replicated between them. With Harbor, the images are stored within the private registry, keeping the bits and intellectual properties behind the company firewall. In addition, Harbor offers advanced security features, such as user management, access control and activity auditing.
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
* **Role based access control**: Users and Docker repositories are organized via "projects", a user can have different permission for images under a project.
|
* **Role based access control**: Users and repositories are organized via 'projects' and a user can have different permission for images under a project.
|
||||||
* **Image replication**: Images can be replicated(synchronized) between multiple registry instances. Great for load balancing and distributed data centers.
|
* **Image replication**: Images can be replicated (synchronized) between multiple registry instances. Great for load balancing, high availability, hybrid and multi-cloud scenarios.
|
||||||
* **Graphical user portal**: User can easily browse, search Docker repositories, manage projects/namespaces.
|
* **Graphical user portal**: User can easily browse, search repositories and manage projects.
|
||||||
* **AD/LDAP support**: Harbor integrates with existing enterprise AD/LDAP for user authentication and management.
|
* **AD/LDAP support**: Harbor integrates with existing enterprise AD/LDAP for user authentication and management.
|
||||||
* **Auditing**: All the operations to the repositories are tracked.
|
* **Auditing**: All the operations to the repositories are tracked.
|
||||||
* **Internationalization**: Already localized for English, Chinese, German, Japanese and Russian. More languages can be added.
|
* **Internationalization**: Already localized for English, Chinese, German, Japanese and Russian. More languages can be added.
|
||||||
* **RESTful API**: RESTful APIs for most administrative operations, easing intergration with external management platforms.
|
* **RESTful API**: RESTful APIs for most administrative operations, easy to integrate with external systems.
|
||||||
|
* **Easy deployment**: docker compose and offline installer.
|
||||||
|
|
||||||
### Getting Started
|
### Install
|
||||||
Harbor is self-contained and can be easily deployed via docker-compose (Quick-Start steps below). Refer to the [Installation and Configuration Guide](docs/installation_guide.md) for detailed information.
|
|
||||||
|
|
||||||
**System requirements:**
|
**System requirements:**
|
||||||
Harbor only works with docker 1.10+ and docker-compose 1.6.0+, and an internet-connected host.
|
Harbor only works with docker 1.10.0+ and docker-compose 1.6.0+.
|
||||||
|
|
||||||
|
#### Install via docker compose
|
||||||
|
On an Internet connected host, Harbor can be easily installed via docker-compose:
|
||||||
|
|
||||||
1. Get the source code:
|
1. Get the source code:
|
||||||
|
|
||||||
@ -43,22 +46,24 @@ Harbor only works with docker 1.10+ and docker-compose 1.6.0+, and an internet-c
|
|||||||
$ docker-compose up -d
|
$ docker-compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
_If everything worked properly, you should be able to open a browser to visit the admin portal at http://reg.yourdomain.com . Note that the default administrator username/password are admin/Harbor12345 ._
|
#### Install via offline installer
|
||||||
|
For those who do not want to clone the source, or need to install Harbor on a server not connected to the Internet, there is a pre-built installation package available. For details on how to download and use the installation package, please refer to [Installation and Configuration Guide](docs/installation_guide.md).
|
||||||
|
|
||||||
Log in to the admin portal and create a new project, e.g. `myproject`. You can then use docker commands to login and push images (By default, the registry server listens on port 80):
|
#### After installation
|
||||||
|
_If everything worked properly, you should be able to open a browser to visit the admin portal at http://reg.yourdomain.com. Note that the default administrator username/password are admin/Harbor12345._
|
||||||
|
|
||||||
|
Log in to the admin portal and create a new project, e.g. `myproject`. You can then use docker commands to login and push images (by default, the registry server listens on port 80):
|
||||||
```sh
|
```sh
|
||||||
$ docker login reg.yourdomain.com
|
$ docker login reg.yourdomain.com
|
||||||
$ docker push reg.yourdomain.com/myproject/myrepo
|
$ docker push reg.yourdomain.com/myproject/myrepo
|
||||||
```
|
```
|
||||||
|
|
||||||
**Data migration:**
|
### Upgrade
|
||||||
|
|
||||||
If you are upgrading Harbor from an older version with existing data, you may need to migrate the data to fit the new database schema. For more details please refer to [Data Migration Guide](docs/migration_guide.md) .
|
If you are upgrading Harbor from an older version with existing data, you need to migrate the data to fit the new database schema. For more details, please refer to [Data Migration Guide](docs/migration_guide.md).
|
||||||
|
|
||||||
**NOTE:**
|
### Run
|
||||||
For those who don't want to clone the source, or need to install Harbor on a server not connected to the Internet - there is a pre-built installation package available. For details on how to download and use this installation package, please refer to [Installation and Configuration Guide](docs/installation_guide.md) .
|
For information on how to use Harbor, please take a look at [User Guide](docs/user_guide.md).
|
||||||
|
|
||||||
For information on how to use Harbor, please see [User Guide](docs/user_guide.md) .
|
|
||||||
|
|
||||||
### Contribution
|
### Contribution
|
||||||
We welcome contributions from the community. If you wish to contribute code and you have not signed our contributor license agreement (CLA), our bot will update the issue when you open a pull request. For any questions about the CLA process, please refer to our [FAQ](https://cla.vmware.com/faq).
|
We welcome contributions from the community. If you wish to contribute code and you have not signed our contributor license agreement (CLA), our bot will update the issue when you open a pull request. For any questions about the CLA process, please refer to our [FAQ](https://cla.vmware.com/faq).
|
||||||
@ -77,4 +82,4 @@ Harbor is available under the [Apache 2 license](LICENSE).
|
|||||||
<img alt="beego" src="docs/img/beegoLogo.png"> Harbor is powered by <a href="http://beego.me/">Beego</a>.
|
<img alt="beego" src="docs/img/beegoLogo.png"> Harbor is powered by <a href="http://beego.me/">Beego</a>.
|
||||||
|
|
||||||
### About
|
### About
|
||||||
Project Harbor is initiated by VMware China R&D as a Cloud Application Accelerator (CAA) project. CAA provides a set of tools to improve the productivity of cloud developers in China and other countries. CAA includes tools like registry server, mirror server, decentralized image distributor, etc.
|
Project Harbor is initiated by the Advanced Technology Center (ATC), VMware China R&D as a Cloud Application Accelerator (CAA) project.
|
||||||
|
94
contrib/sdk/harbor-py/.gitignore
vendored
Normal file
94
contrib/sdk/harbor-py/.gitignore
vendored
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
# Temporary files
|
||||||
|
files.txt
|
||||||
|
*.swp
|
||||||
|
*~
|
||||||
|
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
env/
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*,cover
|
||||||
|
.hypothesis/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# IPython Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# celery beat schedule file
|
||||||
|
celerybeat-schedule
|
||||||
|
|
||||||
|
# dotenv
|
||||||
|
.env
|
||||||
|
|
||||||
|
# virtualenv
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
69
contrib/sdk/harbor-py/README.md
Normal file
69
contrib/sdk/harbor-py/README.md
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
## Introduction
|
||||||
|
|
||||||
|
[harbor](https://github.com/vmware/harbor) is the enterprise-class registry server for docker distribution.
|
||||||
|
|
||||||
|
[harbor-py](https://github.com/tobegit3hub/harbor-py) is the native and compatible python SDK for harbor. The supported APIs are list below.
|
||||||
|
|
||||||
|
- [x] Projects APIs
|
||||||
|
- [x] [Get projects](./examples/get_projects.py)
|
||||||
|
- [x] [Create project](./examples/create_project.py)
|
||||||
|
- [x] [Check project exist](./examples/check_project_exist.py)
|
||||||
|
- [x] [Set project publicity](./examples/set_project_publicity.py)
|
||||||
|
- [x] [Get project id from name](./examples/get_project_id_from_name.py)
|
||||||
|
- [ ] Get project access logs
|
||||||
|
- [ ] Get project member
|
||||||
|
- [ ] Get project and user member
|
||||||
|
- [x] Users APIs
|
||||||
|
- [x] [Get users](./examples/get_users.py)
|
||||||
|
- [x] [Create user](./examples/create_user.py)
|
||||||
|
- [x] [Update user profile](./examples/update_user_profile.py)
|
||||||
|
- [x] [Delete user](./examples/delete_user.py)
|
||||||
|
- [x] [Change password](./examples/change_password.py)
|
||||||
|
- [x] [Promote as admin](./examples/promote_as_admin.py)
|
||||||
|
- [x] Repositories APIs
|
||||||
|
- [x] [Get repositories](./examples/get_repositories.py)
|
||||||
|
- [x] [Delete repository](./examples/delete_repository.py)
|
||||||
|
- [x] [Get repository tags](./examples/get_repository_tags.py)
|
||||||
|
- [x] [Get repository manifests](./examples/get_repository_manifests.py)
|
||||||
|
- [x] Others APIs
|
||||||
|
- [x] [Search](./examples/search.py)
|
||||||
|
- [x] [Get statistics](./examples/get_statistics.py)
|
||||||
|
- [x] [Get top accessed repositories](./examples/get_top_accessed_repositories.py)
|
||||||
|
- [x] [Get logs](./examples/get_logs.py)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```
|
||||||
|
pip install harbor-py
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
client.get_projects()
|
||||||
|
client.get_users()
|
||||||
|
client.get_statistics()
|
||||||
|
client.get_top_accessed_repositories()
|
||||||
|
client.search("library")
|
||||||
|
```
|
||||||
|
|
||||||
|
For more usage, please refer to the [examples](./examples/).
|
||||||
|
|
||||||
|
## Contribution
|
||||||
|
|
||||||
|
If you have any suggestion, feel free to submit [issues](https://github.com/tobegit3hub/harbor-py/issues) or send [pull-requests](https://github.com/tobegit3hub/harbor-py/pulls) for `harbor-py`.
|
||||||
|
|
||||||
|
Publish `harbor-py` package to [pypi](https://pypi.python.org/pypi/harbor-py/) server with the following commands.
|
||||||
|
|
||||||
|
```
|
||||||
|
python setup.py register -r pypi
|
||||||
|
python setup.py sdist upload -r pypi
|
||||||
|
```
|
18
contrib/sdk/harbor-py/examples/change_password.py
Executable file
18
contrib/sdk/harbor-py/examples/change_password.py
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Change password
|
||||||
|
user_id = 2
|
||||||
|
old_password = "test-password"
|
||||||
|
new_password = "new-password"
|
||||||
|
client.change_password(user_id, old_password, new_password)
|
16
contrib/sdk/harbor-py/examples/check_project_exist.py
Executable file
16
contrib/sdk/harbor-py/examples/check_project_exist.py
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Check if project exists
|
||||||
|
project_name = "test-project"
|
||||||
|
print(client.check_project_exist(project_name))
|
17
contrib/sdk/harbor-py/examples/create_project.py
Executable file
17
contrib/sdk/harbor-py/examples/create_project.py
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Create project
|
||||||
|
project_name = "test-project"
|
||||||
|
is_public = True
|
||||||
|
client.create_project(project_name, is_public)
|
20
contrib/sdk/harbor-py/examples/create_user.py
Executable file
20
contrib/sdk/harbor-py/examples/create_user.py
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Create user
|
||||||
|
username = "test-username"
|
||||||
|
email = "test-email@gmail.com"
|
||||||
|
password = "test-password"
|
||||||
|
realname = "test-realname"
|
||||||
|
comment = "test-comment"
|
||||||
|
client.create_user(username, email, password, realname, comment)
|
16
contrib/sdk/harbor-py/examples/delete_repository.py
Executable file
16
contrib/sdk/harbor-py/examples/delete_repository.py
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Delete repository
|
||||||
|
repo_name = "library/cirros"
|
||||||
|
client.delete_repository(repo_name)
|
16
contrib/sdk/harbor-py/examples/delete_user.py
Executable file
16
contrib/sdk/harbor-py/examples/delete_user.py
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Delete user
|
||||||
|
user_id = 2
|
||||||
|
print(client.delete_user(user_id))
|
15
contrib/sdk/harbor-py/examples/get_logs.py
Executable file
15
contrib/sdk/harbor-py/examples/get_logs.py
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Get logs
|
||||||
|
print(client.get_logs())
|
16
contrib/sdk/harbor-py/examples/get_project_id_from_name.py
Executable file
16
contrib/sdk/harbor-py/examples/get_project_id_from_name.py
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Get project id from name
|
||||||
|
project_name = "library"
|
||||||
|
print(client.get_project_id_from_name(project_name))
|
15
contrib/sdk/harbor-py/examples/get_projects.py
Executable file
15
contrib/sdk/harbor-py/examples/get_projects.py
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Get all projects
|
||||||
|
print(client.get_projects())
|
16
contrib/sdk/harbor-py/examples/get_repositories.py
Executable file
16
contrib/sdk/harbor-py/examples/get_repositories.py
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Get all repositories
|
||||||
|
project_id = 1
|
||||||
|
print(client.get_repositories(project_id))
|
17
contrib/sdk/harbor-py/examples/get_repository_manifests.py
Executable file
17
contrib/sdk/harbor-py/examples/get_repository_manifests.py
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Get repository manifests
|
||||||
|
repo_name = "library/cirros"
|
||||||
|
tag = "latest"
|
||||||
|
client.get_repository_manifests(repo_name, tag)
|
16
contrib/sdk/harbor-py/examples/get_repository_tags.py
Executable file
16
contrib/sdk/harbor-py/examples/get_repository_tags.py
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Get repository tags
|
||||||
|
repo_name = "library/cirros"
|
||||||
|
client.get_repository_tags(repo_name)
|
13
contrib/sdk/harbor-py/examples/get_statistics.py
Executable file
13
contrib/sdk/harbor-py/examples/get_statistics.py
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
print(client.get_statistics())
|
19
contrib/sdk/harbor-py/examples/get_top_accessed_repositories.py
Executable file
19
contrib/sdk/harbor-py/examples/get_top_accessed_repositories.py
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Get top accessed respositories
|
||||||
|
print(client.get_top_accessed_repositories())
|
||||||
|
|
||||||
|
# Get top accessed respositories with count
|
||||||
|
count = 1
|
||||||
|
print(client.get_top_accessed_repositories(count))
|
15
contrib/sdk/harbor-py/examples/get_users.py
Executable file
15
contrib/sdk/harbor-py/examples/get_users.py
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Get all users
|
||||||
|
print(client.get_users())
|
16
contrib/sdk/harbor-py/examples/promote_as_admin.py
Executable file
16
contrib/sdk/harbor-py/examples/promote_as_admin.py
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Promote as admin
|
||||||
|
user_id = 2
|
||||||
|
client.promote_as_admin(user_id)
|
16
contrib/sdk/harbor-py/examples/search.py
Executable file
16
contrib/sdk/harbor-py/examples/search.py
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Search with query string
|
||||||
|
query_string = "library"
|
||||||
|
print(client.search(query_string))
|
17
contrib/sdk/harbor-py/examples/set_project_publicity.py
Executable file
17
contrib/sdk/harbor-py/examples/set_project_publicity.py
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Set project publicity
|
||||||
|
project_id = 1
|
||||||
|
is_public = True
|
||||||
|
client.set_project_publicity(project_id, is_public)
|
12
contrib/sdk/harbor-py/examples/test_harborclient.py
Executable file
12
contrib/sdk/harbor-py/examples/test_harborclient.py
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
19
contrib/sdk/harbor-py/examples/update_user_profile.py
Executable file
19
contrib/sdk/harbor-py/examples/update_user_profile.py
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("../")
|
||||||
|
|
||||||
|
from harborclient import harborclient
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
user = "admin"
|
||||||
|
password = "Harbor12345"
|
||||||
|
|
||||||
|
client = harborclient.HarborClient(host, user, password)
|
||||||
|
|
||||||
|
# Update user profile
|
||||||
|
user_id = 2
|
||||||
|
email = "new@gmail.com"
|
||||||
|
realname = "new_realname"
|
||||||
|
comment = "new_comment"
|
||||||
|
client.update_user_profile(user_id, email, realname, comment)
|
5
contrib/sdk/harbor-py/format_code.sh
Executable file
5
contrib/sdk/harbor-py/format_code.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
find ./ -name "*.py" |xargs sudo yapf -i
|
0
contrib/sdk/harbor-py/harborclient/__init__.py
Normal file
0
contrib/sdk/harbor-py/harborclient/__init__.py
Normal file
371
contrib/sdk/harbor-py/harborclient/harborclient.py
Executable file
371
contrib/sdk/harbor-py/harborclient/harborclient.py
Executable file
@ -0,0 +1,371 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import requests
|
||||||
|
import simplejson
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
|
||||||
|
class HarborClient(object):
|
||||||
|
def __init__(self, host, user, password, protocol="http"):
|
||||||
|
self.host = host
|
||||||
|
self.user = user
|
||||||
|
self.password = password
|
||||||
|
self.protocol = protocol
|
||||||
|
|
||||||
|
self.session_id = self.login()
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
self.logout()
|
||||||
|
|
||||||
|
def login(self):
|
||||||
|
login_data = requests.post('%s://%s/login' %
|
||||||
|
(self.protocol, self.host),
|
||||||
|
data={'principal': self.user,
|
||||||
|
'password': self.password})
|
||||||
|
if login_data.status_code == 200:
|
||||||
|
session_id = login_data.cookies.get('beegosessionID')
|
||||||
|
|
||||||
|
logging.debug("Successfully login, session id: {}".format(
|
||||||
|
session_id))
|
||||||
|
return session_id
|
||||||
|
else:
|
||||||
|
logging.error("Fail to login, please try again")
|
||||||
|
return None
|
||||||
|
|
||||||
|
def logout(self):
|
||||||
|
requests.get('%s://%s/logout' % (self.protocol, self.host),
|
||||||
|
cookies={'beegosessionID': self.session_id})
|
||||||
|
logging.debug("Successfully logout")
|
||||||
|
|
||||||
|
# Get project id
|
||||||
|
def get_project_id_from_name(self, project_name):
|
||||||
|
registry_data = requests.get(
|
||||||
|
'%s://%s/api/projects?project_name=%s' %
|
||||||
|
(self.protocol, self.host, project_name),
|
||||||
|
cookies={'beegosessionID': self.session_id})
|
||||||
|
if registry_data.status_code == 200 and registry_data.json():
|
||||||
|
project_id = registry_data.json()[0]['project_id']
|
||||||
|
logging.debug(
|
||||||
|
"Successfully get project id: {}, project name: {}".format(
|
||||||
|
project_id, project_name))
|
||||||
|
return project_id
|
||||||
|
else:
|
||||||
|
pritn("Fail to get project id from project name", project_name)
|
||||||
|
return None
|
||||||
|
|
||||||
|
# GET /search
|
||||||
|
def search(self, query_string):
|
||||||
|
result = None
|
||||||
|
path = '%s://%s/api/search?q=%s' % (self.protocol, self.host,
|
||||||
|
query_string)
|
||||||
|
response = requests.get(path,
|
||||||
|
cookies={'beegosessionID': self.session_id})
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = response.json()
|
||||||
|
logging.debug("Successfully get search result: {}".format(result))
|
||||||
|
else:
|
||||||
|
logging.error("Fail to get search result")
|
||||||
|
return result
|
||||||
|
|
||||||
|
# GET /projects
|
||||||
|
def get_projects(self, project_name=None, is_public=None):
|
||||||
|
# TODO: support parameter
|
||||||
|
result = None
|
||||||
|
path = '%s://%s/api/projects' % (self.protocol, self.host)
|
||||||
|
response = requests.get(path,
|
||||||
|
cookies={'beegosessionID': self.session_id})
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = response.json()
|
||||||
|
logging.debug("Successfully get projects result: {}".format(
|
||||||
|
result))
|
||||||
|
else:
|
||||||
|
logging.error("Fail to get projects result")
|
||||||
|
return result
|
||||||
|
|
||||||
|
# HEAD /projects
|
||||||
|
def check_project_exist(self, project_name):
|
||||||
|
result = False
|
||||||
|
path = '%s://%s/api/projects?project_name=%s' % (
|
||||||
|
self.protocol, self.host, project_name)
|
||||||
|
response = requests.head(path,
|
||||||
|
cookies={'beegosessionID': self.session_id})
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = True
|
||||||
|
logging.debug(
|
||||||
|
"Successfully check project exist, result: {}".format(result))
|
||||||
|
elif response.status_code == 404:
|
||||||
|
result = False
|
||||||
|
logging.debug(
|
||||||
|
"Successfully check project exist, result: {}".format(result))
|
||||||
|
else:
|
||||||
|
logging.error("Fail to check project exist")
|
||||||
|
return result
|
||||||
|
|
||||||
|
# POST /projects
|
||||||
|
def create_project(self, project_name, is_public=False):
|
||||||
|
result = False
|
||||||
|
path = '%s://%s/api/projects' % (self.protocol, self.host)
|
||||||
|
request_body = simplejson.dumps({'project_name': project_name,
|
||||||
|
'public': is_public})
|
||||||
|
response = requests.post(path,
|
||||||
|
cookies={'beegosessionID': self.session_id},
|
||||||
|
data=request_body)
|
||||||
|
if response.status_code == 201 or response.status_code == 500:
|
||||||
|
# TODO: the response return 500 sometimes
|
||||||
|
result = True
|
||||||
|
logging.debug(
|
||||||
|
"Successfully create project with project name: {}".format(
|
||||||
|
project_name))
|
||||||
|
else:
|
||||||
|
logging.error(
|
||||||
|
"Fail to create project with project name: {}, response code: {}".format(
|
||||||
|
project_name, response.status_code))
|
||||||
|
return result
|
||||||
|
|
||||||
|
# PUT /projects/{project_id}/publicity
|
||||||
|
def set_project_publicity(self, project_id, is_public):
|
||||||
|
result = False
|
||||||
|
path = '%s://%s/api/projects/%s/publicity?project_id=%s' % (
|
||||||
|
self.protocol, self.host, project_id, project_id)
|
||||||
|
request_body = simplejson.dumps({'public': is_public})
|
||||||
|
response = requests.put(path,
|
||||||
|
cookies={'beegosessionID': self.session_id},
|
||||||
|
data=request_body)
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = True
|
||||||
|
logging.debug(
|
||||||
|
"Success to set project id: {} with publicity: {}".format(
|
||||||
|
project_id, is_public))
|
||||||
|
else:
|
||||||
|
logging.error(
|
||||||
|
"Fail to set publicity to project id: {} with status code: {}".format(
|
||||||
|
project_id, response.status_code))
|
||||||
|
return result
|
||||||
|
|
||||||
|
# GET /statistics
|
||||||
|
def get_statistics(self):
|
||||||
|
result = None
|
||||||
|
path = '%s://%s/api/statistics' % (self.protocol, self.host)
|
||||||
|
response = requests.get(path,
|
||||||
|
cookies={'beegosessionID': self.session_id})
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = response.json()
|
||||||
|
logging.debug("Successfully get statistics: {}".format(result))
|
||||||
|
else:
|
||||||
|
logging.error("Fail to get statistics result")
|
||||||
|
return result
|
||||||
|
|
||||||
|
# GET /users
|
||||||
|
def get_users(self, user_name=None):
|
||||||
|
# TODO: support parameter
|
||||||
|
result = None
|
||||||
|
path = '%s://%s/api/users' % (self.protocol, self.host)
|
||||||
|
response = requests.get(path,
|
||||||
|
cookies={'beegosessionID': self.session_id})
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = response.json()
|
||||||
|
logging.debug("Successfully get users result: {}".format(result))
|
||||||
|
else:
|
||||||
|
logging.error("Fail to get users result")
|
||||||
|
return result
|
||||||
|
|
||||||
|
# POST /users
|
||||||
|
def create_user(self, username, email, password, realname, comment):
|
||||||
|
result = False
|
||||||
|
path = '%s://%s/api/users' % (self.protocol, self.host)
|
||||||
|
request_body = simplejson.dumps({'username': username,
|
||||||
|
'email': email,
|
||||||
|
'password': password,
|
||||||
|
'realname': realname,
|
||||||
|
'comment': comment})
|
||||||
|
response = requests.post(path,
|
||||||
|
cookies={'beegosessionID': self.session_id},
|
||||||
|
data=request_body)
|
||||||
|
if response.status_code == 201:
|
||||||
|
result = True
|
||||||
|
logging.debug("Successfully create user with username: {}".format(
|
||||||
|
username))
|
||||||
|
else:
|
||||||
|
logging.error(
|
||||||
|
"Fail to create user with username: {}, response code: {}".format(
|
||||||
|
username, response.status_code))
|
||||||
|
return result
|
||||||
|
|
||||||
|
# PUT /users/{user_id}
|
||||||
|
def update_user_profile(self, user_id, email, realname, comment):
|
||||||
|
# TODO: support not passing comment
|
||||||
|
result = False
|
||||||
|
path = '%s://%s/api/users/%s?user_id=%s' % (self.protocol, self.host,
|
||||||
|
user_id, user_id)
|
||||||
|
request_body = simplejson.dumps({'email': email,
|
||||||
|
'realname': realname,
|
||||||
|
'comment': comment})
|
||||||
|
response = requests.put(path,
|
||||||
|
cookies={'beegosessionID': self.session_id},
|
||||||
|
data=request_body)
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = True
|
||||||
|
logging.debug(
|
||||||
|
"Successfully update user profile with user id: {}".format(
|
||||||
|
user_id))
|
||||||
|
else:
|
||||||
|
logging.error(
|
||||||
|
"Fail to update user profile with user id: {}, response code: {}".format(
|
||||||
|
user_id, response.status_code))
|
||||||
|
return result
|
||||||
|
|
||||||
|
# DELETE /users/{user_id}
|
||||||
|
def delete_user(self, user_id):
|
||||||
|
result = False
|
||||||
|
path = '%s://%s/api/users/%s?user_id=%s' % (self.protocol, self.host,
|
||||||
|
user_id, user_id)
|
||||||
|
response = requests.delete(path,
|
||||||
|
cookies={'beegosessionID': self.session_id})
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = True
|
||||||
|
logging.debug("Successfully delete user with id: {}".format(
|
||||||
|
user_id))
|
||||||
|
else:
|
||||||
|
logging.error("Fail to delete user with id: {}".format(user_id))
|
||||||
|
return result
|
||||||
|
|
||||||
|
# PUT /users/{user_id}/password
|
||||||
|
def change_password(self, user_id, old_password, new_password):
|
||||||
|
result = False
|
||||||
|
path = '%s://%s/api/users/%s/password?user_id=%s' % (
|
||||||
|
self.protocol, self.host, user_id, user_id)
|
||||||
|
request_body = simplejson.dumps({'old_password': old_password,
|
||||||
|
'new_password': new_password})
|
||||||
|
response = requests.put(path,
|
||||||
|
cookies={'beegosessionID': self.session_id},
|
||||||
|
data=request_body)
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = True
|
||||||
|
logging.debug(
|
||||||
|
"Successfully change password for user id: {}".format(user_id))
|
||||||
|
else:
|
||||||
|
logging.error("Fail to change password for user id: {}".format(
|
||||||
|
user_id))
|
||||||
|
return result
|
||||||
|
|
||||||
|
# PUT /users/{user_id}/sysadmin
|
||||||
|
def promote_as_admin(self, user_id):
|
||||||
|
# TODO: always return 404, need more test
|
||||||
|
result = False
|
||||||
|
path = '%s://%s/api/users/%s/sysadmin?user_id=%s' % (
|
||||||
|
self.protocol, self.host, user_id, user_id)
|
||||||
|
response = requests.put(path,
|
||||||
|
cookies={'beegosessionID': self.session_id})
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = True
|
||||||
|
logging.debug(
|
||||||
|
"Successfully promote user as admin with user id: {}".format(
|
||||||
|
user_id))
|
||||||
|
else:
|
||||||
|
logging.error(
|
||||||
|
"Fail to promote user as admin with user id: {}, response code: {}".format(
|
||||||
|
user_id, response.status_code))
|
||||||
|
return result
|
||||||
|
|
||||||
|
# GET /repositories
|
||||||
|
def get_repositories(self, project_id, query_string=None):
|
||||||
|
# TODO: support parameter
|
||||||
|
result = None
|
||||||
|
path = '%s://%s/api/repositories?project_id=%s' % (
|
||||||
|
self.protocol, self.host, project_id)
|
||||||
|
response = requests.get(path,
|
||||||
|
cookies={'beegosessionID': self.session_id})
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = response.json()
|
||||||
|
logging.debug(
|
||||||
|
"Successfully get repositories with id: {}, result: {}".format(
|
||||||
|
project_id, result))
|
||||||
|
else:
|
||||||
|
logging.error("Fail to get repositories result with id: {}".format(
|
||||||
|
project_id))
|
||||||
|
return result
|
||||||
|
|
||||||
|
# DELETE /repositories
|
||||||
|
def delete_repository(self, repo_name, tag=None):
|
||||||
|
# TODO: support to check tag
|
||||||
|
# TODO: return 200 but the repo is not deleted, need more test
|
||||||
|
result = False
|
||||||
|
path = '%s://%s/api/repositories?repo_name=%s' % (self.protocol,
|
||||||
|
self.host, repo_name)
|
||||||
|
response = requests.delete(path,
|
||||||
|
cookies={'beegosessionID': self.session_id})
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = True
|
||||||
|
logging.debug("Successfully delete repository: {}".format(
|
||||||
|
repo_name))
|
||||||
|
else:
|
||||||
|
logging.error("Fail to delete repository: {}".format(repo_name))
|
||||||
|
return result
|
||||||
|
|
||||||
|
# Get /repositories/tags
|
||||||
|
def get_repository_tags(self, repo_name):
|
||||||
|
result = None
|
||||||
|
path = '%s://%s/api/repositories/tags?repo_name=%s' % (
|
||||||
|
self.protocol, self.host, repo_name)
|
||||||
|
response = requests.get(path,
|
||||||
|
cookies={'beegosessionID': self.session_id})
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = response.json()
|
||||||
|
logging.debug(
|
||||||
|
"Successfully get tag with repo name: {}, result: {}".format(
|
||||||
|
repo_name, result))
|
||||||
|
else:
|
||||||
|
logging.error("Fail to get tags with repo name: {}".format(
|
||||||
|
repo_name))
|
||||||
|
return result
|
||||||
|
|
||||||
|
# GET /repositories/manifests
|
||||||
|
def get_repository_manifests(self, repo_name, tag):
|
||||||
|
result = None
|
||||||
|
path = '%s://%s/api/repositories/manifests?repo_name=%s&tag=%s' % (
|
||||||
|
self.protocol, self.host, repo_name, tag)
|
||||||
|
response = requests.get(path,
|
||||||
|
cookies={'beegosessionID': self.session_id})
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = response.json()
|
||||||
|
logging.debug(
|
||||||
|
"Successfully get manifests with repo name: {}, tag: {}, result: {}".format(
|
||||||
|
repo_name, tag, result))
|
||||||
|
else:
|
||||||
|
logging.error(
|
||||||
|
"Fail to get manifests with repo name: {}, tag: {}".format(
|
||||||
|
repo_name, tag))
|
||||||
|
return result
|
||||||
|
|
||||||
|
# GET /repositories/top
|
||||||
|
def get_top_accessed_repositories(self, count=None):
|
||||||
|
result = None
|
||||||
|
path = '%s://%s/api/repositories/top' % (self.protocol, self.host)
|
||||||
|
if count:
|
||||||
|
path += "?count=%s" % (count)
|
||||||
|
response = requests.get(path,
|
||||||
|
cookies={'beegosessionID': self.session_id})
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = response.json()
|
||||||
|
logging.debug(
|
||||||
|
"Successfully get top accessed repositories, result: {}".format(
|
||||||
|
result))
|
||||||
|
else:
|
||||||
|
logging.error("Fail to get top accessed repositories")
|
||||||
|
return result
|
||||||
|
|
||||||
|
# GET /logs
|
||||||
|
def get_logs(self, lines=None, start_time=None, end_time=None):
|
||||||
|
result = None
|
||||||
|
path = '%s://%s/api/logs' % (self.protocol, self.host)
|
||||||
|
response = requests.get(path,
|
||||||
|
cookies={'beegosessionID': self.session_id})
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = response.json()
|
||||||
|
logging.debug("Successfully get logs")
|
||||||
|
else:
|
||||||
|
logging.error("Fail to get logs and response code: {}".format(
|
||||||
|
response.status_code))
|
||||||
|
return result
|
3
contrib/sdk/harbor-py/harborclient/test_harborclient.py
Normal file
3
contrib/sdk/harbor-py/harborclient/test_harborclient.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import harborclient
|
1
contrib/sdk/harbor-py/requirements.txt
Normal file
1
contrib/sdk/harbor-py/requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
requests>2.2.0
|
103
contrib/sdk/harbor-py/setup.py
Normal file
103
contrib/sdk/harbor-py/setup.py
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
""" The missing harbor python SDK
|
||||||
|
|
||||||
|
See: https://github.com/tobegit3hub/harbor-py
|
||||||
|
"""
|
||||||
|
|
||||||
|
from setuptools import setup, find_packages
|
||||||
|
from codecs import open
|
||||||
|
from os import path
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='harbor-py',
|
||||||
|
|
||||||
|
# Versions should comply with PEP440. For a discussion on single-sourcing
|
||||||
|
# the version across setup.py and the project code, see
|
||||||
|
# https://packaging.python.org/en/latest/single_source_version.html
|
||||||
|
version='1.2.0',
|
||||||
|
description='The missing harbor python SDK',
|
||||||
|
|
||||||
|
# The project's main homepage.
|
||||||
|
url='https://github.com/tobegit3hub/harbor-py',
|
||||||
|
|
||||||
|
# Author details
|
||||||
|
author='tobe',
|
||||||
|
author_email='tobeg3oogle@gmail.com',
|
||||||
|
|
||||||
|
# Choose your license
|
||||||
|
license='Apache Software',
|
||||||
|
|
||||||
|
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||||
|
classifiers=[
|
||||||
|
# How mature is this project? Common values are
|
||||||
|
# 3 - Alpha
|
||||||
|
# 4 - Beta
|
||||||
|
# 5 - Production/Stable
|
||||||
|
'Development Status :: 3 - Alpha',
|
||||||
|
|
||||||
|
# Indicate who your project is intended for
|
||||||
|
'Intended Audience :: Developers',
|
||||||
|
'Topic :: Software Development :: Build Tools',
|
||||||
|
|
||||||
|
# Pick your license as you wish (should match "license" above)
|
||||||
|
'License :: OSI Approved :: Apache Software License',
|
||||||
|
|
||||||
|
# Specify the Python versions you support here. In particular, ensure
|
||||||
|
# that you indicate whether you support Python 2, Python 3 or both.
|
||||||
|
'Programming Language :: Python :: 2',
|
||||||
|
'Programming Language :: Python :: 2.6',
|
||||||
|
'Programming Language :: Python :: 2.7',
|
||||||
|
'Programming Language :: Python :: 3',
|
||||||
|
'Programming Language :: Python :: 3.3',
|
||||||
|
'Programming Language :: Python :: 3.4',
|
||||||
|
'Programming Language :: Python :: 3.5',
|
||||||
|
],
|
||||||
|
|
||||||
|
# What does your project relate to?
|
||||||
|
keywords='docker registry distribution harbor python sdk',
|
||||||
|
|
||||||
|
# You can just specify the packages manually here if your project is
|
||||||
|
# simple. Or you can use find_packages().
|
||||||
|
#packages=find_packages(exclude=['contrib', 'docs', 'tests']),
|
||||||
|
packages=['harborclient'],
|
||||||
|
|
||||||
|
# Alternatively, if you want to distribute just a my_module.py, uncomment
|
||||||
|
# this:
|
||||||
|
# py_modules=["my_module"],
|
||||||
|
|
||||||
|
# List run-time dependencies here. These will be installed by pip when
|
||||||
|
# your project is installed. For an analysis of "install_requires" vs pip's
|
||||||
|
# requirements files see:
|
||||||
|
# https://packaging.python.org/en/latest/requirements.html
|
||||||
|
#install_requires=['peppercorn'],
|
||||||
|
|
||||||
|
# List additional groups of dependencies here (e.g. development
|
||||||
|
# dependencies). You can install these using the following syntax,
|
||||||
|
# for example:
|
||||||
|
# $ pip install -e .[dev,test]
|
||||||
|
#extras_require={
|
||||||
|
# 'dev': ['check-manifest'],
|
||||||
|
# 'test': ['coverage'],
|
||||||
|
#},
|
||||||
|
|
||||||
|
# If there are data files included in your packages that need to be
|
||||||
|
# installed, specify them here. If using Python 2.6 or less, then these
|
||||||
|
# have to be included in MANIFEST.in as well.
|
||||||
|
#package_data={
|
||||||
|
# 'sample': ['package_data.dat'],
|
||||||
|
#},
|
||||||
|
|
||||||
|
# Although 'package_data' is the preferred approach, in some case you may
|
||||||
|
# need to place data files outside of your packages. See:
|
||||||
|
# http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files # noqa
|
||||||
|
# In this case, 'data_file' will be installed into '<sys.prefix>/my_data'
|
||||||
|
#data_files=[('my_data', ['data/data_file'])],
|
||||||
|
|
||||||
|
# To provide executable scripts, use entry points in preference to the
|
||||||
|
# "scripts" keyword. Entry points provide cross-platform support and allow
|
||||||
|
# pip to create the appropriate form of executable for the target platform.
|
||||||
|
#entry_points={
|
||||||
|
# 'console_scripts': [
|
||||||
|
# 'harbor=harborclient:main',
|
||||||
|
# ],
|
||||||
|
#},
|
||||||
|
)
|
7
contrib/sdk/harbor-py/uninstall.sh
Executable file
7
contrib/sdk/harbor-py/uninstall.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -x
|
||||||
|
set -e
|
||||||
|
|
||||||
|
python setup.py install --record files.txt
|
||||||
|
cat files.txt | xargs rm -rf
|
Loading…
Reference in New Issue
Block a user