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

add PublicViewerConfig utils #377

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

filariow
Copy link
Contributor

@filariow filariow commented Mar 22, 2024

Signed-off-by: Francesco Ilario <[email protected]>
Signed-off-by: Francesco Ilario <[email protected]>
Signed-off-by: Francesco Ilario <[email protected]>
Comment on lines +19 to +25
func (c PublicViewerConfig) IsPublicViewer(username string) bool {
if !c.Enabled() {
return false
}

return c.Config.Username == username
}
Copy link
Contributor

Choose a reason for hiding this comment

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

should we check that c.Config.Username is not empty ? I mean could it happen that we enable the config without setting a username? WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the RegEx validation should prevent this from happening

// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`

Copy link
Contributor Author

@filariow filariow Mar 25, 2024

Choose a reason for hiding this comment

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

no, you're right, this can happen. Let me look into that more, great catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think this approach could help also here?

Copy link
Contributor

Choose a reason for hiding this comment

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

As pointed out in the comment codeready-toolchain/host-operator#998 (comment) , I would remove the field.

Signed-off-by: Francesco Ilario <[email protected]>
Copy link

codecov bot commented Mar 25, 2024

Codecov Report

Merging #377 (840d7c5) into master (d3c1484) will decrease coverage by 0.32%.
The diff coverage is 0.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #377      +/-   ##
==========================================
- Coverage   77.74%   77.42%   -0.32%     
==========================================
  Files          46       47       +1     
  Lines        1959     1967       +8     
==========================================
  Hits         1523     1523              
- Misses        376      384       +8     
  Partials       60       60              
Files Coverage Δ
pkg/configuration/publicviewer_config.go 0.00% <0.00%> (ø)

@filariow filariow marked this pull request as draft March 26, 2024 15:52
Copy link

sonarcloud bot commented Apr 17, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
7.9% Duplication on New Code

See analysis details on SonarCloud

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.

2 participants