I am currently working with snapcraft, interfaces and hooks. What I want to do is to provide datastorage with a data provider snap and I have some consumer snaps. The consumer snap has to create his own folders in the provider snap when the interface is connected.
In the hook documentation (
https://docs.snapcraft.io/supported-snap-hooks/3795) you can read:
Or when an interface is connected or disconnected, the snap might need to obtain attributes specific to that connection. These types of situations are handled by hooks.
My problem now: I can´t find any hook that can do that. Is there something missing in the documentation?
this is (well, part of it):
I’ve recently started working on a disconnect hooks for the upcoming interface hooks - the idea is to support “disconnect-plug-…” and “disconnect-slot-…” hooks on respective ends of a connection, and fire them up on snap disconnect. When it comes to implementation, there will be two extra hook tasks apart from the existing “disconnect” task, similiar to how “connect” hooks are implemented.
I hit an obstacle though with our internal logic for resolving disconnect parameters. In order to create h…
which is still marked WIP…
…similiar to how “connect” hooks are implemented.
So as I understand there are already connect hooks available?
Yes, the documentation is incomplete unfortunately with that regard, but it will soon be updated as we’ve been reworking it a lot recently. Sorry about that.
The feature is already available. You can define the following hooks:
On the snap that provides a slot:
On the snap that has a plug:
From your description it looks like you want to do something in connect-* hooks. They are executed after the connection is made, when the new security profile is already in place.
I know this is not a perfect lecture, but you may take a look at our test snap used in automatic tests for some inspiration: