Make snap config discoverable

I can see that it is possible to set/get config options for a snap. However, I cannot find a way to define or get the config for a snap. Juju charms have a config.yaml that define the parameters and doing juju config gives the default and current settings. This makes charms self-documenting. Is there something similar for snaps?

Having a discoverable configuration would make it possible to add features to frontends, like snapweb, to manage snaps better.

in 15.04 you could call "snappy get " and get a json doc with all possible options, this was removed with the switch to core 16. i think @pstolowski recently started working on re-implemeting this (or a similar) feature for the 16 series (a search for “config” in this forum does not reveal it though).

Correct. This has undergone some changes recently and will become available with snapd 2.28. Here is the forum topic where this issue was discussed: How to "snap get" root document

You will be able to discover config options easily (in a list format by default if running in a terminal), e.g.

$ snap get core
Key       Value
bar       {...}
foo       1
refresh   {...}

$ snap get core baz 
Key      Value
bar.baz  2

And snap get <snapname> -d will yield json output with complete configuration of given snap.

1 Like

Thanks, that’s really useful.

Are there any plans to be able to define the config parameters? That’s where the approach in Juju seems superior as config.yaml provides data types, descriptions and defaults for every parameter.

Yes, we will support config schemas, but no details yet.