Skip to content

Commit ebb55ce

Browse files
authored
[metadata] remove support for outdated registry fields (#1941)
1 parent fcbdf64 commit ebb55ce

File tree

8 files changed

+8
-626
lines changed

8 files changed

+8
-626
lines changed

crates/wasm-metadata/src/add_metadata.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{rewrite_wasm, Author, Description, Licenses, Producers, RegistryMetadata, Source};
1+
use crate::{rewrite_wasm, Author, Description, Licenses, Producers, Source};
22

33
use anyhow::Result;
44

@@ -41,10 +41,6 @@ pub struct AddMetadata {
4141
/// URL to get source code for building the image
4242
#[cfg_attr(feature = "clap", clap(long, value_name = "NAME"))]
4343
pub source: Option<Source>,
44-
45-
/// Add an registry metadata to the registry-metadata section
46-
#[cfg_attr(feature="clap", clap(long, value_parser = parse_registry_metadata_value, value_name="PATH"))]
47-
pub registry_metadata: Option<RegistryMetadata>,
4844
}
4945

5046
#[cfg(feature = "clap")]
@@ -54,15 +50,6 @@ pub(crate) fn parse_key_value(s: &str) -> Result<(String, String)> {
5450
.ok_or_else(|| anyhow::anyhow!("expected KEY=VALUE"))
5551
}
5652

57-
#[cfg(feature = "clap")]
58-
pub(crate) fn parse_registry_metadata_value(s: &str) -> Result<RegistryMetadata> {
59-
let contents = std::fs::read(s)?;
60-
61-
let registry_metadata = RegistryMetadata::from_bytes(&contents, 0)?;
62-
63-
Ok(registry_metadata)
64-
}
65-
6653
impl AddMetadata {
6754
/// Process a WebAssembly binary. Supports both core WebAssembly modules, and WebAssembly
6855
/// components. The module and component will have, at very least, an empty name and producers
@@ -75,7 +62,6 @@ impl AddMetadata {
7562
&self.description,
7663
&self.licenses,
7764
&self.source,
78-
self.registry_metadata.as_ref(),
7965
input,
8066
)
8167
}

crates/wasm-metadata/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ pub use metadata::Metadata;
77
pub use names::{ComponentNames, ModuleNames};
88
pub use oci_annotations::{Author, Description, Licenses, Source};
99
pub use producers::{Producers, ProducersField};
10-
pub use registry::{CustomLicense, Link, LinkType, RegistryMetadata};
1110

1211
pub(crate) use rewrite::rewrite_wasm;
1312

@@ -16,7 +15,6 @@ mod metadata;
1615
mod names;
1716
mod oci_annotations;
1817
mod producers;
19-
mod registry;
2018
mod rewrite;
2119

2220
pub(crate) mod utils;

crates/wasm-metadata/src/metadata.rs

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ use std::fmt;
44
use std::ops::Range;
55
use wasmparser::{KnownCustom, Parser, Payload::*};
66

7-
use crate::{
8-
Author, ComponentNames, Description, Licenses, ModuleNames, Producers, RegistryMetadata, Source,
9-
};
7+
use crate::{Author, ComponentNames, Description, Licenses, ModuleNames, Producers, Source};
108

119
/// A tree of the metadata found in a WebAssembly binary.
1210
#[derive(Debug, Serialize)]
@@ -18,8 +16,6 @@ pub enum Metadata {
1816
name: Option<String>,
1917
/// The component's producers section, if any.
2018
producers: Option<Producers>,
21-
/// The component's registry metadata section, if any.
22-
registry_metadata: Option<RegistryMetadata>,
2319
/// The component's author section, if any.
2420
author: Option<Author>,
2521
/// Human-readable description of the binary
@@ -39,8 +35,6 @@ pub enum Metadata {
3935
name: Option<String>,
4036
/// The module's producers section, if any.
4137
producers: Option<Producers>,
42-
/// The module's registry metadata section, if any.
43-
registry_metadata: Option<RegistryMetadata>,
4438
/// The component's author section, if any.
4539
author: Option<Author>,
4640
/// Human-readable description of the binary
@@ -116,14 +110,6 @@ impl Metadata {
116110
.expect("non-empty metadata stack")
117111
.set_producers(producers);
118112
}
119-
KnownCustom::Unknown if c.name() == "registry-metadata" => {
120-
let registry: RegistryMetadata =
121-
RegistryMetadata::from_bytes(&c.data(), 0)?;
122-
metadata
123-
.last_mut()
124-
.expect("non-empty metadata stack")
125-
.set_registry_metadata(registry);
126-
}
127113
KnownCustom::Unknown if c.name() == "author" => {
128114
let a = Author::parse_custom_section(&c)?;
129115
match metadata.last_mut().expect("non-empty metadata stack") {
@@ -170,7 +156,6 @@ impl Metadata {
170156
description: None,
171157
licenses: None,
172158
source: None,
173-
registry_metadata: None,
174159
children: Vec::new(),
175160
range,
176161
}
@@ -184,7 +169,6 @@ impl Metadata {
184169
description: None,
185170
licenses: None,
186171
source: None,
187-
registry_metadata: None,
188172
range,
189173
}
190174
}
@@ -200,16 +184,6 @@ impl Metadata {
200184
Metadata::Component { producers, .. } => *producers = Some(p),
201185
}
202186
}
203-
fn set_registry_metadata(&mut self, r: RegistryMetadata) {
204-
match self {
205-
Metadata::Module {
206-
registry_metadata, ..
207-
} => *registry_metadata = Some(r),
208-
Metadata::Component {
209-
registry_metadata, ..
210-
} => *registry_metadata = Some(r),
211-
}
212-
}
213187
fn push_child(&mut self, child: Self) {
214188
match self {
215189
Metadata::Module { .. } => panic!("module shouldnt have children"),
@@ -221,10 +195,7 @@ impl Metadata {
221195
let spaces = std::iter::repeat(" ").take(indent).collect::<String>();
222196
match self {
223197
Metadata::Module {
224-
name,
225-
producers,
226-
registry_metadata,
227-
..
198+
name, producers, ..
228199
} => {
229200
if let Some(name) = name {
230201
writeln!(f, "{spaces}module {name}:")?;
@@ -234,15 +205,11 @@ impl Metadata {
234205
if let Some(producers) = producers {
235206
producers.display(f, indent + 4)?;
236207
}
237-
if let Some(registry_metadata) = registry_metadata {
238-
registry_metadata.display(f, indent + 4)?;
239-
}
240208
Ok(())
241209
}
242210
Metadata::Component {
243211
name,
244212
producers,
245-
registry_metadata,
246213
children,
247214
..
248215
} => {
@@ -254,9 +221,6 @@ impl Metadata {
254221
if let Some(producers) = producers {
255222
producers.display(f, indent + 4)?;
256223
}
257-
if let Some(registry_metadata) = registry_metadata {
258-
registry_metadata.display(f, indent + 4)?;
259-
}
260224
for c in children {
261225
c.display(f, indent + 4)?;
262226
}

crates/wasm-metadata/src/producers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl Producers {
148148
/// Merge into an existing wasm module. Rewrites the module with this producers section
149149
/// merged into its existing one, or adds this producers section if none is present.
150150
pub fn add_to_wasm(&self, input: &[u8]) -> Result<Vec<u8>> {
151-
rewrite_wasm(&None, self, &None, &None, &None, &None, None, input)
151+
rewrite_wasm(&None, self, &None, &None, &None, &None, input)
152152
}
153153

154154
pub(crate) fn display(&self, f: &mut fmt::Formatter, indent: usize) -> fmt::Result {

0 commit comments

Comments
 (0)