185 Commits

Author SHA1 Message Date
Samuele Pedroni
00c3b5201c asserts: change behavior of alternative attribute matcher
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
2021-11-26 17:13:05 +01:00
Paweł Stołowski
cf75a47c6b Tweak AtSequence comment, omit "?" in the string repr if sequence point
is not set.
2021-02-04 11:36:38 +00:00
Paweł Stołowski
f027fdcf1a Handle NotFound error explicitly from Resolve; add
HeadersFromSequenceKey helper.
2021-02-03 16:28:04 +00:00
Paweł Stołowski
fe6ced9742 Extend comments, simplify String(). 2021-02-03 15:52:22 +00:00
Paweł Stołowski
293b0161b9 Introduce AtSequence type. 2021-02-03 11:16:11 +00:00
Samuele Pedroni
6adfc51ea7 Merge remote-tracking branch 'upstream/master' into asserts-find-sequence 2020-07-06 21:57:42 +02:00
Samuele Pedroni
5079d8c533 asserts: fixes
thanks @stolowski
2020-07-01 17:22:40 +02:00
Samuele Pedroni
237c0103ac asserts: implement Database.FindSequence
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.
2020-06-29 14:14:28 +02:00
Samuele Pedroni
f583badfbe asserts: adjust terminology: sequence key, sequence number 2020-06-29 13:51:54 +02:00
Samuele Pedroni
59d467f1b5 asserts: introduce the concept of sequence-forming assertion types
this is expressed via AssertionType.SequenceForming and the
SequenceMember interface

so far repair and validation-set are sequence-forming
2020-06-29 13:46:42 +02:00
Samuele Pedroni
e4afb8b356 asserts: introduce new assertion validation-set
Merge pull request #8852 from pedronis/validation-set

See the doc comment for asserts.ValidationSet.
2020-06-17 19:14:37 +02:00
Michael Vogt
50a2d9dc18 asserts: add missing systemUserFormatAnalyze() (thanks Samuele) 2020-06-15 12:12:12 +02:00
Michael Vogt
1d20b3cf88 asserts,daemon: add support for "serials" field in system-user assertion
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
2020-06-15 09:31:51 +02:00
Samuele Pedroni
e736092075 asserts: introduce new assertion validation-set 2020-06-11 20:05:45 +02:00
Samuele Pedroni
93b8dd4b6e asserts: At returning an AtRevision for convenience 2020-04-27 10:46:55 +02:00
Samuele Pedroni
660d2af1dc store,asserts: always send assertion-max-formats with fetch-assertions 2020-04-21 22:02:46 +02:00
Samuele Pedroni
66abe79f63 asserts: introduce asserts.AtRevision and Grouping
they will be used to define and organize what to request when
requesting assertions in bulk to the store
2020-04-21 22:02:46 +02:00
Samuele Pedroni
c20c2c1f3e asserts: parse plug-names/slot-names constraints
these introduce format 4 for snap-declaration
2020-01-31 11:55:37 +01:00
Ian Johnson
a2d65b7911 asserts.go,cmd/model: use array literal over slice declaration
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2019-08-20 09:56:16 -05:00
Ian Johnson
14915ce5a0 asserts/asserts.go: add MetaHeaders
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>
2019-08-09 16:18:46 -05:00
Samuele Pedroni
0d0b3d67c8 asserts: parse on-store/on-brand/on-model constraints for plug/slot rules under format iteration 3 of snap-declaration 2018-09-15 18:19:44 +02:00
Samuele Pedroni
f730383d2b empty values check in HeadersFromPrimaryKey 2017-09-12 22:30:17 +02:00
Samuele Pedroni
97e3ef21a3 many: introduce asserts.NotFoundError replacing both ErrNotFound and store.AssertionNotFoundError (#3893)
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.
2017-09-12 16:34:53 +02:00
Matt Goodall
1782ef5be1 asserts: add store assertion type (#3520) 2017-08-16 10:54:28 -03:00
John R. Lenton
9c51ec7f4c many: support querying and completing assertion type names 2017-06-30 10:13:04 +01:00