Skip to content

Commit 722142f

Browse files
Remove distinction around library components in wkg and PR cleanups
Signed-off-by: Kate Goldenring <[email protected]>
1 parent c13a5ff commit 722142f

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

Diff for: component-model/src/creating-and-consuming/distributing.md

+22-21
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,38 @@ You can get involved with improving the packaging and hosting of Wasm components
88

99
## The `wkg` Registry Tool
1010

11-
The [`wasm-pkg-tools` project](https://github.com/bytecodealliance/wasm-pkg-tools) enables fetching and publishing Wasm components to OCI registries. It contains a `wkg` CLI tool that eases distributing and fetching components and WIT packages. `wkg` contains several subcommand:
11+
The [`wasm-pkg-tools` project](https://github.com/bytecodealliance/wasm-pkg-tools) enables fetching and publishing Wasm components to OCI registries. It contains a `wkg` CLI tool that eases distributing and fetching components and WIT packages. The usual way of using `wkg` is to address packages by their package name, i.e. `example:[email protected]`. When using `wkg` this way, you don't need to know about the physical location of the package, as the `wkg` configuration handles that for you. If you need to, though, you can also use `wkg` to work with OCI artifacts directly, addressing them by OCI references when using the `wkg oci` subcommand.
1212

13-
- `wkg oci` - is a CLI wrapper around the [oci-wasm](https://github.com/bytecodealliance/rust-oci-wasm) crate which enables pushing/pulling Wasm artifacts to/from any OCI registry
14-
- `wkg publish` - pushes *library* components or WIT packages
15-
- `wkg get` - pulls *library* components or WIT packages
13+
`wkg` contains several subcommand:
14+
15+
- `wkg oci` - pushes/pulls Wasm artifacts to/from any OCI registry
16+
- `wkg publish` - publish components or WIT packages by package name
17+
- `wkg get` - pulls components or WIT packages by package name
1618
- `wkg wit` - commands for interacting with WIT files and dependencies
1719
- `wkg config` - interact with the `wkg` configuration
1820

1921
The following sections detail a subset of actions that can be performed with `wkg`.
2022

2123
## `wkg` Configuration Files
2224

23-
The `wkg` tool uses a configuration file to understand where to publish and fetch specific packages to and from. It provides the ability to configure:
25+
When you use most `wkg` commands (`wkg oci` being the exception), you don't interact with physical locations, only with package names. The `wkg` configuration file is used to map package naming to physical location. It provides the ability to configure:
26+
27+
- The default registry for packages in a given namespace. For example, the location for `wasi` packages such as `wasi:clocks` or `wasi:http`.
28+
- Registry overrides for specific packages, or packages not stored in the same place as the rest of their namespace. For example, if `wasi:key-value` were stored in a different registry from other `wasi` packages.
29+
- The default registry for all packages not listed in one of the previous sections
2430

25-
- a default registry for all packages at the top level of the file
26-
- a default registry for all packages of a specific namespace under `[namespace_registries]`. This section can be used to configure the registry of all `wasi` namespaced packages, such as `wasi:clocks` and `wasi:http`.
27-
- an override for package of a specific namespace under `[package_registry_overrides]`. This section can be used to fetch/publish a specific package of a namespace from/to a different location than all other packages of that namespace. For example, maybe you want to fetch `wasi:http` from a different registry.
28-
- credentials for a registry under `[registry."<registry-name>".oci]`
29-
- and more! See the [`wkg` docs for more configuration options](https://github.com/bytecodealliance/wasm-pkg-tools?tab=readme-ov-file#configuration).
31+
The configuration file also includes credentials for private registries, or for pushing to registries where you have permission, and other configuration options. See the [`wkg` docs for more configuration options](https://github.com/bytecodealliance/wasm-pkg-tools?tab=readme-ov-file#configuration).
3032

31-
For example, to fetch WASI packages, such as `wasi:clocks` and `wasi:http`, a line can be added under the `namespace_registries` section for the `wasi` namespace. Specifically, the example below configures `wkg` to fetch WASI packages from the [WebAssembly OCI GitHub Container Registry](https://github.com/orgs/WebAssembly/packages), where the latest interfaces are published upon WASI releases. To edit your `wkg` config file, simply run `wkg config --edit`.
33+
For example, to fetch WASI packages, such as `wasi:clocks` and `wasi:http`, you can add a line under the `namespace_registries` section for the `wasi` namespace. Specifically, the example below configures `wkg` to fetch WASI packages from the [WebAssembly OCI GitHub Container Registry](https://github.com/orgs/WebAssembly/packages), where the latest interfaces are published upon WASI releases. To edit your `wkg` config file, run `wkg config --edit`.
3234

33-
> Remember, all package names consist of the a namespace field followed by the package field. The package name `wasi:clocks` has a namespace of `wasi` and package field of `clocks`. In this way, the following configuration ensures that `wkg` will know to route fetches and publishes of any `wasi:x` to the configured location.
35+
> Remember, all package names consist of the a namespace field followed by the package field. The package name `wasi:clocks` has a namespace of `wasi` and package field of `clocks`. In this way, the following configuration ensures that `wkg` will know to route fetches and publishes of any `wasi:<package field>` to the configured location.
3436
3537
```toml
3638
# $XDG_CONFIG_HOME/wasm-pkg/config.toml
3739
default_registry = "ghcr.io"
3840

3941
[namespace_registries]
40-
# Instruct wkg to use the OCI protocol to fetch packages with the `wasi` namespace from ghcr.io/webassembly
42+
# Tell wkg that packages with the `wasi` namespace are in an OCI registry under ghcr.io/webassembly
4143
wasi = { registry = "wasi", metadata = { preferredProtocol = "oci", "oci" = {registry = "ghcr.io", namespacePrefix = "webassembly/" } } }
4244
```
4345

@@ -54,10 +56,9 @@ docs = { registry = "docs-registry", metadata = { preferredProtocol = "oci", "o
5456

5557
> Note: the registry name can be referenced in the `package_registry_overrides` section of the `wkg` config to provide overrides for specific packages of a namespace.
5658
59+
## Distributing WIT and Components by Package Name with `wkg publish`
5760

58-
## Distributing WIT and Library Components using `wkg publish`
59-
60-
Once you've [configured `wkg`](#wkg-configuration-files) to know where to publish packages to, you can use the `wkg publish` command to publish library *components* or *interfaces* to be consumed by others.
61+
Once you've [configured `wkg`](#wkg-configuration-files) to know where to publish packages to, you can use the `wkg publish` command to publish *components* or *interfaces* to be consumed by others.
6162

6263
Imagine you have defined the following `adder` world in WIT:
6364

@@ -85,7 +86,7 @@ wkg publish docs:[email protected]
8586
If you had configured `wkg` as described in the [`wkg` configuration section](#wkg-configuration-files), this would publish the component to `ttl.sh/wasm-components/docs/adder:0.1.0`. This WIT can then be fetched using `wkg get`, specifying the format `wit`:
8687

8788
```sh
88-
wkg get --format wit docs:[email protected]
89+
wkg get --format wit docs:[email protected] --output adder.wit
8990
```
9091

9192
Instead of publishing the WIT interface, you could publish the built component by running:
@@ -94,17 +95,17 @@ Instead of publishing the WIT interface, you could publish the built component b
9495
wkg publish adder.wasm --package docs:[email protected]
9596
```
9697

97-
This component can then be fetched by running:
98+
You can then fetch the component by running:
9899

99100
```sh
100-
wkg get docs:[email protected]
101+
wkg get docs:[email protected] --output adder.wasm
101102
```
102103

103104
## More Generic Operations with `wkg oci`
104105

105-
The `wkg oci` subcommand is a CLI wrapper around the [oci-wasm](https://github.com/bytecodealliance/rust-oci-wasm) crate which enables pushing/pulling Wasm artifacts to/from any OCI registry. Unlike `wkg publish` and `wkg get` it is not limited to library components, as providing the WIT package is not required.
106+
The `wkg oci` subcommand enables pushing/pulling Wasm artifacts to/from any OCI registry. Unlike `wkg publish` and `wkg get`, providing the WIT package is not required.
106107

107-
A component is pushed to an OCI registry using `wkg oci pull`. The example below pulls a component from a GitHub Container Registry.
108+
To push a component to an OCI registry, use `wkg oci pull`. The example below pushes a component to a GitHub Container Registry.
108109

109110
```sh
110111
wkg oci push ghcr.io/user/component:0.1.0 component.wasm

0 commit comments

Comments
 (0)