From 9771daa9dd8c77d185f6fce7c55cf2bc407d34af Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Tue, 14 Dec 2021 12:32:05 +0100 Subject: [PATCH] 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) --- src/pybind/mgr/cephadm/upgrade.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/pybind/mgr/cephadm/upgrade.py b/src/pybind/mgr/cephadm/upgrade.py index d11960ba9dba4..6061eddd470fa 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 -- 2.39.5