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.
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?
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:
prepare-slot-<slotname>
connect-slot-<slotname>
disconnect-slot-<slotname>
unprepare-slot-<slotname>
On the snap that has a plug:
prepare-plug-<plugname>
connect-plug-<plugname>
disconnect-plug-<plugname>
unprepare-plug-<plugname>
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: