From: Sebastian Wagner Date: Tue, 14 Dec 2021 11:32:05 +0000 (+0100) Subject: mgr/cephadm: normalize_image_digest: comment to tests X-Git-Tag: v16.2.8~161^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9771daa9dd8c77d185f6fce7c55cf2bc407d34af;p=ceph.git mgr/cephadm: normalize_image_digest: comment to tests `pytest --doctest` ftw. Be aware those tests actually fail, as the implementation contradicts the function documentation. Signed-off-by: Sebastian Wagner (cherry picked from commit dc19e3a867b015d8f4c6f5128603d71be3ce5b0d) --- diff --git a/src/pybind/mgr/cephadm/upgrade.py b/src/pybind/mgr/cephadm/upgrade.py index d11960ba9dba..6061eddd470f 100644 --- a/src/pybind/mgr/cephadm/upgrade.py +++ b/src/pybind/mgr/cephadm/upgrade.py @@ -22,13 +22,22 @@ CEPH_MDSMAP_ALLOW_STANDBY_REPLAY = (1 << 5) def normalize_image_digest(digest: str, default_registry: str) -> str: - # normal case: - # ceph/ceph -> docker.io/ceph/ceph - # edge cases that shouldn't ever come up: - # ubuntu -> docker.io/ubuntu (ubuntu alias for library/ubuntu) - # no change: - # quay.ceph.io/ceph/ceph -> ceph - # docker.io/ubuntu -> no change + """ + Normal case: + >>> normalize_image_digest('ceph/ceph', 'docker.io') + 'docker.io/ceph/ceph' + + Edge cases that shouldn't ever come up. (ubuntu alias for library/ubuntu) + >>> normalize_image_digest('ubuntu', 'docker.io') + 'docker.io/ubuntu' + + No change: + >>> normalize_image_digest('quay.ceph.io/ceph/ceph', 'docker.io') + 'quay.ceph.io/ceph/ceph' + + >>> normalize_image_digest('docker.io/ubuntu', 'docker.io') + 'docker.io/ubuntu' + """ bits = digest.split('/') if '.' not in bits[0] or len(bits) < 3: digest = 'docker.io/' + digest