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: prevent creating teams with reserved team names #21727

Merged
merged 9 commits into from
Sep 5, 2024

Conversation

jahzielv
Copy link
Contributor

@jahzielv jahzielv commented Aug 30, 2024

Related issue: #21264

Checklist for submitter

If some of the following don't apply, delete the relevant line.

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    See Changes files for more information.
  • Added/updated tests
  • Manual QA for all new/changed functionality

@jahzielv
Copy link
Contributor Author

Note: based on this code the requirement in the bug ticket for something like nO teAMs to be used in a VPP team assignment in gitops should fail, but the tests in main are being fixed rn, so I can't add a test to confirm. I think that can be added later tho.

@jahzielv jahzielv marked this pull request as ready for review August 30, 2024 20:05
@jahzielv jahzielv requested review from a team as code owners August 30, 2024 20:05
ghernandez345
ghernandez345 previously approved these changes Sep 2, 2024
Copy link
Contributor

@ghernandez345 ghernandez345 left a comment

Choose a reason for hiding this comment

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

FE looks good 👍🏽

Copy link
Contributor

@roperzh roperzh left a comment

Choose a reason for hiding this comment

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

looks good, left a question about consistent error messages

return nil, fleet.NewInvalidArgumentError("name", "may not be all teams")
}
if l == strings.ToLower(fleet.ReservedNameNoTeam) {
return nil, fleet.NewInvalidArgumentError("name", "may not be no team")
Copy link
Contributor

Choose a reason for hiding this comment

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

dumb question, why these have a different error message? the two below look better:

"All teams" is a reserved team name`

Copy link
Contributor Author

@jahzielv jahzielv Sep 5, 2024

Choose a reason for hiding this comment

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

@roperzh I think I was just trying to be consistent with the other errors in this part of the code. I can update it to be consistent with the other errors I added though.

Copy link

codecov bot commented Sep 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.84%. Comparing base (f186eed) to head (3a6267b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #21727      +/-   ##
==========================================
- Coverage   64.84%   64.84%   -0.01%     
==========================================
  Files        1500     1500              
  Lines      119108   119123      +15     
  Branches     3502     3509       +7     
==========================================
+ Hits        77240    77249       +9     
- Misses      34858    34861       +3     
- Partials     7010     7013       +3     
Flag Coverage Δ
backend 66.03% <100.00%> (-0.01%) ⬇️
frontend 52.39% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@roperzh roperzh left a comment

Choose a reason for hiding this comment

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

Looks good! As a nit you can totally ignore:

the error string is repeated many times, for similar cases we tend to declare a variable (there's a list of errors somewhere)

@jahzielv jahzielv merged commit 557c5d1 into main Sep 5, 2024
28 checks passed
@jahzielv jahzielv deleted the 21264-fix-reserved-team-names branch September 5, 2024 21:44
Copy link
Member

@lucasmrod lucasmrod left a comment

Choose a reason for hiding this comment

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

I was just thinking about this because I'm working on policies for "No team". And you can specify Team: "<TeamName>" for policies when applying them via fleetctl apply.

Should we do a migration to rename existing teams with the "No team" name?

@jahzielv
Copy link
Contributor Author

jahzielv commented Sep 5, 2024

Should we do a migration to rename existing teams with the "No team" name?

I was thinking about this as well! What would we rename them to?

@roperzh
Copy link
Contributor

roperzh commented Sep 5, 2024

I thought it was informally discussed we won't try to migrate old teams bye I might be misremembering

@lucasmrod
Copy link
Member

Yeah, it makes sense it would break some workflows (e.g. gitops).
That said, we should add something to the release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants