]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: move normalize_conatiner_id function to container_engines.py
authorJohn Mulligan <jmulligan@redhat.com>
Fri, 7 Feb 2025 16:29:40 +0000 (11:29 -0500)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 11 Feb 2025 21:08:05 +0000 (16:08 -0500)
The container_engines.py is the current home of functions related to
generic container engine (podman & docker) stuff. The
normalize_conatiner_id is a function from stripping the hash type prefix
from digests and thus easily fits that description.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadm.py
src/cephadm/cephadmlib/container_engines.py

index 4529ade7e33375d082f8b7f9f16d75cab377ce80..86b8deca24d2ccb87b7f97df5154d92165603740 100755 (executable)
@@ -89,6 +89,7 @@ from cephadmlib.container_engines import (
     Podman,
     check_container_engine,
     find_container_engine,
+    normalize_container_id,
     parsed_container_cpu_perc,
     parsed_container_image_stats,
     parsed_container_mem_usage,
@@ -275,18 +276,6 @@ def generate_password():
                    for i in range(10))
 
 
-def normalize_container_id(i):
-    # type: (str) -> str
-    # docker adds the sha256: prefix, but AFAICS both
-    # docker (18.09.7 in bionic at least) and podman
-    # both always use sha256, so leave off the prefix
-    # for consistency.
-    prefix = 'sha256:'
-    if i.startswith(prefix):
-        i = i[len(prefix):]
-    return i
-
-
 def make_fsid():
     # type: () -> str
     return str(uuid.uuid1())
index 9b308fdd4174eb7577ca4526531c4618425b2ed3..1e17c337980924114983fa33253e6b28e3c7b072 100644 (file)
@@ -415,3 +415,18 @@ def parsed_container_image_stats(
         ctx, image_name, container_path=container_path
     )
     return _parse_container_image_stats(image_name, out, err, code)
+
+
+def normalize_container_id(i: str) -> str:
+    # docker adds the sha256: prefix, but AFAICS both
+    # docker (18.09.7 in bionic at least) and podman
+    # both always use sha256, so leave off the prefix
+    # for consistency.
+    # ---
+    # (JJM) This is not a good idea and cephadm should move away from stripping
+    # the hash-type prefix. This is there so that docker/OCI can eventually
+    # move hash types if need be. Removing it breaks hash agility!
+    prefix = 'sha256:'
+    if i.startswith(prefix):
+        i = i[len(prefix) :]
+    return i