INNER CODE UNIT · Python

ensure_tokens_present

pluralsh/plural · bin/list_images.py:83

async def ensure_tokens_present(dkr_client, path):
    key = None
    for pattern in dkr_client.tokens:
        if pattern.fullmatch("dkr.plural.sh"):
            key = pattern
            break
    if key is None:
        key = await DockerRegistryClientAsync._get_endpoint_pattern(
            endpoint="dkr.plural.sh"
        )
    scope = f"repository:{path}:pull"
    if scope in dkr_client.tokens.get(key, {}):
        return
    async with aiohttp.ClientSession() as session:
        plrl_token = get_token()
        async with session.post(f"https://app.plural.sh/auth/token?scope={scope}&password={plrl_token}") as response:
            resp = await response.text()
            resp = json.loads(resp)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…