K8SPSMDB-1593: Refactor user annotation key generation#2232
K8SPSMDB-1593: Refactor user annotation key generation#2232ravisingal wants to merge 10 commits intopercona:mainfrom
Conversation
Refactor annotation key generation to ensure it adheres to Kubernetes naming constraints by limiting the prefix length.
egegunes
left a comment
There was a problem hiding this comment.
@ravisingal it'd be great to have some unit tests for this
added unit tests |
| func buildAnnotationKey(crName, userName string) string { | ||
| annotationKeyBase := fmt.Sprintf("percona.com/%s-%s", crName, userName) | ||
| const hashSuffix = "-hash" | ||
| const maxAnnotationNameLength = 63 |
There was a problem hiding this comment.
i think we need to move this to outside of function and use it in unit tests instead of passing the same value separately in both places
| if !strings.HasPrefix(got, prefix) { | ||
| t.Errorf("buildAnnotationKey() = %v, should start with %v", got, prefix) | ||
| } |
There was a problem hiding this comment.
Instead of using these conditions, we can use assert and require from testify as we do in other tests in this repo.
There was a problem hiding this comment.
the same of some other cases in the same test
There was a problem hiding this comment.
@ravisingal could you please check these comments
hors
left a comment
There was a problem hiding this comment.
@ravisingal please sign cla
e81adde
done. |
commit: bb80a94 |
Refactor annotation key generation to ensure it adheres to Kubernetes naming constraints by limiting the prefix length.
CHANGE DESCRIPTION
Problem:
Short explanation of the problem.
Cause:
Short explanation of the root cause of the issue if applicable.
Solution:
Short explanation of the solution we are providing with this PR.
CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
compare/*-oc.yml)?Config/Logging/Testability