change the behavior of an alt attribute matcher when matching against
a list of values to match the alternatives to each element and not
overall
this is the approach used by all other matchers against a list of
values
the old behavior was unused and as the new tests show the new behavior
is quite productive. if really needed expressing for different
variants of a list can still be done by expressing variants for one
full level up
to avoid uses of this confusing old snapd make sure format: 5 is used
to mark snap-declarations that use alt attribute matchers going
forward
FindSequence finds a sequence-forming assertion based the given
headers. Provided headers must contain a prefix of the primary key
for the assertion type except for the sequence header.
Th assertion is the first in the sequence under the prefix with
sequential number > after.
If after is -1 it returns instead the assertion with the largest
sequential number.
This will allow to hand out system-user assertions limited to a
limited set of serial assertions.
Implements the spec in https://forum.snapcraft.io/t/18163
This is a list of headers which are about the assertion specifically and can be
omitted in some contexts when outputting headers from an assertion.
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
This converts the singleton asserts.ErrNotFound to a richer asserts.NotFoundError struct carrying Type and optionally PrimaryKey, similar to store.AssertionNotFoundError which then gets folded with this.
This means code doesn't have to worry anymore which is which or to convert between the two. And when possible there is more information around. Though Backstores can continue to return minimal information (Type but not Headers in the new error).
A helper asserts.IsNotFound is also added to cover the simple old ==/!= asserts.ErrNotFound needs.
This also fixes/adjust some error handling to usually not repeat the richer information twice.