-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
refactor: simplify getPodName
and make consistent with back-end
#12964
refactor: simplify getPodName
and make consistent with back-end
#12964
Conversation
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
…ion call Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
- cast the `NodeStatus` instead of filling it all out with unused fields Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
these seemed to have accidentally diverged in 1e87159 Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
…'t been selected Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
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.
It's easier to read each commit independently than it is to read the PR as a whole, that's why I split them that way
This is gold
Backported this refactor to |
Fixes #6982 (comment), Fixes #9168 (comment)
Motivation
Simplify
getPodName
as it required lots of args that could be retrieved from the existing Workflow and Node. Simplify surrounding code as wellMake it more consistent to the back-end as well, particularly after #12928.
Modifications
simplify calls to
getPodName
to only require the Workflow and Node as argsworkflow-details.tsx
was particularly simplified as a result, a whole function was replaced with a one-linergetPodName
in the UI more closely matchGeneratePodName
on the back-endadjust
pod-name.test.ts
to match the modified argssimplify other parts of
pod-name.ts
simplify
getTemplateNameFromNode
to a one-liner that's easier to read and reads like the comment tooif (node.templateName)
checks forundefined
,''
, and othersnode?.
is not necessary per fix: Workflow details accessing undefined templateRef. Fixes #9167 #9168 (comment), and we can invert the conditional toif (node.templateRef?.template)
slightly optimize
ensurePodNamePrefixLength
by moving the static calculation ofmaxPrefixLength
into the module scope and outside the function scopepod_name.go
use named functions for better tracing compared to
const
variables assigned to anonymous functions, same as refactor(ui): use named functions for better tracing #12062 et alVerification
Existing tests pass
Also tested manually with the Workflow from #12895.
Screenshot:
Notes to Reviewers
It's easier to read each commit independently than it is to read the PR as a whole, that's why I split them that way
Future Work
pod-name.ts
should only beexport
inggetPodName
. the rest is not used anywhere except for the testsGeneratePodName
can similarly be simplified, but it requires a lot more refactoring of functions of up the chain