Repository navigation
Conversation
stefan-ctrl
left a comment
There was a problem hiding this comment.
As a draft review was requested, I've added few comments.
Generally, it looks good, and the projector seems to be used as intended.
I have a few questions regarding the business requirements, as ListenerApplication is not part of the initial projection. Is this by design or as it is still WIP, will be added at a later time?
| case *entgen.ListenerQuery: | ||
| q.Where(listener.Or( | ||
| listener.HasSubscriptionWith( | ||
| apisubscription.HasOwnerWith( | ||
| application.HasOwnerTeamWith(team.NameIn(teams...)), | ||
| ), | ||
| ), | ||
| listener.HasExposureWith( | ||
| apiexposure.HasOwnerWith( | ||
| application.HasOwnerTeamWith(team.NameIn(teams...)), | ||
| ), | ||
| ), | ||
| )) | ||
|
|
There was a problem hiding this comment.
Question:
What about filtering for ListenerApplications?
Spectre, as I understand it, is a 3-party application: Listener, Provider, Consumer.
The current filter only considers the consumer through subscription and the provider through exposure.
Should the listener application’s owner team also be allowed to view the listener?
Depending on the MC view, this might be needed.
There was a problem hiding this comment.
Ahh, I think i misunderstood this. I thought the Listener is always the Consumer. But thinking about this it makes more sense, that the Listener is from a third independent application, which requests access to the route between a Provider and Consumer.
Adding the ListenerApplication should then make this possible
There was a problem hiding this comment.
I just added the separate application to the listener.
| }) | ||
| }) | ||
|
|
||
| Context("when viewer is unrelated to the Listener", func() { |
There was a problem hiding this comment.
Is the context covert when the viewer is the application owner of the ListenerApplication (i.e. SpectreApplication)? Should they be able to view the state of the approvals?
There was a problem hiding this comment.
I added a testcase where the viewer only owns the listener application and sees the state of the approval and approval requests.
There was a problem hiding this comment.
Nice to add an additional schema test file to keep the test file clean and not cluttered 👍
6eae82e to
9ae9011
Compare
And currently i only implement the controlplane-api after this is done i'll implement the projector change, which populates it. |
9ae9011 to
4138d0e
Compare
690b2cd to
4361f6a
Compare
4138d0e to
cb31f5d
Compare
stefan-ctrl
left a comment
There was a problem hiding this comment.
First round of review. Will continue after some meetings.
| api.Module, | ||
| apiexposure.Module, | ||
| apisubscription.Module, | ||
| approval.Module, |
There was a problem hiding this comment.
For what purpose have the approval modules been removed?
| if data.ApprovalKey != "provider" && data.ApprovalKey != "consumer" { | ||
| return 0, fmt.Errorf("invalid Listener approvalKey %q", data.ApprovalKey) | ||
| } | ||
| if data.Action != "listen-"+data.ApprovalKey { |
There was a problem hiding this comment.
Minor:
"linsten-" should be a const with a comment above it, explaining why this is needed and the convention behind it.
| func (r *Repository) resolveSubscriptionID(ctx context.Context, data *ApprovalRequestData) (int, error) { | ||
| switch data.TargetKind { | ||
| case TargetKindListener: | ||
| if data.ApprovalKey != "provider" && data.ApprovalKey != "consumer" { |
There was a problem hiding this comment.
Minor:
Personal preference: Would like to see const values with some comments (1-liner), explaining our convention.
Also, perhaps both if checks could be combined. (this, and the following).
| func (r *Repository) resolveSubscriptionID(ctx context.Context, data *ApprovalData) (int, error) { | ||
| switch data.TargetKind { | ||
| case TargetKindListener: | ||
| if data.ApprovalKey != "provider" && data.ApprovalKey != "consumer" { |
There was a problem hiding this comment.
Similar to the other comments in approvalrequest
| // spec.target references. | ||
| et, lk := cachekeys.APISubscriptionMeta(data.Meta.Namespace, data.Meta.Name) | ||
| r.cache.Set(et, lk, subscriptionID) | ||
| et, lk = cachekeys.APISubscription(data.BasePath, data.OwnerAppName, data.OwnerTeamName) |
There was a problem hiding this comment.
What is the benefit of caching the keys for APISubscription in addition to the APISubscriptionInfo and why is this needed for the listener addition?
| TargetKindAPISubscription = "ApiSubscription" | ||
| TargetKindEventSubscription = "EventSubscription" | ||
| TargetKindAgenticSubscription = "AgenticSubscription" | ||
| TargetKindListener = "Listener" |
There was a problem hiding this comment.
Minor:
Would the key ListenerSubscription make more sense here, since Listener would need to be approved as well?
| BasePath string | ||
| RequestFilter *model.ListenerFilter | ||
| ResponseFilter *model.ListenerFilter | ||
| Observer Key |
There was a problem hiding this comment.
Instead of key, a direct reference to the model.* should be preferred to be in line with the other approaches.
See the following snippet as an example:
controlplane/projector/internal/domain/approval/types.go
Lines 47 to 48 in cb31f5d
The reference would then be resolved in the translator:
ApplicationInfo seems to be appropriate.
61d58be to
32f9344
Compare
66f1a9b to
fe74c70
Compare
11dc328 to
dffbe0d
Compare
ecd7a72 to
245a115
Compare
cb31f5d to
281ec72
Compare
Associate listeners with their declaring application, separate from the API consumer. Require both provider and consumer approval before marking a listener approved.
Key the Listener parent indexes by the full namespace instead of the team name, so a change in one environment no longer enqueues Listeners of another. Treat a SpectreApplication from a different environment as missing, and document the scoping of the remaining raw-client calls.
281ec72 to
6769d64
Compare
Replace the duplicated provider/consumer and listen- action checks in the approval and approval request translators and repositories with one shared helper based on the approval API key constants. Restore the original approval module registration order.
No description provided.