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

fix: return groups user has access to in group payloads #3613

Merged
merged 1 commit into from
Dec 8, 2023

Conversation

shreddedbacon
Copy link
Member

@shreddedbacon shreddedbacon commented Dec 7, 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

As identified in uselagoon/lagoon-cli#288 (comment) Users in groups with multiple roles (eg owner, developer etc) may not be able to view their project-group allocations via the cli, because the checks performed in Lagoon don't manage to marry the user groups and project groups successfully. This will manifest as the following:

$ lagoon list project-groups -p lagoon-demo
There are no groups for project 'lagoon-demo'
GROUP ID	GROUP NAME	ORGANIZATION 

instead of
$ lagoon list project-groups -p lagoon-demo
GROUP ID                            	GROUP NAME       	ORGANIZATION 
8fc64c2a-e810-4ff1-a47e-68a1501c4ae8	lagoon-demo-group	null	

When we changed the group payload to use brief representation, this meant more information was returned in the response than what is generated when a user requests their groups. This meant that the intersection that was previously performed would fail because the project group could contain all the subgroups for roles, and the user groups would only contain the group they are a member of within the main group, the intersection would fail as the two objects were now different.

This PR changes the comparison done to still match on the parent group even if the subgroups are not all returned in a user groups query.

@shreddedbacon shreddedbacon added this to the 2.17.0 milestone Dec 7, 2023
@shreddedbacon shreddedbacon marked this pull request as ready for review December 7, 2023 22:50
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 is a nice pickup

R.Intersection is overly specific here, given the two fundamentally different payloads. Doing a user<>project compare on bare group ids works better.

Tested locally ok.

@tobybellwood tobybellwood merged commit eb190da into main Dec 8, 2023
1 check passed
@shreddedbacon shreddedbacon deleted the project-group-resolver branch December 11, 2023 06:09
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.

None yet

2 participants