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
Conversation
they will be used to define and organize what to request when requesting assertions in bulk to the store
this is just the signature change without any logic
this is meant for fetching or updating assertions
There was a problem hiding this 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this 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. |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
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.