This repository has been archived by the owner on May 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Push: Get reponame from package name in manifest bundle
OLM Marketplace has requirement that packages must be pushed to repositories with the same name as package name. Incompatible API change was introduced due this request, so now it is part of API v2. `<repo>` part has been dropped from operators push API. Edpoints: * [POST] `/v2/<organization>/zipfile` * [POST] `/v2/<organization>/zipfile/<version>` * [POST] `/v2/<organization>/koji/<nvr>` * [POST] `/v2/<organization>/koji/<nvr>/<version>` * OSBS-7128 Signed-off-by: Martin Bašti <mbasti@redhat.com>
- Loading branch information
1 parent
b302692
commit 6dd1a76
Showing
15 changed files
with
390 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# | ||
# Copyright (C) 2019 Red Hat, Inc | ||
# see the LICENSE file for license | ||
# | ||
|
||
"""Helper classes/functions for operator manifests""" | ||
|
||
import logging | ||
import io | ||
|
||
import yaml | ||
|
||
from operatorcourier.api import build_and_verify | ||
from omps.errors import QuayCourierError | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class ManifestBundle: | ||
"""Provides metadata of operator bundle""" | ||
|
||
@classmethod | ||
def from_dir(cls, source_dir_path): | ||
"""Build bundle from specified directory | ||
:param source_dir_path: path to directory with operator manifest | ||
:rtype: ManifestBundle | ||
:return: object | ||
""" | ||
try: | ||
bundle = build_and_verify(source_dir_path) | ||
except Exception as e: | ||
msg = "Operator courier failed: {}".format(e) | ||
raise QuayCourierError(msg) | ||
return cls(bundle) | ||
|
||
def __init__(self, bundle): | ||
""" | ||
:param bundle: bundle built by operator-courier | ||
""" | ||
self._bundle = bundle | ||
|
||
@property | ||
def bundle(self): | ||
"""Returns operator bundle""" | ||
return self._bundle | ||
|
||
@property | ||
def package_name(self): | ||
"""Returns defined package name from operator bundle""" | ||
# op. courier do verification, this should be never empty | ||
pkgs_yaml = self.bundle['data']['packages'] | ||
pkgs = yaml.safe_load(io.StringIO(pkgs_yaml)) | ||
return pkgs[0]['packageName'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.