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

replace special chars in user names #93

Closed

Conversation

MatousJobanek
Copy link
Contributor

so the username can be used as the name of the User resource as well as the label value


var specialCharRegexp = regexp.MustCompile("[^A-Za-z0-9]")

func sanitizeUserName(userName string) string {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

before you start asking why I didn't use the already existing functions, I was thinking about it, but decided to use this simple option, the reasons are:

  • transforming username from toolchain-common - the usage is different, it cuts the name of the username (to keep it short) as it expects that it would be used together with the namespace/space suffixes. It also does some assumptions with @ char.
  • transforming usersignup name that is in registration service - yes, we could use this one, but we would need to move it to toolchain-common first. However, I thought that we don't need any extra logic of generating the sha in case there is some special char in the username. TBH, the risk of having a conflict of the names is very low, so I would rather keep it simple and let the transformation that is in reg-service fully optimized for the usage for UserSignup names.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for this explanation :D

Copy link
Contributor

@fbm3307 fbm3307 left a comment

Choose a reason for hiding this comment

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

Would this be an add-on to #92 ?

@MatousJobanek
Copy link
Contributor Author

let me close this one - it should rather fail if the name is not compliant than doing some additional replacements

Copy link

codecov bot commented Dec 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.84%. Comparing base (9ef0ea0) to head (8b4738f).

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #93      +/-   ##
==========================================
+ Coverage   67.78%   67.84%   +0.05%     
==========================================
  Files          44       44              
  Lines        3216     3222       +6     
==========================================
+ Hits         2180     2186       +6     
  Misses        841      841              
  Partials      195      195              
Files with missing lines Coverage Δ
pkg/cmd/generate/cluster.go 80.00% <100.00%> (+3.07%) ⬆️

@MatousJobanek
Copy link
Contributor Author

the correct fix is here: #94

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.

4 participants