def delete_package_release(organization, repo, version=None): """ Delete particular version of released package from quay.io :param organization: quay.io organization :param repo: target repository :param version: version of operator manifest :return: HTTP response """ cnr_token = extract_auth_token(request) quay_org = ORG_MANAGER.get_org(organization, cnr_token) # quay.io may contain OMPS incompatible release version format string # but we want to be able to delete everything there, thus using _raw # method if version is None: versions = quay_org.get_releases_raw(repo) else: versions = [version] for ver in versions: quay_org.delete_release(repo, ver) data = { 'organization': organization, 'repo': repo, 'deleted': versions, } resp = jsonify(data) resp.status_code = requests.codes.ok return resp
def _zip_flow(*, organization, repo, version, extract_manifest_func, extras_data=None): """ :param str organization: quay.io organization :param str|None repo: target repository (if not specified, will be taken from manifest data) :param str|None version: version of operator manifest :param Callable[str, int] extract_manifest_func: function to retrieve operator manifests zip file. First argument of function is path to target dir where zip archive content will be extracted, second argument max size of extracted files :param extras_data: extra data added to response :return: JSON response """ cnr_token = extract_auth_token(request) quay_org = ORG_MANAGER.get_org(organization, cnr_token) data = {} with TemporaryDirectory() as tmpdir: max_size = current_app.config['ZIPFILE_MAX_UNCOMPRESSED_SIZE'] extract_manifest_func(tmpdir, max_uncompressed_size=max_size) extracted_files = _dir_files(tmpdir) logger.info("Extracted files: %s", extracted_files) data['extracted_files'] = extracted_files with TemporaryDirectory() as tmpdir_flatten: # operator-courier supports only flat dir structure _flatten_manifest_structure(tmpdir, tmpdir_flatten) if repo is None: repo = _get_reponame_from_manifests(tmpdir_flatten) version = get_package_version(quay_org, repo, version) logger.info("Using release version: %s", version) replace_registries(quay_org, tmpdir_flatten) quay_org.push_operator_manifest(repo, version, tmpdir_flatten) data.update({ 'organization': organization, 'repo': repo, 'version': version, }) if extras_data: data.update(extras_data) resp = jsonify(data) resp.status_code = 200 return resp