Skip to content

docs: allow SNAP_INSTANCE_NAME var in content interface paths - #637

Open
Mohit-Chachada wants to merge 2 commits into
canonical:mainfrom
Mohit-Chachada:allow-snap-instance-name-var-in-content-interface-paths
Open

Mohit-Chachada wants to merge 2 commits into
canonical:mainfrom
Mohit-Chachada:allow-snap-instance-name-var-in-content-interface-paths

Conversation

@Mohit-Chachada

@Mohit-Chachada Mohit-Chachada commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

Comment thread docs/reference/interfaces/content-interface.md Outdated
@Mohit-Chachada
Mohit-Chachada requested a review from zyga October 15, 2026 09:46
It is recommended to only expose a single `read` path using this configuration.

(sharing-per-instance-data)=
### Sharing per-instance data

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not put that under the source section?

@Mohit-Chachada Mohit-Chachada Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved in 0cbf565


_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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think examples work wonders.

@Mohit-Chachada Mohit-Chachada Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the suggestions!
Combined inputs and updated the wording in 0cbf565

@raimundo-henriques raimundo-henriques left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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+.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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+.

@Mohit-Chachada Mohit-Chachada Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 0cbf565


_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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same rationale as above and trying to simplify the phrasing a bit.

Suggested change
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.

@Mohit-Chachada Mohit-Chachada Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 0cbf565

**consumer/snapcraft.yaml**:
```yaml
plugs:
_plug_name_:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
_plug_name_:
<plug_name>:

@Mohit-Chachada Mohit-Chachada Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 0cbf565

@@ -1 +1 @@
(interfaces-content-interface)=

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind taking the opportunity to include a metadata description? This is my current proposal.

Suggested change
---
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)=

@Mohit-Chachada Mohit-Chachada Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 0cbf565

@Mohit-Chachada
Mohit-Chachada force-pushed the allow-snap-instance-name-var-in-content-interface-paths branch from 25c47c9 to 0cbf565 Compare October 26, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants