Repository navigation
docs: allow SNAP_INSTANCE_NAME var in content interface paths - #637
Mohit-Chachada wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review issues were identified.
0 open findings
What changed in this PR
Documents support for $SNAP_INSTANCE_NAME in content interface source paths for parallel-installed snaps.
Changes:
- Documents variable usage and snapd version requirements.
- Adds producer/consumer configuration and path examples.
| File | Summary |
|---|---|
docs/reference/interfaces/content-interface.md |
Documents per-instance content sharing. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| It is recommended to only expose a single `read` path using this configuration. | ||
|
|
||
| (sharing-per-instance-data)= | ||
| ### Sharing per-instance data |
There was a problem hiding this comment.
why not put that under the source section?
|
|
||
| _Requires snapd 2.79+._ | ||
|
|
||
| When a slot's `read` or `write` paths are declared under the `source` section, and a path starts with `$SNAP_DATA` or `$SNAP_COMMON`, it may also reference `$SNAP_INSTANCE_NAME`. This allows a {ref}`parallel-installed <interfaces-parallel-installs>` producer snap to share a separate directory for each of its instances. |
There was a problem hiding this comment.
The wording makes it sound like a single instance is somehow collecting the data from all other connected slots.
How about:
<right below the using `source` >
#### Parallel installed content providers
_Requires snapd 2.79+._
Using $`SNAP_INSTANCE_NAME `in the final source path element makes distinguishing data from multiple connected slot providers easier in the plug side snap. Specifically, given the following slot declaration:
\```
slots:
_slot_name_:
interface: content
content: assets
source:
read:
- $SNAP_DATA/assets/$SNAP_INSTANCE_NAME
\```
and the plug:
\```
plugs:
_plug_name_:
interface: content
content: assets
target: $SNAP_DATA/assets
\```
The plug side connections will be accessible at:
\```
$SNAP_DATA/assets/snap-with-slot_foo
$SNAP_DATA/assets/snap-with-slot_bar
\```
Since `$SNAP_INSTANCE_NAME` is only known at content provider snap installation time, it can only be used when sharing data from writable locations, such as `$SNAP_DATA` or `$SNAP_COMMON`.
There was a problem hiding this comment.
Interestingly, I don't get this feeling from the current phrasing.
From my newcomer perspective, I must say I find "makes distinguishing data from multiple connected slot providers easier in the plug side snap" somewhat hard to understand. I wonder whether this is explanation, more than reference. I might be totally wrong, though.
There was a problem hiding this comment.
I think examples work wonders.
There was a problem hiding this comment.
thanks for the suggestions!
Combined inputs and updated the wording in 0cbf565
raimundo-henriques
left a comment
There was a problem hiding this comment.
Thank you. I left some comments.
|
|
||
| Read, write and target should start with either ``$SNAP``, ``$SNAP_DATA`` or ``$SNAP_COMMON`` to refer to the designated directory. See {ref}`Environment variables <reference-development-environment-variables>` for details on where these point to on the filesystem. | ||
|
|
||
| Slot paths declared under the `source` section can additionally reference `$SNAP_INSTANCE_NAME`, but only within a path that starts with `$SNAP_DATA` or `$SNAP_COMMON`. This is useful for sharing a separate, per-instance directory with consumers of a {ref}`parallel-installed <interfaces-parallel-installs>` producer snap. See [Sharing per-instance data](#sharing-per-instance-data) below. Requires _snapd_ 2.79+. |
There was a problem hiding this comment.
Since the rest of the page consistently uses 'source attribute', I think it would be better to keep using that. I also think it is good to avoid 'section', as it is often used to refer to sections in the docs.
| Slot paths declared under the `source` section can additionally reference `$SNAP_INSTANCE_NAME`, but only within a path that starts with `$SNAP_DATA` or `$SNAP_COMMON`. This is useful for sharing a separate, per-instance directory with consumers of a {ref}`parallel-installed <interfaces-parallel-installs>` producer snap. See [Sharing per-instance data](#sharing-per-instance-data) below. Requires _snapd_ 2.79+. | |
| Paths declared in a slot's `source` attribute can also reference `$SNAP_INSTANCE_NAME`, but only within a path that starts with `$SNAP_DATA` or `$SNAP_COMMON`. This is useful for sharing a separate, per-instance directory with consumers of a {ref}`parallel-installed <interfaces-parallel-installs>` producer snap. See [Sharing per-instance data](#sharing-per-instance-data) below. Requires _snapd_ 2.79+. |
|
|
||
| _Requires snapd 2.79+._ | ||
|
|
||
| When a slot's `read` or `write` paths are declared under the `source` section, and a path starts with `$SNAP_DATA` or `$SNAP_COMMON`, it may also reference `$SNAP_INSTANCE_NAME`. This allows a {ref}`parallel-installed <interfaces-parallel-installs>` producer snap to share a separate directory for each of its instances. |
There was a problem hiding this comment.
Same rationale as above and trying to simplify the phrasing a bit.
| When a slot's `read` or `write` paths are declared under the `source` section, and a path starts with `$SNAP_DATA` or `$SNAP_COMMON`, it may also reference `$SNAP_INSTANCE_NAME`. This allows a {ref}`parallel-installed <interfaces-parallel-installs>` producer snap to share a separate directory for each of its instances. | |
| When a slot's `source` attribute declares `read` or `write` paths starting with `$SNAP_DATA` or `$SNAP_COMMON`, it may also reference `$SNAP_INSTANCE_NAME`. This allows a {ref}`parallel-installed <interfaces-parallel-installs>` producer snap to share a separate directory for each of its instances. |
| **consumer/snapcraft.yaml**: | ||
| ```yaml | ||
| plugs: | ||
| _plug_name_: |
There was a problem hiding this comment.
I noticed that we're using _..._ to identify placeholders on this page. As far as I can tell, it's only being done here and in reference/development/environment-variables.md. I know it's not the scope of this PR, but perhaps taking the opportunity to replace the occurrences of _..._ with <...> as a drive-by change, if you wouldn't mind, would be nice.
| _plug_name_: | |
| <plug_name>: |
| @@ -1 +1 @@ | |||
| (interfaces-content-interface)= | |||
There was a problem hiding this comment.
Would you mind taking the opportunity to include a metadata description? This is my current proposal.
| --- | |
| myst: | |
| html_meta: | |
| description: Reference documentation for the content interface, which lets producer snaps share code, data, libraries, and sockets with consumer snaps. | |
| --- | |
| (interfaces-content-interface)= |
25c47c9 to
0cbf565
Compare
Docs for canonical/snapd#17752
SNAPDENG-37629