Skip to content

Commit

Permalink
skip 2xx check on Oras-py Registry.push response
Browse files Browse the repository at this point in the history
Signed-off-by: Isabella do Amaral <[email protected]>
  • Loading branch information
isinyaaa committed Oct 28, 2024
1 parent bb445ec commit a8ee5e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 3 additions & 1 deletion omlmd/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ def push(
manifest_config=manifest_cfg,
do_chunked=True,
)
self.notify_listeners(PushEvent(result, target, model_metadata))
self.notify_listeners(
PushEvent.from_response(result, target, model_metadata)
)
return result
finally:
if owns_meta_files:
Expand Down
13 changes: 6 additions & 7 deletions omlmd/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ class Event(ABC):

@dataclass
class PushEvent(Event):
response: requests.Response
digest: str
target: str
metadata: ModelMetadata

@property
def ok(self) -> bool:
return self.response.status_code == 200

def get_digest(self) -> str:
return self.response.headers["Docker-Content-Digest"] if self.ok else ""
@classmethod
def from_response(
cls, response: requests.Response, target: str, metadata: ModelMetadata
) -> t.Self:
return cls(response.headers["Docker-Content-Digest"], target, metadata)

0 comments on commit a8ee5e2

Please sign in to comment.