-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(environments): Add new /environments endpoint and move /projects to Project #24154
Conversation
dd8fdee
to
039719f
Compare
6c4eaa8
to
336d8cb
Compare
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
This PR was closed due to lack of activity. Feel free to reopen if it's still relevant. |
616975b
to
471c1a3
Compare
📸 UI snapshots have been updated2 snapshot changes in total. 0 added, 2 modified, 0 deleted:
Triggered by this commit. |
📸 UI snapshots have been updated4 snapshot changes in total. 0 added, 4 modified, 0 deleted:
Triggered by this commit. |
📸 UI snapshots have been updated4 snapshot changes in total. 0 added, 4 modified, 0 deleted:
Triggered by this commit. |
Size Change: 0 B Total Size: 1.1 MB ℹ️ View Unchanged
|
📸 UI snapshots have been updated2 snapshot changes in total. 0 added, 2 modified, 0 deleted:
Triggered by this commit. |
def register_grandfathered_environment_nested_viewset( | ||
prefix: str, viewset: type[viewsets.GenericViewSet], basename: str, parents_query_lookups: list[str] | ||
) -> tuple[NestedRegistryItem, NestedRegistryItem]: | ||
""" | ||
Register the environment-specific viewset under both /environments/:team_id/ (correct endpoint) | ||
and /projects/:team_id/ (legacy, but supported for backward compatibility endpoint). | ||
DO NOT USE ON ANY NEW ENDPOINT YOU'RE ADDING! | ||
""" |
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 is a key bit
📸 UI snapshots have been updated2 snapshot changes in total. 0 added, 2 modified, 0 deleted:
Triggered by this commit. |
@@ -50,3 +56,7 @@ def __str__(self): | |||
return str(self.pk) | |||
|
|||
__repr__ = sane_repr("id", "name") | |||
|
|||
@cached_property | |||
def passthrough_team(self) -> "Team": |
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.
Should we consider having a "primary_team" field instead of using this hack?
Worried that this has the potential to be leaky - once we get one project with multiple teams, this field might point to another project's team.
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.
There is actually a guarantee in place that Team.objects.get(id=project.id)
always returns the projects' first team – even for projects with multiple environments. That's because at this point all Project and Team objects use the same source of IDs: Team.objects.increment_id_sequence()
.
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.
I see that it works now, I guess I'm assuming that it won't always be true (or it could always be true and we just allow team ids to have big gaps), so it would be better to not build logic in that depends on that?
Not awful to migrate later when we're ready to diverge, so nbd either way, but just a thing.
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.
The idea is that it will always be true, because it makes migrating things easier in the beginning. E.g. in ingestion, where events will continue to be Team-specific, but group definitions will become Project-specific
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.
I am not terribly well versed in django internals (router or auth), but from my understanding of the project, this looks good for this step of the project.
Added one comment about potentially making the passthrough relation explicit instead of magic.
Thanks for giving this a look @aspicer! |
8fe7a07
to
cf886a6
Compare
📸 UI snapshots have been updated1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
Triggered by this commit. |
Problem
Step 4 of project environments implementation. Give this a read before reviewing.
Changes
Added the
/environments
endpoint, which is based on the Team model. At the same time, moved/projects
to the Project model, with a backward compatibility feature of "passing through" reads and writes of environment-specific settings to the Team with the same ID as the Project (this means that all existingTestTeam
tests should continue to pass).TODO for self before merging: check if
project.name == project.passthrough_team.name
currently holds for all projects in both regions.How did you test this code?
TODO: Add
/environments
tests.