Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store,asserts,many: support the new action fetch-assertions #8536

Merged
merged 6 commits into from Apr 29, 2020

Conversation

pedronis
Copy link
Collaborator

@pedronis pedronis commented Apr 21, 2020

This is meant for fetching or updating assertions.

Given that fetching assertions can be combined with but is orthogonal to snaps operations and that assertions have prerequisites constituting a DAG (let's ignore trusted assertions), and that fetch-assertions results point to streams of assertions which are not required to match one by one the requested assertions, this uses more free-form mechanisms than what we did for snaps to declare the assertions to fetch and to return the result stream lists. The idea is that an object implementing the AssertionQuery interface will be used to track resolved and to be resolved assertions across the possibly more than one store request needed to fetch some assertions and their prerequisites. That will be defined in asserts/pool.go that here just have an intermediate definition of Grouping.

Parsing error-lists will be done in an immediate follow up.

Copy link
Contributor

@stolowski stolowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, one tiny suggestion. Thank you

@@ -342,14 +378,39 @@ func (s *Store) snapAction(ctx context.Context, currentSnaps []*CurrentSnap, act
actionJSONs[i] = aJSON
}

// assertions
i := len(actions)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be moved down to the scope of if len(toResolve) > 0 {.
But perhaps more readable would be to have single counter for both snaps and assertions loops and not to have to declare or re-set it here.

Copy link
Collaborator

@bboozzoo bboozzoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


package asserts

// A Grouping identifies opaquely a grouping of assertions.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opaquerly identifies a grouping? Something feels a bit off with the comment. Maybe it will be clearer in the PRs that follow, so it's probably better to not do anything at the moment.

@@ -41,7 +41,7 @@ type StoreService interface {
SnapInfo(ctx context.Context, spec store.SnapSpec, user *auth.UserState) (*snap.Info, error)
Find(ctx context.Context, search *store.Search, user *auth.UserState) ([]*snap.Info, error)

SnapAction(ctx context.Context, currentSnaps []*store.CurrentSnap, actions []*store.SnapAction, user *auth.UserState, opts *store.RefreshOptions) ([]store.SnapActionResult, error)
SnapAction(ctx context.Context, currentSnaps []*store.CurrentSnap, actions []*store.SnapAction, assertQuery store.AssertionQuery, user *auth.UserState, opts *store.RefreshOptions) ([]store.SnapActionResult, []store.AssertionResult, error)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to consider doing some future refactoring to the parameters this call takes, I've counted 6 atm.

@mvo5 mvo5 merged commit 24ec4ab into snapcore:master Apr 29, 2020
@pedronis pedronis deleted the fetch-assertions branch April 29, 2020 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants