docs: document default values for confdb#389
Merged
Merged
Conversation
efc6b34 to
6da256c
Compare
miguelpires
reviewed
Jun 23, 2026
miguelpires
left a comment
Contributor
There was a problem hiding this comment.
FWIW, defaults are already documented in https://snapcraft.io/docs/how-to-guides/snap-development/use-snapctl/#confdb, besides the help messages of both snap/snapctl. I'm wary of including every feature here since it's a practical how-to example and should. Maybe we can shorten it a bit
| if ! snapctl get --view :network-wifi-admin acme.ssid >/dev/null 2>&1; then | ||
| snapctl set --view :network-wifi-admin acme.ssid=acme-default | ||
| fi | ||
| ``` |
Contributor
There was a problem hiding this comment.
This is just setting a value in a hook which already has examples above
Comment on lines
+344
to
+357
| Confdb has no schema-level mechanism for declaring default values. There are two ways to provide them. | ||
|
|
||
| ### Supplying a default per request | ||
|
|
||
| If no value has been set for a requested path, `snap get` returns an error. You can supply a fallback with `--default`: | ||
|
|
||
| ```shell | ||
| $ snap get --default=acme-default <account-id>/network/wifi-state acme.ssid | ||
| acme-default | ||
| ``` | ||
|
|
||
| Snaps can use the same `--default` flag through `snapctl get --view`. In both cases, `--default` can only be used when requesting a single path. The value is returned to the caller only and isn't stored, so every reader must supply its own `--default`. | ||
|
|
||
| ### Populating defaults with a load-view hook |
Contributor
There was a problem hiding this comment.
At most, I'd keep this part IMO
Member
Author
There was a problem hiding this comment.
Fair point, I'll shorten it.
miguelpires
reviewed
Jun 25, 2026
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Robotics flagged that providing default values for confdb configuration isn't well documented. This PR adds a "Default values" section covering two approaches: supplying a per-request fallback with the
--default flagonsnap getandsnapctl get --view, and populating a default from a custodian'sload-view-<plug>hook so callers don't each have to pass one.CC: @miguelpires