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

Improvement: add source user and type to tasks and deployments #3631

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

shreddedbacon
Copy link
Member

@shreddedbacon shreddedbacon commented Dec 27, 2023

General Checklist

  • Affected Issues have been mentioned in the Closing issues section
  • Documentation has been written/updated
  • PR title is ready for inclusion in changelog

Database Migrations

  • If your PR contains a database migation, it MUST be the latest in date order alphabetically

Track the user or system that triggered a task or deployment.
It adds sourceType and sourceUser 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 and WEBHOOK. 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 an UNKNOWN type with it being the default, so historical fields would be UNKNOWN type. The source user could also default to unknown if not provided. Rather than being a null field.

Closing issues

closes #3144
partially #1980 (better audit capability in lagoon needed generally)

@shreddedbacon shreddedbacon force-pushed the task-deployment-user-triggered branch from 0ad8722 to 40307a3 Compare January 14, 2024 21:50
@shreddedbacon shreddedbacon changed the title feat: add user trigger source to tasks and deployments feat: add source user and type to tasks and deployments Jan 14, 2024
@shreddedbacon shreddedbacon force-pushed the task-deployment-user-triggered branch 2 times, most recently from 3b6eab8 to c88e618 Compare January 14, 2024 22:26
@shreddedbacon shreddedbacon marked this pull request as ready for review January 14, 2024 22:31
@shreddedbacon shreddedbacon added this to the 2.18.0 milestone Jan 17, 2024
@shreddedbacon shreddedbacon changed the title feat: add source user and type to tasks and deployments Improvement: add source user and type to tasks and deployments Feb 6, 2024
@shreddedbacon shreddedbacon force-pushed the task-deployment-user-triggered branch 2 times, most recently from 412cb5a to 1bb2fcc Compare February 12, 2024 09:32
@shreddedbacon
Copy link
Member Author

I've added some basic tests to the test suite to check that the fields are populated when deployments are triggered via webhook and api calls both git push and pullrequest, deployenvironmentlatest, and deployenvironment branch.

@shreddedbacon shreddedbacon force-pushed the task-deployment-user-triggered branch from 1bb2fcc to ce134f4 Compare February 12, 2024 21:21
@shreddedbacon
Copy link
Member Author

the promote test still seems to use a test-suite legacy token, when other tests uses a ci user token, this can be resolved in a separate PR though

@tobybellwood tobybellwood force-pushed the task-deployment-user-triggered branch from ce134f4 to 45628c0 Compare February 14, 2024 04:59
Copy link
Member

@tobybellwood tobybellwood left a comment

Choose a reason for hiding this comment

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

This looks good to me, and +100 for the tests.

Happy to follow up the errant test token in a follow up.

@tobybellwood tobybellwood merged commit 06a6e44 into main Feb 14, 2024
2 checks passed
@shreddedbacon shreddedbacon deleted the task-deployment-user-triggered branch February 14, 2024 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add author name to pushes
2 participants