一个基于AIOHTTP的Python REST客户端,用于Docker注册表。
docker-registry-client-async的Python项目详细描述
docker注册表客户端异步
概述
一个基于AIOHTTP的pythonrest客户端,用于Docker注册表。在
入门
importasyncioimportjsonfromdocker_registry_client_asyncimportDockerRegistryClientAsync,FormattedSHA256,ImageName,Manifestasyncdefget_config(drca:DockerRegistryClientAsync,image_name:ImageName,manifest:Manifest)->bytes:config_digest=FormattedSHA256.parse(manifest.get_json()["config"]["digest"])result=awaitdrca.get_blob(image_name,config_digest)returnjson.loads(result["blob"].decode("utf-8"))asyncdefget_manifest(drca:DockerRegistryClientAsync,image_name:ImageName)->Manifest:result=awaitdrca.get_manifest(image_name)returnresult["manifest"]asyncdefmain():image_name=ImageName.parse("busybox:1.30.1")asyncwithDockerRegistryClientAsync()asdrca:manifest=awaitget_manifest(drca,image_name)config=awaitget_config(drca,image_name,manifest)print(config)if__name__=="__main__":loop=asyncio.get_event_loop()loop.run_until_complete(main())
兼容性
- 用python3.8测试
安装
从pypi.org
^{pr2}$源代码
$ git clone https://github.com/crashvb/docker-registry-client-async $ cd docker-registry-client-async $ virtualenv env $ source env/bin/activate $ python -m pip install --editable .[dev]
环境变量
Variable | Default Value | Description |
---|---|---|
DRCA_CACERTS | The path to the certificate trust store. | |
DRCA_CHUNK_SIZE | 2097152 | The chunk size to use then replicating content. |
DRCA_CREDENTIALS_STORE | ~/.docker/config.json | The credentials store from which to retrieve registry credentials. |
DRCA_DEFAULT_REGISTRY | index.docker.io | The default registry index to use when resolving image names. |
DRCA_DEFAULT_NAMESPACE | library | The default registry namespace to use when resolving image names. |
DRCA_DEFAULT_TAG | latest | The default image tag to use when resolving image names. |
DRCA_PROTOCOL | https | The default transport protocol to when communicating with a registry. |
DRCA_TOKEN_BASED_ENDPOINTS | index.docker.io,quay.io,registry.redhat.io | Endpoints for which to retrieve authentication tokens. |
发展
- 项目
标签: