Skip to content

Commit c109fe1

Browse files
Merge pull request #145 from waynr/support-oci-image-spec-110rc5
support oci image spec 110rc5
2 parents b512726 + c408449 commit c109fe1

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

src/image/descriptor.rs

+22
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,22 @@ pub struct Descriptor {
6060
#[getset(get = "pub", set = "pub")]
6161
#[builder(default)]
6262
platform: Option<Platform>,
63+
/// This OPTIONAL property contains the type of an artifact when the descriptor points to an
64+
/// artifact. This is the value of the config descriptor mediaType when the descriptor
65+
/// references an image manifest. If defined, the value MUST comply with RFC 6838, including
66+
/// the naming requirements in its section 4.2, and MAY be registered with IANA.
67+
#[serde(skip_serializing_if = "Option::is_none")]
68+
#[getset(get = "pub", set = "pub")]
69+
#[builder(default)]
70+
artifact_type: Option<MediaType>,
71+
/// This OPTIONAL property contains an embedded representation of the referenced content.
72+
/// Values MUST conform to the Base 64 encoding, as defined in RFC 4648. The decoded data MUST
73+
/// be identical to the referenced content and SHOULD be verified against the digest and size
74+
/// fields by content consumers. See Embedded Content for when this is appropriate.
75+
#[serde(skip_serializing_if = "Option::is_none")]
76+
#[getset(get = "pub", set = "pub")]
77+
#[builder(default)]
78+
data: Option<String>,
6379
}
6480

6581
#[derive(
@@ -109,6 +125,10 @@ pub struct Platform {
109125
#[serde(skip_serializing_if = "Option::is_none")]
110126
#[builder(default)]
111127
variant: Option<String>,
128+
/// This property is RESERVED for future versions of the specification.
129+
#[serde(skip_serializing_if = "Option::is_none")]
130+
#[builder(default)]
131+
features: Option<Vec<String>>,
112132
}
113133

114134
impl Descriptor {
@@ -121,6 +141,8 @@ impl Descriptor {
121141
urls: Default::default(),
122142
annotations: Default::default(),
123143
platform: Default::default(),
144+
artifact_type: Default::default(),
145+
data: Default::default(),
124146
}
125147
}
126148
}

src/image/index.rs

+15
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,24 @@ pub struct ImageIndex {
4343
#[getset(get = "pub", set = "pub")]
4444
#[builder(default)]
4545
media_type: Option<MediaType>,
46+
/// This OPTIONAL property contains the type of an artifact when the manifest is used for an
47+
/// artifact. If defined, the value MUST comply with RFC 6838, including the naming
48+
/// requirements in its section 4.2, and MAY be registered with IANA.
49+
#[serde(skip_serializing_if = "Option::is_none")]
50+
#[getset(get = "pub", set = "pub")]
51+
#[builder(default)]
52+
artifact_type: Option<MediaType>,
4653
/// This REQUIRED property contains a list of manifests for specific
4754
/// platforms. While this property MUST be present, the size of
4855
/// the array MAY be zero.
4956
#[getset(get = "pub", set = "pub")]
5057
manifests: Vec<Descriptor>,
58+
/// This OPTIONAL property specifies a descriptor of another manifest. This value, used by the
59+
/// referrers API, indicates a relationship to the specified manifest.
60+
#[serde(skip_serializing_if = "Option::is_none")]
61+
#[getset(get = "pub", set = "pub")]
62+
#[builder(default)]
63+
subject: Option<Descriptor>,
5164
/// This OPTIONAL property contains arbitrary metadata for the image
5265
/// index. This OPTIONAL property MUST use the annotation rules.
5366
#[serde(skip_serializing_if = "Option::is_none")]
@@ -191,6 +204,8 @@ impl Default for ImageIndex {
191204
media_type: Default::default(),
192205
manifests: Default::default(),
193206
annotations: Default::default(),
207+
artifact_type: Default::default(),
208+
subject: Default::default(),
194209
}
195210
}
196211
}

src/image/manifest.rs

+15
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ pub struct ImageManifest {
5050
#[getset(get = "pub", set = "pub")]
5151
#[builder(default)]
5252
media_type: Option<MediaType>,
53+
/// This OPTIONAL property contains the type of an artifact when the manifest is used for an
54+
/// artifact. This MUST be set when config.mediaType is set to the empty value. If defined, the
55+
/// value MUST comply with RFC 6838, including the naming requirements in its section 4.2, and
56+
/// MAY be registered with IANA. Implementations storing or copying image manifests MUST NOT
57+
/// error on encountering an artifactType that is unknown to the implementation.
58+
#[serde(skip_serializing_if = "Option::is_none")]
59+
#[getset(get = "pub", set = "pub")]
60+
#[builder(default)]
61+
artifact_type: Option<MediaType>,
5362
/// This REQUIRED property references a configuration object for a
5463
/// container, by digest. Beyond the descriptor requirements,
5564
/// the value has the following additional restrictions:
@@ -69,6 +78,12 @@ pub struct ImageManifest {
6978
/// attributes of the initial empty directory are unspecified.
7079
#[getset(get_mut = "pub", get = "pub", set = "pub")]
7180
layers: Vec<Descriptor>,
81+
/// This OPTIONAL property specifies a descriptor of another manifest. This value, used by the
82+
/// referrers API, indicates a relationship to the specified manifest.
83+
#[serde(skip_serializing_if = "Option::is_none")]
84+
#[getset(get = "pub", set = "pub")]
85+
#[builder(default)]
86+
subject: Option<Descriptor>,
7287
/// This OPTIONAL property contains arbitrary metadata for the image
7388
/// manifest. This OPTIONAL property MUST use the annotation
7489
/// rules.

src/image/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ pub enum MediaType {
6060
/// MediaType ArtifactManifest specifies the media type used for content addressable
6161
/// artifacts to store them along side container images in a registry.
6262
ArtifactManifest,
63+
/// MediaType EmptyJSON specifies a descriptor that has no content for the implementation. The
64+
/// blob payload is the most minimal content that is still a valid JSON object: {} (size of 2).
65+
/// The blob digest of {} is
66+
/// sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a.
67+
EmptyJSON,
6368
/// MediaType not specified by OCI image format.
6469
Other(String),
6570
}
@@ -87,6 +92,7 @@ impl Display for MediaType {
8792
),
8893
Self::ImageConfig => write!(f, "application/vnd.oci.image.config.v1+json"),
8994
Self::ArtifactManifest => write!(f, "application/vnd.oci.artifact.manifest.v1+json"),
95+
Self::EmptyJSON => write!(f, "application/vnd.oci.empty.v1+json"),
9096
Self::Other(media_type) => write!(f, "{media_type}"),
9197
}
9298
}
@@ -113,6 +119,7 @@ impl From<&str> for MediaType {
113119
}
114120
"application/vnd.oci.image.config.v1+json" => MediaType::ImageConfig,
115121
"application/vnd.oci.artifact.manifest.v1+json" => MediaType::ArtifactManifest,
122+
"application/vnd.oci.empty.v1+json" => MediaType::EmptyJSON,
116123
media => MediaType::Other(media.to_owned()),
117124
}
118125
}

0 commit comments

Comments
 (0)