77
88import os
99from datetime import datetime
10- from typing import Any
10+ from typing import Annotated , Any
1111
1212from models_library .basic_types import SHA1Str , VersionStr
1313from models_library .utils .labels_annotations import from_labels , to_labels
@@ -43,62 +43,89 @@ def _underscore_as_dot(field_name: str):
4343class OciImageSpecAnnotations (BaseModel ):
4444 # TODO: review and polish constraints
4545
46- created : datetime = Field (
47- None ,
48- description = "date and time on which the image was built (string, date-time as defined by RFC 3339)" ,
49- )
50-
51- authors : str = Field (
52- None ,
53- description = "contact details of the people or organization responsible for the image (freeform string)" ,
54- )
55-
56- url : AnyUrl = Field (
57- None , description = "URL to find more information on the image (string)"
58- )
59-
60- documentation : AnyUrl = Field (
61- None , description = "URL to get documentation on the image (string)"
62- )
63-
64- source : AnyUrl = Field (
65- None , description = "URL to get source code for building the image (string)"
66- )
67-
68- version : VersionStr = Field (
69- None ,
70- description = "version of the packaged software"
71- "The version MAY match a label or tag in the source code repository"
72- "version MAY be Semantic versioning-compatible" ,
73- )
74- revision : str = Field (
75- None ,
76- description = "Source control revision identifier for the packaged software." ,
77- )
78-
79- vendor : str = Field (
80- None , description = "Name of the distributing entity, organization or individual."
81- )
46+ created : Annotated [
47+ datetime | None ,
48+ Field (
49+ description = "date and time on which the image was built (string, date-time as defined by RFC 3339)" ,
50+ ),
51+ ] = None
52+
53+ authors : Annotated [
54+ str | None ,
55+ Field (
56+ description = "contact details of the people or organization responsible for the image (freeform string)" ,
57+ ),
58+ ] = None
59+
60+ url : Annotated [
61+ AnyUrl | None ,
62+ Field (None , description = "URL to find more information on the image (string)" ),
63+ ] = None
64+
65+ documentation : Annotated [
66+ AnyUrl | None ,
67+ Field (None , description = "URL to get documentation on the image (string)" ),
68+ ] = None
69+
70+ source : Annotated [
71+ AnyUrl | None ,
72+ Field (
73+ None , description = "URL to get source code for building the image (string)"
74+ ),
75+ ] = None
76+
77+ version : Annotated [
78+ VersionStr | None ,
79+ Field (
80+ description = "version of the packaged software"
81+ "The version MAY match a label or tag in the source code repository"
82+ "version MAY be Semantic versioning-compatible" ,
83+ ),
84+ ] = None
85+ revision : Annotated [
86+ str | None ,
87+ Field (
88+ description = "Source control revision identifier for the packaged software." ,
89+ ),
90+ ] = None
91+ vendor : Annotated [
92+ str | None ,
93+ Field (
94+ description = "Name of the distributing entity, organization or individual."
95+ ),
96+ ] = None
8297
8398 # SEE https://spdx.dev/spdx-specification-21-web-version/#h.jxpfx0ykyb60
84- licenses : str = Field (
85- "MIT" ,
86- description = "License(s) under which contained software is distributed as an SPDX License Expression." ,
87- )
88- ref_name : str = Field (
89- None ,
90- description = "Name of the reference for a target (string)." ,
91- )
99+ licenses : Annotated [
100+ str ,
101+ Field (
102+ description = "License(s) under which contained software is distributed as an SPDX License Expression." ,
103+ ),
104+ ] = "MIT"
105+
106+ ref_name : Annotated [
107+ str | None ,
108+ Field (
109+ description = "Name of the reference for a target (string)." ,
110+ ),
111+ ] = None
112+
113+ title : Annotated [
114+ str | None , Field (description = "Human-readable title of the image (string)" )
115+ ] = None
116+ description : Annotated [
117+ str | None ,
118+ Field (
119+ description = "Human-readable description of the software packaged in the image (string)" ,
120+ ),
121+ ] = None
122+ base_digest : Annotated [
123+ SHA1Str | None ,
124+ Field (
125+ description = "Digest of the image this image is based on (string)" ,
126+ ),
127+ ] = None
92128
93- title : str = Field (None , description = "Human-readable title of the image (string)" )
94- description : str = Field (
95- None ,
96- description = "Human-readable description of the software packaged in the image (string)" ,
97- )
98- base_digest : SHA1Str = Field (
99- None ,
100- description = "Digest of the image this image is based on (string)" ,
101- )
102129 model_config = ConfigDict (
103130 alias_generator = _underscore_as_dot , populate_by_name = True , extra = "forbid"
104131 )
@@ -123,7 +150,7 @@ class LabelSchemaAnnotations(BaseModel):
123150 NOTE: DEPRECATED IN FAVOUR OF OCI IMAGE SPEC
124151 """
125152
126- schema_version : VersionStr = Field ("1.0.0" , alias = "schema-version" )
153+ schema_version : Annotated [ VersionStr , Field (alias = "schema-version" )] = "1.0.0"
127154
128155 build_date : datetime
129156 vcs_ref : str
0 commit comments