-
Notifications
You must be signed in to change notification settings - Fork 101
Validating the label values against regex #1345
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1345 +/- ##
==========================================
+ Coverage 84.88% 84.89% +0.01%
==========================================
Files 100 100
Lines 14520 14530 +10
==========================================
+ Hits 12325 12335 +10
Misses 1734 1734
Partials 461 461
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
||
labels: | ||
label1: label 1 | ||
label1: label-1 |
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.
Why the change in the label, will spaces no longer be allowed ?
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.
yeah thats correct. We are enforcing more strict rules on what values labels can have.
const maxLength = 256 | ||
labelPattern := regexp.MustCompile(regexLabelPattern) | ||
if len(labelValue) > maxLength || !labelPattern.MatchString(labelValue) { | ||
slog.Warn("Label value contains unsupported character ", "label_value", labelValue) |
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 reason for failure here could be that the label is too long, could this message me updated to mention that too
tests := []struct { | ||
name string | ||
input string | ||
wantValid bool |
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.
wantValid bool | |
expected bool |
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got := validateLabel(tt.input) |
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.
got := validateLabel(tt.input) | |
actual := validateLabel(tt.input) |
Implemented a function to validate the label value against regex to align it with N1C.
Checklist
Before creating a PR, run through this checklist and mark each as complete.
CONTRIBUTING
documentmake install-tools
and have attached any dependency changes to this pull requestREADME.md
)