Skip to content

Commit 3edbc6c

Browse files
docs: Adds documentation on wkg.toml and wkg.lock
Also clarifies how wasm metadata is mapped to annotations Signed-off-by: Taylor Thomas <taylor@cosmonic.com>
1 parent 1d54a17 commit 3edbc6c

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,93 @@ file from the example above, then the component will be stored at
208208
`ghcr.io/webassembly/acme/foo:0.1.0`. Please note that the tag _MUST_ be a valid semantic version or
209209
the tooling will ignore it when pulling.
210210

211+
## `wkg.toml` and `wkg.lock`
212+
213+
Whenever `wkg` is used to fetch dependencies or build a wit package, it will automatically create a
214+
`wkg.lock` file. This lock file is the other standardized file that can be used by any other tooling
215+
integrating in with package tooling. Because components are cross language, this file will be the
216+
same for all languages. An example of this file is below:
217+
218+
```toml
219+
version = 1
220+
221+
[[packages]]
222+
name = "wasi:cli"
223+
registry = "wasi.dev"
224+
225+
[[packages.versions]]
226+
requirement = "=0.2.0"
227+
version = "0.2.0"
228+
digest = "sha256:e7e85458e11caf76554b724ebf4f113259decf0f3b1ee2e2930de096f72114a7"
229+
230+
[[packages]]
231+
name = "wasi:clocks"
232+
registry = "wasi.dev"
233+
234+
[[packages.versions]]
235+
requirement = "=0.2.0"
236+
version = "0.2.0"
237+
digest = "sha256:51911098e929732f65d1d84f8dc393299f18a9e8de632d854714f37142efe97b"
238+
239+
[[packages]]
240+
name = "wasi:io"
241+
registry = "wasi.dev"
242+
243+
[[packages.versions]]
244+
requirement = "=0.2.0"
245+
version = "0.2.0"
246+
digest = "sha256:c33b1dbf050f64229ff4decbf9a3d3420e0643a86f5f0cea29f81054820020a6"
247+
248+
[[packages]]
249+
name = "wasi:random"
250+
registry = "wasi.dev"
251+
252+
[[packages.versions]]
253+
requirement = "=0.2.0"
254+
version = "0.2.0"
255+
digest = "sha256:5d535edc544d06719cf337861b7917c3d565360295e5dc424046dceddb0a0e42"
256+
```
257+
258+
On the other hand, the `wkg.toml` file is used to configure various parts of the tooling and _is
259+
entirely optional_. Projects are not required to use this file. Currently, it serves two purposes:
260+
adding additional metadata and overriding versions/dependencies. The most common usage will be to
261+
point to a local dependency:
262+
263+
```toml
264+
[overrides]
265+
"my:local-dep" = { path = "../local-dep/wit" }
266+
```
267+
268+
There is also a `[metadata]` section that can be used to add additional metadata when building a WIT
269+
package (or can be used by other language tooling). For OCI, this metadata is also used to populate
270+
common OCI annotations when publishing a package. A full example of all fields are below:
271+
272+
```toml
273+
[metadata]
274+
authors = ["WasmPkg <wasm-pkg@bytecodealliance.org>"]
275+
categories = ["wasm-pkg"]
276+
description = "WASI HTTP interface"
277+
license = "Apache-2.0"
278+
documentation = "https://docs.foobar.baz"
279+
homepage = "https://foobar.baz"
280+
repository = "https://github.com/bytecodealliance/wasm-pkg-tools"
281+
```
282+
283+
### OCI Annotation Mapping
284+
285+
When publish to OCI via `wkg publish`, it will load the metadata from the wasm binary (which is
286+
automatically added to the WIT package with `wkg wit build` if the metadata is present in the
287+
`wkg.toml` file). The metadata is mapped to the following OCI annotations:
288+
289+
| `wkg.toml` Metadata Field | OCI Annotation |
290+
| ------------------------- | -------------------------------------- |
291+
| `description` | `org.opencontainers.image.description` |
292+
| `license` | `org.opencontainers.image.licenses` |
293+
| `homepage` | `org.opencontainers.image.url` |
294+
| `repository` | `org.opencontainers.image.source` |
295+
296+
Additionally, the `org.opencontainers.image.version` annotation is set to the version of the package being published.
297+
211298
## Contributing
212299
Want to join us? Check out our ["Contributing" guide][contributing] and take a look at some of these
213300
issues:

0 commit comments

Comments
 (0)