def get_image_manifest_oauth2(url, registry, repo, tag, user=None, pw=None, verify=True): manifest = {} digest = "" try: drc = docker_registry_client.DockerRegistryClient(url, username=user, password=pw, verify_ssl=verify, api_version=2) r = drc.repository(namespace=None, repository=repo) manifest, digest = r.manifest(tag, accept_version=2) if manifest['schemaVersion'] == 1: raise Exception( "cannot infer digest from response with manifest schemaVersion 1" ) except Exception as err: raise err return (manifest, digest)
def ping_docker_registry(registry_record): ret = False user = '' url = '' try: registry = registry_record['registry'] verify = registry_record['registry_verify'] url = "https://" + registry user, pw = anchore_engine.auth.common.get_docker_registry_userpw( registry_record) drc = docker_registry_client.DockerRegistryClient(url, username=user, password=pw, verify_ssl=verify) logger.debug("registry access check success (" + str(url) + "," + str(user) + ")") ret = True except Exception as err: logger.warn("failed check to access registry (" + str(url) + "," + str(user) + ") - exception: " + str(err)) raise Exception("failed check to access registry (" + str(url) + "," + str(user) + ") - exception: " + str(err)) #ret = False return (ret)