remove the duration part of the functionality after discussions on this subject. This cleans up a bit a code. Folded all unit tests into the DecodeOK/Invalid
redefine IsCoreBoot as the model having a kernel
there are at least tests that show we can seed such systems
the changes ind devicemgr.go prompted fixes for some remodel tests that were
confusingly running wiht OnClassic true though they were using Core models
Include all validation sets used to check in the validation error
instead of wrapping error with additional information.
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
Wrap the error returned by CheckInstalledSnaps with the new sets
that are not currently tracked. The previous approach required
marking those sets as "extra" in the validation set but was out
of place since this is only required for callers of "TryEnforce" to
resolve constraints that led to the validation error
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
We should be careful not to concatenate variable strings into the first
argument of Sprintf/Printf/Errorf: if these variable strings end up
containing a percent character, it will break the way that the printfs
arguments are interpreted. Luckily, golang is smarter than C and is able
to detect mismatches between the number of '%' and the number of
arguments, but it still can lead to unexpected results:
$ sudo snap set core refresh.rate-limit='%[2]#v'
error: cannot perform the following tasks:
- Run configure hook of "core" snap (run hook "configure": cannot parse "%!#(BADINDEX)v": no numerical prefix)
also:
$ sudo snap set core refresh.rate-limit='%#v'
error: cannot perform the following tasks:
- Run configure hook of "core" snap (run hook "configure": cannot parse "&errors.errorString{s:"no numerical prefix"}": %!s(MISSING))
Moreover, it appears that all the occurrences of such pattern in our
code are situated either on unprivileged processes (like the `snap`
client), or, when in snapd, can only be triggered by the root user
(notice the `sudo` in the commands above).
Nevertheless, let's be defensive and fix these.
There are also other occurrences of concatenations in formatting
strings, but those are only constants so they don't pose a problem. But
to avoid the risk of these strings getting updated in the future with a
mutable version, let's explicitly mark these format prefixes as `const`.