-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a method to retrieve an entity by upstream ID with a hint (#4519)
* Rename EntityWithProperties to EntityWithPropertiesByID We're about to add a different `EntityWithPropertiesByUpstreamID` so let's make the names more descriptive. * Add EntityWithPropertiesByUpstreamHint When processing a webhook payload, we typically only have the information from the webhook payload available which is to say information about the upstream entity. We even don't know exactly which provider and which project are we handling. We used to sort of wing it in the github webhook handler and were just searching by upstream ID as if it was globally unique, but that no longer works with the introduction of multiple providers where several entities might have the same upstream ID or the same name, just in different providers. To handle that, we add a new method to the properties service that searches by upstream properties with a hint. At the moment, the interface supports providerID, projectID and provider implements as a hint. The immediate use is that the github provider will search by the upstream ID with the hint set to ProviderTypeGithub as that's implemented both by the app and OAuth github providers. If any attribute of the hint is set, then the entity's attribute must match the hint, otherwise the entity is filtered out. Additionally, once the entity is found, the hint might contain a property with a value that must match. The use-case there would be deleting entities where we want to ensure that we are deleting an entity with an appropriate upstream hook ID. If no entities match the hints or if multiple entities match a hint, an error is returned. Related: #4327 * getAllByProperty returns an empty list, not ErrEntityNotFound, their callers convert it to ErrEntityNotFound if needed
- Loading branch information
Showing
14 changed files
with
451 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.