]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: normalize_image_digest: comment to tests
authorSebastian Wagner <sewagner@redhat.com>
Tue, 14 Dec 2021 11:32:05 +0000 (12:32 +0100)
committerAdam King <adking@redhat.com>
Mon, 21 Feb 2022 18:43:45 +0000 (13:43 -0500)
`pytest --doctest` ftw. Be aware those tests actually fail, as the
implementation contradicts the function documentation.

Signed-off-by: Sebastian Wagner <sewagner@redhat.com>
(cherry picked from commit dc19e3a867b015d8f4c6f5128603d71be3ce5b0d)

src/pybind/mgr/cephadm/upgrade.py

index d11960ba9dba47325a37a2511cb49213335159b4..6061eddd470faaa280f6f09ae32ecbd81cad0ff0 100644 (file)
@@ -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