这是一个用于查询gitlab注册表中存储库大小的包。
gitlab-registry-usage的Python项目详细描述
简介
gitlab registry usage是用于查询docker大小的包 存储在gitlab注册表中的存储库。包已创建 因为无法监视gitlab注册表的大小 带有Gitlab Web监视工具(Gitlab版本<;)的存储库= 10.5.4条)。
安装
PYPI提供最新版本:
pip install gitlab-registry-usage
用法
命令行界面
使用pip安装后,gitlab-registry-usage命令是 可用:
$ gitlab-registry-usage --help usage: gitlab-registry-usage [-h][-g GITLAB_SERVER][-r REGISTRY_SERVER][-s {name,size,disksize}][-c CREDENTIALS_FILE][-u USERNAME][-V] gitlab-registry-usage is a utility for querying the memory usage of repositories in a GitLab registry. optional arguments: -h, --help show this help message and exit -g GITLAB_SERVER, --gitlab-server GITLAB_SERVER GitLab server hostname (for example `mygitlab.com`) -r REGISTRY_SERVER, --registry-server REGISTRY_SERVER GitLab registry server hostname (for example `registry.mygitlab.com`) -s {name,size,disksize}, --sort {name,size,disksize} sorting order (default: name) -c CREDENTIALS_FILE, --credentials-file CREDENTIALS_FILE path to a file containing username and password/access token (on two separate lines) -u USERNAME, --user USERNAME user account for querying the GitLab API (default: root) -V, --version print the version number and exit
您应该指定gitlab服务器主机名(-g),gitlab注册表 服务器主机名(-r)和凭据文件(-c)或 用户名(-u)和密码(从stdin读取)。
api
模块提供一个高级GitLabRegistry类来查询 存储库目录和存储库大小。此示例打印所有 存储库、标记及其大小:
fromgitlab_registry_usageimportGitLabRegistry# TODO: set these values!gitlab_base_url=''registry_base_url=''username='root'access_token='0000000000'gitlab_registry=GitLabRegistry(gitlab_base_url,registry_base_url,username,access_token)forrepositoryingitlab_registry.repository_tags.keys():repository_tags=gitlab_registry.repository_tags[repository]repository_size=gitlab_registry.repository_sizes[repository]repository_disk_size=gitlab_registry.repository_disk_sizes[repository]tag_sizes=gitlab_registry.tag_sizes[repository]tag_disk_sizes=gitlab_registry.tag_disk_sizes[repository]if(repository_tagsisnotNoneandrepository_sizeisnotNoneandrepository_disk_sizeisnotNoneandtag_sizesisnotNoneandtag_disk_sizesisnotNone):print('{}: repository size: {}, repository disk size: {}'.format(repository,repository_size,repository_disk_size))fortaginrepository_tags:print('{}: tag size: {}, tag disk size: {}'.format(tag,tag_sizes[tag],tag_disk_sizes[tag]))else:print('{}: no further information available'.format(repository))print()print(('total size: {}, total disk size: {}').format(gitlab_registry.total_size,gitlab_registry.total_disk_size))
方法delete_image可用于删除特定图像,如果 相应的sha256散列是已知的。