Loading behave_utils/docker.py +14 −3 Original line number Diff line number Diff line Loading @@ -190,8 +190,9 @@ class Image: _cache = dict[str, ShaID]() def __init__(self, iid: ShaID): def __init__(self, iid: ShaID, name: str|None = None): self.iid = iid self.name = name @classmethod def build(cls, context: Path, target: str = "", **build_args: str|None) -> Self: Loading Loading @@ -224,7 +225,7 @@ class Image: except KeyError: docker(b"pull", repository) iid = cls._process_image(repository) return cls(iid) return cls(iid, repository) @classmethod def _process_image(cls, reference: str) -> ShaID: Loading @@ -234,6 +235,10 @@ class Image: ((tag, iid) for tag in report.path("$.RepoTags", list[str])), reference=iid, ) cls._cache.update( ((tag, iid) for tag in report.path("$.RepoDigests", list[str])), reference=iid, ) return iid def get_id(self) -> ShaID: Loading @@ -242,6 +247,12 @@ class Image: """ return self.iid def get_ref(self) -> str: """ Return a name or IID reference for an Image """ return self.name or self.iid class Container: """ Loading Loading @@ -365,7 +376,7 @@ class Container: docker_output( b"container", b"create", "--label", "uk.org.kodo.behave-utils", *opts, self.image.iid, *self.cmd, *opts, self.image.get_ref(), *self.cmd, ), ) assert self.cid Loading Loading
behave_utils/docker.py +14 −3 Original line number Diff line number Diff line Loading @@ -190,8 +190,9 @@ class Image: _cache = dict[str, ShaID]() def __init__(self, iid: ShaID): def __init__(self, iid: ShaID, name: str|None = None): self.iid = iid self.name = name @classmethod def build(cls, context: Path, target: str = "", **build_args: str|None) -> Self: Loading Loading @@ -224,7 +225,7 @@ class Image: except KeyError: docker(b"pull", repository) iid = cls._process_image(repository) return cls(iid) return cls(iid, repository) @classmethod def _process_image(cls, reference: str) -> ShaID: Loading @@ -234,6 +235,10 @@ class Image: ((tag, iid) for tag in report.path("$.RepoTags", list[str])), reference=iid, ) cls._cache.update( ((tag, iid) for tag in report.path("$.RepoDigests", list[str])), reference=iid, ) return iid def get_id(self) -> ShaID: Loading @@ -242,6 +247,12 @@ class Image: """ return self.iid def get_ref(self) -> str: """ Return a name or IID reference for an Image """ return self.name or self.iid class Container: """ Loading Loading @@ -365,7 +376,7 @@ class Container: docker_output( b"container", b"create", "--label", "uk.org.kodo.behave-utils", *opts, self.image.iid, *self.cmd, *opts, self.image.get_ref(), *self.cmd, ), ) assert self.cid Loading