Merge ~kwmonroe/layer-snap:bug/set-core-flag into ~stub/layer-snap:master

Proposed by Kevin W Monroe
Status: Merged
Merged at revision: dedf37530ed4300ebd926870cb9716dcf3010e87
Proposed branch: ~kwmonroe/layer-snap:bug/set-core-flag
Merge into: ~stub/layer-snap:master
Diff against target: 17 lines (+6/-0)
1 file modified
lib/charms/layer/snap.py (+6/-0)
Reviewer Review Type Date Requested Status
Stuart Bishop Approve
Review via email: mp+349204@code.launchpad.net

Description of the change

We know any snap install will ensure the 'core' snap gets installed. Set a 'snap.installed.core' flag in the install() method in case consumers want to use things like get/set for core system options.

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

I'm currently thinking we should explicitly install the core snap before installing any other snaps. This gives us a way of reporting 'snaps don't work on this machine' differently to 'requested snaps won't install for some reason'.

Revision history for this message
Stuart Bishop (stub) wrote :

This is landable and useful as-is.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/charms/layer/snap.py b/lib/charms/layer/snap.py
2index be32056..efe4893 100644
3--- a/lib/charms/layer/snap.py
4+++ b/lib/charms/layer/snap.py
5@@ -50,6 +50,12 @@ def install(snapname, **kw):
6 _install_store(snapname, **kw)
7 reactive.set_state(installed_state)
8
9+ # Installing any snap will first ensure that 'core' is installed. Set an
10+ # appropriate flag for consumers that want to get/set core options.
11+ core_installed = 'snap.installed.core'
12+ if not reactive.is_state(core_installed):
13+ reactive.set_state(core_installed)
14+
15
16 def refresh(snapname, **kw):
17 '''Update a snap.

Subscribers

People subscribed via source and target branches

to all changes: