112 Commits

Author SHA1 Message Date
Paweł Stołowski
1fb898b3e8 Two extra test checks. 2021-02-04 15:07:41 +00: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
bd146f7a49 asserts: make parsing of integer headers more uniform
especially error handling
2020-07-06 22:03:59 +02:00
Samuele Pedroni
071ad500a5 asserts: disallow prefix zeros in revision, sequence, snap-size etc 2020-07-06 21:58:42 +02:00
Samuele Pedroni
4422c93e87 asserts: introduce Backstore.SequenceMemberAfter
implement it first for the memoryBackstore

there's also an always failing impementation for filesystemBackstore
for now
2020-06-29 13:52:36 +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
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
20c4aec9c0 asserts: introduce Pool
Motivation

With the new assertion bulk refresh API we can fetch or update
many assertions together, either assertions related/dependent or
unrelated/independent of each other.

To help driving and managing that this introduces asserts.Pool:

* a Pool can track unresolved assertions to be fetched
* or assertions to be updated
* it can record resolved assertions as fetched from the store and
  implicitly turn unresolved prerequisites into assertions to
  resolve

* assertions can be organized in groups, as the doc comment explains:
    Failure can be tracked isolated to groups, conversely any
    error related to a single group alone will stop any work to
    resolve it.  Independent assertions should not be grouped.

* assertions that are part of or are required by more than one
  group are tracked only once, for example store account-keys or
  developer account assertions for developers of many snaps on
  the system.

The latter is achieved by labeling each assertion with a Grouping
which represents all the groups it belongs to, at the low-level
this uses internal.Groupings/Grouping.

This organization into groupings matches well with the capabilities
of the API and means assertions will be typically requested only
once and grouped in ways that should be cache friendly.
2020-04-27 10:46:55 +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
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
John Lenton
7b162185ab Merge pull request #3506 from pedronis/asserts-type-max-body-size
asserts: introduce NewDecoderWithTypeMaxBodySize

NewDecoderWithTypeMaxBodySize allow to create an assertion stream Decoder that is configured with optional per-type max body sizes.

This will allow snap-repair to control what size of repair scripts/bodies is happy to accept.
2017-06-28 11:18:56 +01:00
Samuele Pedroni
62711e4c08 asserts: open up and optimize Encoder to help avoiding unnecessary copying (#3513) 2017-06-22 22:55:25 +02:00
Samuele Pedroni
b0e69e272b asserts: introduce NewDecoderWithTypeMaxBodySize 2017-06-21 16:47:23 +02:00
Michael Vogt
336a3fa0a6 rename emergency assertion to "repair" (thanks to Gustavo) 2017-04-19 07:58:58 +02:00
Michael Vogt
2adda121a8 Add skeleton for emergency fix assertion 2017-04-18 18:32:19 +02:00