-
Notifications
You must be signed in to change notification settings - Fork 123
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
Feature: PipelineLoop: iteration counter #886
Labels
Comments
Action items:
The SDK part will be tricky because it changes the original design for parallelFor DSL. We need to first implement this feature on the controller level first to figure out what spec is easier to map back to the DSL format. |
fyi @yhwang @ScrapCodes |
Change for SDK is here: Changes for Controller are here: |
I verified that loop counter works as expected. Thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/kind feature
Description:
[A clear and concise description of what your proposal. What problem does it solve?]
Currently, PipelineLoop enables the user to choose
iterationParam
, which contains the element the loop loops over. It's a functional equivalent of the following Python code:However, the input is always sequential, so the number of each iteration is known --- as proved by the fact that
iteration_number
is populated in the execution tracking yaml. That information, however, is not available at runtime, so no task nor custom-task may use it e.g. when reporting the value. It's therefore impossible to do the functional equivalent of:Additional information:
I would suggest adding a new parameter,
iterationNumberParam
, pointing at a parameter used to denote which iteration it is in.From the DSL perspective, I'd suggest
tekton.Loop
to simply get a new field ---iteration_number
, of typeTektonLoopIterationNumber(dsl.PipelineParam)
. It would be a much simpler cousin toLoopArguments(dsl.PipelineParam)
, as no sub-vars,to_list
norfrom_pipeline_param
would be needed --- just a PipelineParam of type int that will be populated by the parameter listed initerationNumberParam
.If backward-compatibility for not generating
iterationNumberParam
would be an issue,iteration_number
can always be made a property which, on access, sets a flagiteration_number_used
so that the compiler knows if the DSL used it at least once or not. If not --- then it will generate the very same yaml it does today, so no incompatibility can occur.Example:
If that's bothersome (it may be, considering how
iteration_number
would be accessible outside of the loop body, which isn't really what is expected), some simple helper method may be added:The text was updated successfully, but these errors were encountered: