Improvement: add source user and type to tasks and deployments #3631
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
General Checklist
Database Migrations
Track the user or system that triggered a task or deployment.
It adds
sourceType
andsourceUser
to Task and Deployments which can only be set when the tasks are created initially. These fields cannot be modified afterwards (beyond direct database interactions)The two trigger types are
API
andWEBHOOK
. Deployments currently support both source types.Tasks are not triggered by webhooks, so only the
API
type is available to it.The webhook source type will also try and extract information about the user that initiated the webhook call if possible, otherwise the trigger user will just be
webhook
.API source types will try and retrieve the user email address from the token, if the user triggering the task is a system token, it will extract the
iss
field from the system token, this could result in strange names if a token is really old.This does not backport the data to existing tasks/deployments as this information is unknown, so the data will be
null
for old tasks and deployments. The thought of adding anUNKNOWN
type with it being the default, so historical fields would beUNKNOWN
type. The source user could also default tounknown
if not provided. Rather than being anull
field.Closing issues
closes #3144
partially #1980 (better audit capability in lagoon needed generally)