Skip to content

Commit dbf9881

Browse files
committed
provider: add argument to pass a subject
Signed-off-by: Tiziano Müller <[email protected]>
1 parent ea92ae1 commit dbf9881

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

oras/provider.py

+14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import copy
66
import os
77
import urllib
8+
from dataclasses import asdict, dataclass
89
from http.cookiejar import DefaultCookiePolicy
910
from typing import Callable, List, Optional, Tuple, Union
1011

@@ -23,6 +24,13 @@
2324
container_type = Union[str, oras.container.Container]
2425

2526

27+
@dataclass
28+
class Subject:
29+
mediaType: str
30+
digest: str
31+
size: int
32+
33+
2634
class Registry:
2735
"""
2836
Direct interactions with an OCI registry.
@@ -626,6 +634,8 @@ def push(self, *args, **kwargs) -> requests.Response:
626634
:type manifest_annotations: dict
627635
:param target: target location to push to
628636
:type target: str
637+
:param subject: optional subject reference
638+
:type subject: Subject
629639
"""
630640
container = self.get_container(kwargs["target"])
631641
self.load_configs(container, configs=kwargs.get("config_path"))
@@ -700,6 +710,10 @@ def push(self, *args, **kwargs) -> requests.Response:
700710
if manifest_annots:
701711
manifest["annotations"] = manifest_annots
702712

713+
subject = kwargs.get("subject")
714+
if subject:
715+
manifest["subject"] = asdict(subject)
716+
703717
# Prepare the manifest config (temporary or one provided)
704718
manifest_config = kwargs.get("manifest_config")
705719
config_annots = annotset.get_annotations("$config")

0 commit comments

Comments
 (0)