Skip to content

Make creating annotations for a command easier #5069

Open
@linear

Description

@linear

Right now creating a manifest locally requires using toml/ciborium locally.

Eg:

        use wasmer_config::package::{Command, CommandV2, CommandAnnotations, Manifest, Package};
        use wasmer_config::ciborium::Value;

        let package: Package = Package::default();
        let args = Value::Array(vec![Value::Text("-w=/assets/config.toml".to_string()), Value::Text("-g=info".to_string())]);
        let wasi_annotations = Value::Map(vec![(Value::Text("main-args".to_string()), args)]);
        let command = Command::V2(CommandV2 {
            name: "script".to_string(),
            module: ModuleReference::Dependency {
                dependency: "wasmer/static-web-server".to_string(),
                module: "webserver".to_string(),
            },
            runner: "https://webc.org/runner/wasi".to_string(),
            annotations: Some(CommandAnnotations::CBOR(Value::Map(vec![(Value::Text("wasi".to_string()), wasi_annotations)]))),
        });
        let mut manifest = Manifest::builder(package)
            .with_dependency(
                "wasmer/static-web-server",
                VersionReq::parse("1.0.4").unwrap(),
            )
            .with_command(command)
            .build()
            .unwrap();
        manifest.fs.insert("/assets".to_string(), PathBuf::from("/assets"));
        manifest.fs.insert(root.clone(), PathBuf::from(root));

Ideally, annotations should be of type Hashmap<String, AnySerializableValue>, so exposing toml and ciborium is not needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions