Skip to content

Commit bb57662

Browse files
lirons-legitclaude
andcommitted
docs: add doc comments to touched retry-scope functions
CodeRabbit's docstring-coverage check flagged functions touched by this diff as undocumented. Add Go doc comments to buildRetryStrategyLocalScope and the two retry tests it did not already cover. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Liron Shabtai <lirons@legitsecurity.com>
1 parent c53a7b3 commit bb57662

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

workflow/controller/operator.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,6 +2140,10 @@ func getRetryNodeChildrenIds(node *wfv1.NodeStatus, nodes wfv1.Nodes) []string {
21402140
return childrenIds
21412141
}
21422142

2143+
// buildRetryStrategyLocalScope returns the lastRetry.* variables for a retry node — the retries index,
2144+
// the last retried child's exit code, status, duration, and message, and the exit-code history of all
2145+
// previous attempts — for use in retryStrategy.expression. It returns an empty scope when the node has
2146+
// no retried children yet.
21432147
func buildRetryStrategyLocalScope(node *wfv1.NodeStatus, nodes wfv1.Nodes) map[string]any {
21442148
localScope := make(map[string]any)
21452149

workflow/controller/operator_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10195,6 +10195,8 @@ func TestOperatorRetryExpression(t *testing.T) {
1019510195
assert.Equal(t, "retryStrategy.expression evaluated to false", retryNode.Message)
1019610196
}
1019710197

10198+
// TestBuildRetryStrategyLocalScope verifies buildRetryStrategyLocalScope populates the lastRetry.*
10199+
// variables from a retry node's child attempts.
1019810200
func TestBuildRetryStrategyLocalScope(t *testing.T) {
1019910201
wf := wfv1.MustUnmarshalWorkflow(operatorRetryExpression)
1020010202
retryNode, err := wf.GetNodeByName("retry-script-9z9pv[1].retry")

workflow/validate/validate_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4212,6 +4212,8 @@ spec:
42124212
args: ["{{= 2 + len(filter(split(lastRetry.exitCodes, ','), {# == '137'})) }}"]
42134213
`
42144214

4215+
// TestLastRetryExitCodesResolvesInValidation verifies that a retryStrategy template referencing
4216+
// lastRetry.exitCodes in an expression passes validation — i.e. the variable is registered in scope.
42154217
func TestLastRetryExitCodesResolvesInValidation(t *testing.T) {
42164218
err := validate(logging.TestContext(t.Context()), lastRetryExitCodesInExpression)
42174219
require.NoError(t, err)

0 commit comments

Comments
 (0)