Interface concepts

Interfaces are a mechanism for communication and resource sharing. It is an integral part of workshop confinement, ensuring that each workshop operates in its own isolated environment, while still allowing controlled interactions among the SDKs and with the host.

In Workshop, SDKs can act as providers and consumers of resources such as the GPU, or file directories. Host system resources are exposed via the system SDK that is present in every workshop by design.

For a workshop to be operational, the SDKs listed in its definition must connect to the resources they expect. Such connections are uniformly established via the interface system.

To achieve this, Workshop implements a counterpart to snapd’s interface manager, which controls whether an SDK can use resources beyond its confines. You can think of specific interfaces as resource types: filesystem, hardware, computing, and so on.

Specific interfaces are predefined and implemented by Workshop, so you cannot create a custom interface type. Currently, Workshop and SDKcraft support the following:

Plugs and slots

Interfaces become useful when SDKs declare plugs to consume them and slots to provide them. See Plugs and slots for the full mechanics, including the wiring you can express in the workshop definition.

Validation

All plugs and slots defined for a workshop directly or via its SDKs are checked to make sure they can be installed as part of the workshop and then connected. For this, Workshop uses a set of internal rules.

Each interface has its own rule set; for example, the mount interface plug can be installed and auto-connected based on its rules alone. However, other interfaces may have different rules, such as allowing installation but not auto-connection for ssh-agent.

Connections

From the user perspective, connections can be established through the interface system in several ways:

  • The connections section of the workshop definition and the workshop connect command can be used to link interface plugs to respective slots, allowing the SDKs to orderly access the resources.

  • Conversely, the workshop disconnect command terminates existing interface connections, revoking the access to the resources granted by the connection.

  • Finally, the workshop connections command lists all existing connections and their states, providing an overview of how workshop connections are laid out.

Some plugs can be auto-connected to their slots at launch or refresh. This behavior varies by interface, but the overall aim is to conduct reasonably in each case: the mount and the GPU interfaces are auto-connected, whereas the camera, custom device, desktop, and SSH interfaces require manual connection.

Auto-connection also depends on where a plug or slot lives. Additional slots defined for the system SDK, for interfaces such as tunnel or mount, are not auto-connected at launch or refresh, largely for security reasons: the system SDK exposes sensitive host system resources. To the contrary, plugs added under the system SDK can be auto-connected, because they expose workshop internals.

To know how each kind of connection is treated when a workshop is launched, refreshed, or restored, see Connections across refresh and restore.

See also

Explanation:

How-to guides:

Reference: